- From: Roland Steiner <rolandsteiner@google.com>
- Date: Wed, 28 Sep 2011 15:00:43 +0900
- To: fantasai <fantasai.lists@inkedblade.net>
- Cc: www-style@w3.org
- Message-ID: <CACFPSpj1Me57eov9aREcw+o6oXVbksD8GctcTrA1HYf9yZFsKA@mail.gmail.com>
On Thu, Sep 22, 2011 at 4:30 AM, fantasai <fantasai.lists@inkedblade.net>wrote: > On 09/21/2011 10:12 AM, Ian Hickson wrote: > >> On Tue, 20 Sep 2011, fantasai wrote: >> >>> On 09/20/2011 05:22 PM, Ian Hickson wrote: >>> >>>> On Tue, 20 Sep 2011, fantasai wrote: >>>> >>>>> >>>>> So, given that, rather than having a "scoped vs. global" switch, how >>>>> about using a pseudo-class to distinguish whether a portion of the >>>>> selector is matching out-of-scope elements? E.g. >>>>> >>>>> <style scoped> >>>>> section> h1 { border-bottom: solid; } >>>>> :context(body.homepage) h1 { color: red; } >>>>> :context(body.archive) h1 { color: gray; } >>>>> </style> >>>>> >>>> >>>> ...what element does the :context() match against? >>>> >>> >>> The one defining the scope. >>> >> >> So basically :context(...) is like :scope:matches(... #) ? >> > > Yes. Although I was thinking of having these work differently: > > :context(blockquote) > p { ... } > :context(blockquote) p { ... } > > So :context(...) would be more like > > :scope-or-ancestor-of-scope:**matches(...) > That would mean that the same selector that would match an element within <style scoped> wouldn't match the same element if used in <style> (i.e., without scoping), because :scope is then equivalent to :root, and the context very likely no longer matches. @global doesn't suffer this issue. But why limit this to the scope? It seems to me, that this could be useful in a general way, basically A:context(X) saying that the element A must have an ancestor that matches X, or match X itself. That would also prevent the above issue, AFAICT. OTOH, it then _is_ the same as "A:matches(X), A:matches(X #)". For the purposes of scoped selector matching, we could rule that selectors within :context (and :matches?) are exempt from scoping (you then couldn't have a scoped context, but I guess that's a negligible drawback). As stated elsewhere, I like the parallel between @global <-> querySelector and no @global <-> queryScopedSelector, but I guess either approach would work. Cheers, - Roland
Received on Wednesday, 28 September 2011 06:01:28 UTC