Re: [csswg-drafts] [css-scoping] Please bring back scoped styles (#3547)

@Heydon It's a proposal that was put together many years ago. It was dropped because nobody seemed to be interested in it. Work continued on Web Components, and the scoped style proposals were deleted from the specs.

Wrt your example, doing exactly that would require bringing back HTML scoped styles, which is a different syntax for triggering the same behavior as @scope. In either case, you're binding some styles to a scoping root: the HTML syntax implies that relationship by placing the <style> element inside the scoping root, and the CSS syntax uses a selector. (The downside to the HTML approach is that you have to inject the style sheet into the markup. Which maybe isn't too bad if you only have one instance, but it can be pretty repetitive if you have multiple instances with the same styles!) If you wanted to tie some @scope'd CSS rules to a particular instance of custom-element, it's possible: you could do it with an ID selector, for example. @scope binds to whichever elements are selected by the @scope, and if you somehow manage to select only that custom-element instance (whether using ID selectors or some other method that happens to select only that one element) then it only binds to that instance.

-- 
GitHub Notification of comment by fantasai
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/3547#issuecomment-458364886 using your GitHub account

Received on Tuesday, 29 January 2019 01:01:37 UTC