- From: Leif Halvard Silli <xn--mlform-iua@xn--mlform-iua.no>
- Date: Tue, 29 Sep 2009 15:11:39 +0200
- To: Øyvind Stenhaug <oyvinds@opera.com>
- CC: public-css-testsuite@w3.org
Øyvind Stenhaug On 09-09-29 12.04: > On Tue, 29 Sep 2009 03:42:13 +0200, Leif Halvard Silli > <xn--mlform-iua@målform.no> wrote: > >> UAs generally support omitted '*' just fine, except - it turns out - >> when used with namespaces: current release of Firefox and Opera will >> then not even accept the selector as _valid_. As a consequence the "bar" >> selector of the following rules gets ignored (since Firefox/Opera think >> the preceding selector is invalid): >> >> *|[foo], bar{} *|.foo, bar{} *|#foo, bar{} *|:first-child, bar{} > > These "foo" constructs don't seem to be allowed by the Selectors grammar > (<http://www.w3.org/TR/css3-selectors/#w3cselgrammar>). In pointing to that grammar, do you then refer to the following 3 lines - or do you also refer to something more than that in that grammar? The 3 lines: universal : [ namespace_prefix ]? '*' ; If this is all you refer to, then please note that the [namespace_prefix] is a 0 or 1 option. And that there are no special rules defined here w.r.t. whether there is - or isn't - a namespace prefix. Thus, if these 3 lines are all that you refer to, and if your reading of the rule is correct, then we would also have to conclude that the following example, which is based on an example from the Universal selector section - and which the draft directly says is _legal_ [see below], actually is illegal: [hreflang|=en]{color:lime} And thus, if this is the case - if the grammar says that this rule is wrong, then the grammar is not in tune with the prose of the draft - or with common implementations either. Let me go through what the prose says: The prose says [http://w3.org/TR/css3-selectors/#universal-selector]: "If the universal selector is not the only component of a sequence of simple selectors, the * may be omitted." Examples: *[hreflang|=en] and [hreflang|=en] are equivalent, [ snip ] The logical conclusion to this is that [hreflang|=en] is - in fact - a universal selector. Because, according to CSS 2.1, every simple selector is either a universal selector or type selector [http://w3.org/TR/CSS21/selector.html#selector-syntax]. The next section of CSS3 selectors talks about universal selectors and namespaces [http://w3.org/TR/css3-selectors/#univnmsp]. All of the examples in that section types the "*" directly - but we cannot conclude from that, that the "*" _has_ to be typed directly. Here are the example section in full: ns|* all elements in namespace ns *|* all elements |* all elements without a namespace * if no default namespace has been specified, this is equivalent to *|*. Otherwise it is equivalent to ns|* where ns is the default namespace. Here it is said that "*" is equivalent to "*|*". The logical conclusion is "*|*" and "*" are equivalent also when the universal selector is omitted. Thus it is logical that *|*[hreflang|=en] and *|[hreflang|=en] are equivalent with *[hreflang|=en]' and [hreflang|=en] - see the first example that I quoted. Further below, the draft speaks about attribute selectors, including namespaces and attribute selectors [http://w3.org/TR/css3-selectors/#attrnmsp]. Here the draft *does not* discuss *|[attr]. Instead it discusses [ns|attr]. This, if you ask me, confirms that a lone [attr] is a legal, universal selector also when it is written as *|[attr]. The Selectors Level 3 draft could need an update that makes clear that it is permitted to write *|[attr] (or that directly forbids it, if that should become the solution - I hope not, and see no reason to do it - on the contrary [more on that later, if need be ...]). All this confirms that it is correct to warn against omitting the "*", as I believe Selectors Level 3 does. But it also points to a language problem: When the draft speaks about attribute selectors, then it does - in one way - actually speak about universal and/or type selectors. Perhaps the draft should say that, whenever an attribute selector is not attached to a type selector or to the "*", then it represents - in fact - a universal selector. -- leif halvard silli
Received on Tuesday, 29 September 2009 13:12:26 UTC