Re: [css3-mediaqueries][cssom] Empty media queries in stylesheets and the DOM

Le 28/04/10 19:50, L. David Baron a écrit :

> As Daniel pointed out in today's telecon, we also need to specify
> whether that restriction for @media is syntactic (something enforced
> only at parse time) or dynamic (something that's also enforced after
> mutation of the media list is mutated via the object model).  I
> believe Daniel said that it should be syntactic (a parse time check
> only), which happens to be what I implemented.  I also agree that
> this is the right thing (presuming we want this restriction on
> @media at all); I would not want to have to implement dynamic
> enforcement of this restriction, while enforcing it syntactically is
> a one line code change (see the patch in the above bug).  However,
> it would mean that an @media rule all of whose media had been
> removed dynamically would have to be serialized as @media all, a
> slight quirk.

1. IF WE DON'T CHANGE THE SYNTACTIC RULE
----------------------------------------

I pondered the possibility to say a CSSMediaRule with an empty
media list applies to no medium at all...
But on the OM side, we need to be able to take a given CSSMediaRule and
copy an existing media list inside that CSSMediaRule. Suppose that
media list is empty - meaning "all" for the source object - the
CSSMediaRule must then deal with an empty media list as meaning "all".
In summary, that means we need the following:

   a. a CSSMediaRule with an empty media list applies to all media.
   b. an empty media list attached to a CSSMediaRules is serialized as
      "all" to preserve validity of the serialization

2. IF WE CHANGE THE SYNTACTIC RULE AND ALLOW @media {}
------------------------------------------------------

Then we need to check if existing web pages use @media {} at all
in a way we're not aware of (a hack). If the change is harmless
and we allow @media {}, then we have nothing to do on the OM side,
period.

CONCLUSION
----------

We have to deal with all of this because both @media syntax and OM
were designed at a time Media Queries did not exist. Option 1 above
is workable and induces no change on the syntactic side, but has a
light side-effect on the OM one: parsing of the serialization of a
CSSMediaRule with an empty media list will NOT be equal (from an OM
point of view) to the original CSSMediaRule.
Option 2 above is hyper-simple if workable. My gut feeling is that we
should aim at option 2. With my editor's implementor hat on, I don't
like the side-effect of option 1 I just highlighted above. Such things
should not happen. I could live with it though; does not mean I find
it a beautiful solution.

</Daniel>

Received on Friday, 30 April 2010 11:05:15 UTC