W3C home > Mailing lists > Public > www-style@w3.org > April 2010

[cssom] Comments on "Serializing Selectors"

From: L. David Baron <dbaron@dbaron.org>
Date: Wed, 21 Apr 2010 09:43:50 -0700
To: www-style@w3.org
Message-ID: <20100421164350.GA19252@pickering.dbaron.org>
Some comments on Section 4.2 of cssom, at:
http://dev.w3.org/csswg/cssom/#serializing-selectors follow:

The conditions for (1) and (2) in the list at top-level in the
section are hard to understand, and I also think they're incorrect
in a relatively important case (although I'm not completely sure I
understand their implications):  I think they require the omission
of a universal-selector with a non-default namespace prefix that's
in a sequence of simple selectors that has another simple selector
in it.  In other words, I think the current rules require that:
be serialized as:
even when the default namespace is not svg.

I think the goal of the rules ought to be to serialize a "*" under
two conditions:
 * the universal selector is associated with a non-default namespace
 * there is nothing other than a universal selector in the sequence
   of simple selectors
If these rules are ever intended to be applied in cases where the
default namespace under which the selector is serialized is
different from the default namespace when the selector was parsed,
then we need to be extra careful, since that would mean that there
would be a need to serialize "*" even in cases where there was no
explicit "*" written by the author.  (This doesn't actually matter
in Gecko's implementation, since we don't store whether the author
wrote an explicit "*"; we only store the result of what it means.)
See my parenthetical comment about data model below.

# 4. If this is the last part of the chain of the selector and there
# is a pseudo-element, append "::" followed by the name of the
# pseudo-class, to s. 

"pseudo-class" should be "pseudo-element"

In the rules for type and universal selectors:

  The spec should probably have a separate case for the case where
  there is a default namespace that is not "*", but the namespace
  for the selector is that any namespace is allowed:  you have to
  serialize a "*|".  It's not clear to me whether that's implied by
  the current cases.

  # 4.  If this is a universal selector append "* (U+002A) to s. 

  There's a missing quote after the "*".

  (I'm also a little concerned that the spec might be written under
  the assumption of a specific data model that's not described
  anywhere.  In particular one could think of storing selectors in
  two possible ways:
    * as a list of all the things written
    * as a structure that has a slot for each type of selector
  In some ways, the handling of type/universal selectors and their
  namespaces is aligned more with the latter than the former, since
  default namespaces apply even when the universal selector is
  implied rather than written, but the spec seems to describe things
  more in terms of the first data model.  Gecko's storage is
  actually more like the second.)

In the rules for attribute selectors:

  As for type/universal selectors, I think you need a case for
  serializing the "*|" namespace.

  # 3.  If the namespace prefix maps to a namespace that is the null
  # namespace (not in a namespace) append "|" (U+007C) to s. 

  I don't think this is needed (or desired) since default namespaces
  do not apply to attribute selectors.

Finally, serializing the argument to :not() should be the rules to
"serialize a simple selector", not "serializing a group of
selectors".  This is actually substantively important, since
otherwise you'd get extra "*|*" generated for :not() around anything
other than a type or universal selector when there is a default


L. David Baron                                 http://dbaron.org/
Mozilla Corporation                       http://www.mozilla.com/
Received on Wednesday, 21 April 2010 16:44:19 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:07:45 UTC