Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: shadow root support #2138

Closed
wants to merge 3 commits into from
Closed

Conversation

jon-w1
Copy link

@jon-w1 jon-w1 commented Sep 24, 2021

Background

Importing react-native-web kicks off StyleSheet resolution on a single style element which gets added to the head of the HTML document. However, when rendering an application within a Shadow DOM root (e.g. when encapsulating within an HTML custom element), any stylesheets from the main document are ignored.

Issue Link

#1517

In This Update

  • Updated renderApplication to check if the rootTag's RootNode is of ShadowRoot type. If so, an additional style tag is added to the shadow root
  • Modified createStyleResolver to insert any new rules into both the document-level stylesheet as well as any additional shadow root stylesheets

This is my first PR for RNW so let me know if there's anything else I should consider!

@necolas
Copy link
Owner

necolas commented Sep 29, 2021

I think there was a similar issue with rendering into sourceless iframes. Perhaps this patch could be adapted to include support for that use case too?

@necolas
Copy link
Owner

necolas commented Sep 29, 2021

And it's possible this overlaps with the issue for using multiple windows (i.e., roots) in an electron environment #1765

@necolas
Copy link
Owner

necolas commented Nov 10, 2021

@jon-w1 following up on the comments above. Thanks

@zarubond
Copy link
Contributor

And it's possible this overlaps with the issue for using multiple windows (i.e., roots) in an electron environment #1765

Here I am creating a fix for multiple windows/iframes https://github.com/zarubond/react-native-web/tree/zarubond/multi_root

@necolas necolas mentioned this pull request Jan 31, 2022
7 tasks
@necolas necolas added this to the 0.18: StyleSheet milestone Mar 1, 2022
necolas added a commit that referenced this pull request Mar 2, 2022
* Improves React Native compatibility by making StyleSheet.create the identify function.
* Improves React 18 support by inserting styles on eval.
* Supports use with multiple windows (i.e., iframes) and shadow roots.
* Supports nested LTR/RTL layouts.
* Supports 3rd party compilers and extraction to static CSS.
* Fixes static and dynamic short/longform deduplication.
* Reduces browser support: Safari 10.1+, Chromium Edge, no IE, no legacy Android browsers.
* Removes automatic vendor-prefixing of inline styles (for better perf).
* Removes focus-visible polyfill as modern browsers no longer show focus rings for mouse interactions.

Close #2208
Fix #2138
Fix #2196
Fix #2007
Fix #1517
@necolas necolas added the has: pr Subject of a pull request label Mar 2, 2022
@necolas necolas mentioned this pull request Mar 23, 2022
@necolas necolas closed this in b27c982 Jun 10, 2022
rnike pushed a commit to VeryBuy/react-native-web that referenced this pull request Sep 13, 2022
* Improves React Native compatibility by making StyleSheet.create the identify function.
* Improves React 18 support by inserting styles on eval.
* Supports use with multiple windows (i.e., iframes) and shadow roots.
* Supports nested LTR/RTL layouts.
* Supports 3rd party compilers and extraction to static CSS.
* Fixes static and dynamic short/longform deduplication.
* Reduces browser support: Safari 10.1+, Chromium Edge, no IE, no legacy Android browsers.
* Removes automatic vendor-prefixing of inline styles (for better perf).
* Removes focus-visible polyfill as modern browsers no longer show focus rings for mouse interactions.

Close necolas#2208
Fix necolas#2138
Fix necolas#2196
Fix necolas#2007
Fix necolas#1517
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has: pr Subject of a pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants