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

[ShadyDOM] Shadow DOM is not scoped and elements doesn't get style-scope when template is cloned after CE definition #77

Open
2 of 3 tasks
TimvdLippe opened this issue Jun 17, 2018 · 3 comments

Comments

@TimvdLippe
Copy link
Contributor

From @tomalec on January 10, 2018 16:10

Description

Shadow DOM styles are not scoped for vanilla JS Custom Elements and shadow DOM content does not get style-scope my-element class when element is cloned and stamped after CE definition

Live Demo

http://jsbin.com/sekilom/edit?html,output

Steps to Reproduce

  1. Create a template with <my-element>
  2. Define my-element in the way it attaches open shadow root in constructor or attributeChangedCallback, the shadow root that contains styles and elements.
  3. Clone the template, stamp it to the main document

Expected Results

  1. Styles should get scoped,
  2. Elements should get style-scope my-element class

Actual Results

  1. Styles are not scoped,
  2. Elements didn't get style-scope my-element class

Browsers Affected

  • Chrome
  • Firefox
  • Edge
  • [?] Safari 9
  • [?] Safari 8
  • [?] IE 11

Versions

  • webcomponents: v1.0.22

Investigation

When element is created:

  • before upgrade, or
  • added after upgrade with .innerHTML, or
  • stamped from a template created after upgrade

elements get style-scope ... class, so are at least scopeable

I tried ShadyCSS.styleElement with no luck.
I suspect ShadyCSS assumes every custom element instance should have the same shadow root what is not true per spec and in my case. https://github.com/webcomponents/shadycss/blob/master/src/scoping-shim.js#L233 early returns early, even though my element has shadowRoot.

Copied from original issue: webcomponents/webcomponentsjs#883

@TimvdLippe
Copy link
Contributor Author

Issue still exists: http://jsbin.com/secotoveta/edit?html,output

@adjenks
Copy link

adjenks commented Apr 26, 2019

Experiencing this issue as well.

@dfreedm dfreedm transferred this issue from webcomponents/shadydom Jun 7, 2019
@dfreedm dfreedm changed the title Shadow DOM is not scoped and elements doesn't get style-scope when template is cloned after CE definition [ShadyDOM] Shadow DOM is not scoped and elements doesn't get style-scope when template is cloned after CE definition Jun 12, 2019
dfreedm pushed a commit that referenced this issue Jun 12, 2019
* clone scripts inside templates

* skip test if template is not supported

* Clone scripts also in nested templates

webcomponents/html-imports#77
webcomponents/webcomponentsjs#872

* test with template polyfill

* expand tests for cloned templates

* chai.assert -> assert

* test with fix-template-scripts branch

* cannot exec w/o cloning, remove wrong test

* use template v1.2.1
@stale
Copy link

stale bot commented Apr 22, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Apr 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants