[whatwg] scoped style sheets and @-rules
Ian Hickson
ian at hixie.ch
Thu Aug 1 14:50:50 PDT 2013
On Mon, 21 Jan 2013, L. David Baron wrote:
>
> I thought I'd brought this issue up before, but I can't seem to find a
> record of it.
>
> http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#attr-style-scoped
> currently says that, inside scoped style sheets, @page rules are
> ignored, but other @-rules are honored, scoped either to the style sheet
> or to the subtree.
>
> I think it makes perfect sense to honor @-rules whose effects are scoped
> to the style sheet (@namespace, also @charset if it weren't already
> ignored) or @-rules whose effects are to condition the rules inside of
> them (all the rules in css3-conditional: @media, @supports) or import
> more rules (@import).
>
> But I think it's a large amount of extra implementation complexity to
> honor @-rules whose purpose is to build global dictionaries (in
> particular, @keyframes and @font-face), and I suspect the end result of
> honoring them would yield technology that's more confusing for authors.
> Anything that can be done by changing the meaning of an @keyframes or
> @font-face rule within a subtree could also be done by declaring a
> different animation rule or font-family within that subtree. I suspect
> the extra clarity from the latter makes it a better authoring practice
> anyway, so I don't think implementations should be required to add
> support for a feature that it's better to not use.
>
> Thus I think the specification should mandate that @keyframes and
> @font-face are ignored in scoped style sheets, just like @page.
>
> I think it would also be good if the specification left the effects of
> unknown @-rules undefined until whether they should be supported can be
> properly considered.
I've deferred to the as-yet non-existent CSS Scoped Style Sheets
specification on these matters.
My concern with @font-face is that if we allow it and treat it as a global
rule, it lets a scoped sheet mess around quite dramatically with the rest
of the page, and if we disallow it, it prevents a pretty useful feature --
if people find type face control useful outside of scoped sheets, then why
would they not want it just as much when syndicating the same content?
Same with the @-rules for animation. Can we just not do good animations in
scoped style sheets?
Or indeed with components. Telling authors they can't do good typography
with their components, or can't define keyframes for animation, etc, seems
like a losing proposition.
On Mon, 21 Jan 2013, Tab Atkins Jr. wrote:
>
> I think it makes sense to be able to create @keyframes and @font-face
> rules inside of a Component's style sheet, which is implicitly scoped,
> for example. Similar things (@counter-style, @text-transform, @image,
> other imaginary things with similar effect) also make sense in the same
> way.
I would be concerned about namespace collisions. We've made that mistake
with JS, where different libraries would stop on each other, to the point
where we're now adding modules, and JS actually has scoping built-in, so
it'd be even more dire with CSS, as far as I can tell.
--
Ian Hickson U+1047E )\._.,--....,'``. fL
http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,.
Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
More information about the whatwg
mailing list