scoped-polyfill icon indicating copy to clipboard operation
scoped-polyfill copied to clipboard

scoped styles not applied to scoping element itself

Open thomaspark opened this issue 10 years ago • 4 comments

Scoped styles aren't applied to the scoping element itself (e.g., #scopedByScopedPolyfill_1), just to its children. See: http://stackoverflow.com/questions/19538711/html5-scoped-styles-on-parent-scoping-element

thomaspark avatar Jun 11 '15 06:06 thomaspark

+1 I ended up just programmatically wrapping the parent element and then moving the style element into the wrapper before running the polyfill. It would be great if this worked like the spec, though.

benmarch avatar Mar 05 '16 06:03 benmarch

@benmarch, I ended up creating a polyfill that should work close to spec, including support for :scope selector for parent element:

https://github.com/thomaspark/scoper/

thomaspark avatar Mar 05 '16 21:03 thomaspark

Thanks, @thomaspark, that looks great! The only issue is that my company still supports IE8, which is the only reason I chose this polyfill (I was originally using another one that didn't work in IE8 or 9). If you are interested, I could create a PR for scoper that would make it IE8 compatible--after a quick glance at your source code, it looks like it would be fairly straight-forward. For reference, I am using this in an AngularJS library to dynamically add scoped styles to components and directives.

benmarch avatar Mar 05 '16 23:03 benmarch

Hey @benmarch, sure, if it's pretty straightforward, I'd be interested in a PR to add IE8 support.

thomaspark avatar Mar 06 '16 21:03 thomaspark