Re: [csswg-drafts] [css-selectors][css-namespaces] Lexical Scoping (#4061)

> What I mean is, in the above example, if markdown:class affects the namespace targeting of the child <p> element, that's not how namespaced attributes were originally defined AFAICT.

As, the confusion here is because I wasn't proposing that `<p>` would be namespaced or that the root element's tagname or other attributes were in the namespace of the stylesheet. That's why I used a descendant combinator (`:scope p`) which is selecting `<p>` in the html namespace that is a descendant of an element that matches the `:scope`.

> however, I would still only expect that to have an effect on that particular element.

That means your expectations match what I was proposing!  Huzzah!

It looks like you're trying to accomplish scoping selectors to match a subtree of elements like what happens with a web component. That wasn't something that I was proposing. I'm simply proposing a namespacing ability so that we can avoid naming collisions. If the stylesheet had an unscope tagname selector `p { ... }` in it, it would match every `<p>` tag in the document.

Basically, this works exactly like what you'd expect css-modules to accomplish, it treats class and id identifiers as lexically scoped, but you still have to use combinators with those lexically scoped idents to avoid styles bleeding into other parts of the document.

I think the idea of a subtree-scoping capability is interesting. My sense is that web components handle that case well or eventually will be made to do so, so I was hoping to just solve the isolated problem of third-party css files and name collisions which, afaik, still exists as a (theoretical) problem in web components too.



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

Received on Tuesday, 27 August 2019 05:15:58 UTC