Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does IOS Safari support Shadow DOM?

My application is able to render the Shadow DOM, but the inspector cannot display the shadow root. Can anyone help me out on this?

like image 454
geoyws Avatar asked Apr 07 '17 05:04

geoyws


People also ask

Do web components work in Safari?

Apple Safari supports Web Components, apart from Customized Built-In Elements.

Where is shadow DOM used?

Shadow DOM is very important for web components because it allows specific sections of the HTML document to be completely isolated from the rest of the document. This means CSS styles that are applied to the DOM are not applied to the Shadow DOM, and vice versa.

Can I use declarative shadow DOM?

Declarative Shadow DOM can be used on its own as a way to encapsulate styles or customize child placement, but it's most powerful when used with Custom Elements. Components built using Custom Elements get automatically upgraded from static HTML.

Does shadow DOM improve performance?

First off, it's true that shadow DOM can improve style performance, so our theory about style encapsulation holds up. However, ID and class selectors are fast enough that actually it doesn't matter much whether shadow DOM is used or not – in fact, they're slightly faster without shadow DOM.


1 Answers

It depends on which Shadow DOM you mean—Shadow DOM v0 or Shadow DOM v1.

See http://caniuse.com/#feat=shadowdomv1 and http://caniuse.com/#feat=shadowdom

No version of Safari supports Shadow DOM v0. But as far as iOS Safari, version 10.2+ support Shadow DOM v1 with the following limitation:

Certain CSS selectors do not work (:host > .local-child) and styling slotted content (::slotted) is buggy.

About differences between Shadow DOM v0 and v1, see https://hayato.io/2016/shadowdomv1/


2020-07-31 update: Shadow roots are no longer hidden in Safari Web Inspector — instead they’re now always shown, regardless. See https://trac.webkit.org/changeset/253706/webkit/


In older versions of Safari where Web Inspector does not show shadow roots by default, there’s a button you need to click to show shadow roots; it looks like this:

WebKit Inspector shadow-dom button
And in the Inspector UI, it’s in the toolbar on the right below the tabs. It turns blue when activated:

enter image description here

like image 147
sideshowbarker Avatar answered Oct 18 '22 02:10

sideshowbarker