Mon, 11 Aug 2014 19:06:45 -0700
[selectors] Fix our handling of universal selector to not be implied; tweak default namespace definition accordingly, and generally rewirite the namespace/type selector sections.
selectors/Overview.bs | file | annotate | diff | comparison | revisions | |
selectors/Overview.html | file | annotate | diff | comparison | revisions |
1.1 --- a/selectors/Overview.bs Mon Aug 11 14:30:47 2014 -0700 1.2 +++ b/selectors/Overview.bs Mon Aug 11 19:06:45 2014 -0700 1.3 @@ -657,11 +657,11 @@ 1.4 but not only elements with <a>shadow trees</a> have ''::shadow'' pseudo-elements. 1.5 </div> 1.6 1.7 - Four aspects of a DOM element are especially relevant for selectors: 1.8 + Five aspects of a DOM element are especially relevant for selectors: 1.9 1.10 <ul> 1.11 - <li>The element's type (also known as tagname), 1.12 - which is a pair of strings: a namespace and a local name. 1.13 + <li>The element's type (also known as tagname), which is a string. 1.14 + <li>The element's namespace, which is a string. 1.15 <li>An ID, which is a string. 1.16 <li>Classes, which are strings. 1.17 <li>Attributes, which are pairs of strings consisting of an attribute name and an attribute value. 1.18 @@ -673,12 +673,12 @@ 1.19 are called <dfn export title="feature selector">feature selectors</dfn>. 1.20 1.21 While elements may lack any of the individual <a>features</a>, 1.22 - some elements are <dfn export>featureless</dfn>, 1.23 - which means that not only do they lack any <a>features</a> 1.24 - (and thus will never match a <a>feature selector</a>), 1.25 - but any selectors that reference <a>features</a>, 1.26 - such as '':not(div)'', 1.27 - also never match them. 1.28 + some elements are <dfn export>featureless</dfn>. 1.29 + A <a>featureless</a> element does not match any <a>feature selector</a>, 1.30 + or any selector that resolves based on <a>features</a> 1.31 + (such as '':not(div)''), 1.32 + with the exception of namespace selectors-- 1.33 + a <a>featureless</a> element is treated as having <em>all</em> namespaces. 1.34 Thus, only <a>pseudo-classes</a> or <a>pseudo-elements</a> can be used to select them. 1.35 Individual <a>featureless</a> elements may define additional restrictions on what kinds of selectors can match them. 1.36 1.37 @@ -687,6 +687,25 @@ 1.38 and can't be matched by <em>any</em> <a>pseudo-class</a> except for '':host'' and '':host-context()''.) 1.39 </div> 1.40 1.41 + <details class='why'> 1.42 + <summary>Why do featureless elements match all namespaces?</summary> 1.43 + 1.44 + In a previous version of Selectors, 1.45 + all <a>compound selectors</a> contained a <a>type selector</a>; 1.46 + if you didn't supply one explicitly, 1.47 + a <a>universal selector</a> was implied. 1.48 + Default namespaces [[CSS3NAMESPACE]] affected the implied universal selector, 1.49 + so that selectors like '':hover'' actually meant ''defaultNS|*:hover''. 1.50 + 1.51 + The universal selector is no longer implied, 1.52 + but default namespaces still exist, 1.53 + and have to apply to all compound selectors. 1.54 + The behavior of <a>featureless</a> elements, 1.55 + like the <a>host element</a> in a shadow tree, 1.56 + thus needs to accommodate that and work appropriately. 1.57 + In this case, "appropriately" means "ignoring the default namespace". 1.58 + </details> 1.59 + 1.60 When matching a selector against a document which is in <a>quirks mode</a>, 1.61 class and ID selectors must be matched <a title="ASCII case-insensitive">ASCII case-insensitively</a> 1.62 against the classes and ID of the elements in the document. 1.63 @@ -724,9 +743,9 @@ 1.64 1.65 If this "type" can be separated into a "basic" name 1.66 and a "namespace" that groups names into higher-level groups, 1.67 - that should be reflected in the "namespace" and "local name" divisions of the "type" <a>feature</a>. 1.68 - Otherwise, the "namespace" part should be the empty string, 1.69 - and the entire name should be in the "local name" part. 1.70 + the latter should be reflected as the "namespace" <a>feature</a>. 1.71 + Otherwise, the element shouldn't have a "namespace" <a>feature</a>, 1.72 + and the entire name should be reflected as the "type" <a>feature</a>. 1.73 1.74 <dt>id 1.75 <dd> 1.76 @@ -1203,8 +1222,11 @@ 1.77 Pseudo-elements cannot be represented by the matches-any pseudo-class; 1.78 they are not valid within '':matches()''. 1.79 1.80 - Default namespace declarations do not affect any “implied” universal selectors 1.81 - within a '':matches()'' pseudo-class. 1.82 + Within a '':matches()'' pseudo-class, 1.83 + default namespace declarations only have an effect on compound selectors 1.84 + that contain a <a>type selector</a>. 1.85 + 1.86 + Issue: Do we want to extend this protection from default namespaces to other things? 1.87 1.88 <div class="example"> 1.89 For example, the following selector matches any element that is being 1.90 @@ -1301,51 +1323,62 @@ 1.91 Type (tag name) selector</h3> 1.92 1.93 A <dfn export>type selector</dfn> is the name of a document language element type 1.94 - written using the syntax of <a href="http://www.w3.org/TR/css3-namespace/#css-qnames">CSS qualified names</a> [[!CSS3NAMESPACE]]. 1.95 + written as either an <a>identifier</a> 1.96 + or, if interacting with namespaces, 1.97 + a <a>CSS qualified name</a> 1.98 + (see [[#type-nmsp]]) 1.99 + [[!CSS3NAMESPACE]]. 1.100 + 1.101 A type selector represents an instance of the element type in the document tree. 1.102 1.103 <div class="example"> 1.104 - Example: 1.105 - The following selector represents an <a element>h1</a> element in the document tree: 1.106 - 1.107 - <pre>h1 </pre> 1.108 + For example, the selector ''h1'' represents an <a element>h1</a> element in the document. 1.109 </div> 1.110 1.111 -<h4 id="typenmsp"> 1.112 -Type selectors and namespaces</h4> 1.113 - 1.114 - Type selectors allow an optional namespace component: a namespace 1.115 - prefix that has been previously <a href="#nsdecl">declared</a> may be 1.116 - prepended to the element name separated by the namespace separator 1.117 - "vertical bar" (U+007C, <code>|</code>). (See, e.g., [[XML-NAMES]] for the use of namespaces in 1.118 - XML.) 1.119 - 1.120 - The namespace component may be left empty (no prefix before the 1.121 - namespace separator) to indicate that the selector is only to 1.122 - represent elements with no namespace. 1.123 - 1.124 - An asterisk may be used for the namespace prefix, indicating that 1.125 - the selector represents elements in any namespace (including elements 1.126 - with no namespace). 1.127 - 1.128 - Element type selectors that have no namespace component (no 1.129 - namespace separator) represent elements without regard to the 1.130 - element's namespace (equivalent to "<code>*|</code>") unless a default 1.131 - namespace has been <a href="#nsdecl">declared</a> for namespaced selectors (e.g. in CSS, in 1.132 - the style sheet). If a default namespace has been declared, such 1.133 - selectors will represent only elements in the default namespace. 1.134 - 1.135 - A type selector containing a namespace prefix that has not been 1.136 - previously <a href="#nsdecl">declared</a> for namespaced selectors is 1.137 - an <a href="#conformance">invalid</a> selector. 1.138 - 1.139 - In a namespace-aware client, 1.140 - the name part of element type selectors 1.141 - (the part after the namespace separator, if it is present) 1.142 - will only match against the <a href="http://www.w3.org/TR/REC-xml-names/#NT-LocalPart">local part</a> 1.143 - of the element's <a href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">qualified name</a>. 1.144 - 1.145 - In summary: 1.146 +<h3 id="the-universal-selector"> 1.147 +Universal selector </h3> 1.148 + 1.149 + The <dfn export>universal selector</dfn> is a special <a>type selector</a>, 1.150 + written either as the asterisk character (<code>*</code> U+002A), 1.151 + or as a <a>CSS qualified name</a> 1.152 + with an asterisk as the local name (see [[#type-nmsp]]). 1.153 + It represents an element with any name. 1.154 + 1.155 + Like a <a>type selector</a>, 1.156 + the <a>universal selector</a> can be qualified by a namespace, 1.157 + and is affected by a default namespace as defined in [[#type-nmsp]]. 1.158 + 1.159 + Unless an element is <a>featureless</a>, 1.160 + the presence of a <a>universal selector</a> has no effect on whether the element matches the selector. 1.161 + (<a>Featureless</a> elements do not match any <a>feature</a> selector, 1.162 + including the <a>universal selector</a>.) 1.163 + 1.164 + <div class="example"> 1.165 + <ul> 1.166 + <li> 1.167 + <span class=css>*[hreflang|=en]</span> and <span class=css>[hreflang|=en]</span> are equivalent, 1.168 + <li>''*.warning'' and ''.warning'' are equivalent, 1.169 + <li>''*#myid'' and ''#myid'' are equivalent. 1.170 + </ul> 1.171 + </div> 1.172 + 1.173 + The <a>universal selector</a> follows the same syntax rules as other <a>type selectors</a>: 1.174 + only one can appear per <a>compound selector</a>, 1.175 + and it must be the first <a>simple selector</a> in the <a>compound selector</a>. 1.176 + 1.177 + Note: In some cases, adding a <a>universal selector</a> can make a selector easier to read, 1.178 + even though it has no effect on the matching behavior. 1.179 + For example, ''div :first-child'' and ''div:first-child'' are somewhat difficult to tell apart at a quick glance, 1.180 + but writing the former as ''div *:first-child'' makes the difference obvious. 1.181 + 1.182 +<h3 id='type-nmsp'> 1.183 +Namespaces in Selectors</h3> 1.184 + 1.185 + <a>Type selectors</a> allow an optional namespace component: 1.186 + a namespace prefix that has been previously <a href="#nsdecl">declared</a> 1.187 + may be prepended to the element name separated by the namespace separator “vertical bar” (<code>|</code> U+007C). 1.188 + (See, e.g., [[XML-NAMES]] for the use of namespaces in XML.) 1.189 + It has the following meaning in each form: 1.190 1.191 <dl> 1.192 <dt><code>ns|E</code> 1.193 @@ -1398,71 +1431,24 @@ 1.194 namespace has been defined. 1.195 </div> 1.196 1.197 -<h3 id="the-universal-selector"> 1.198 -Universal selector </h3> 1.199 - 1.200 - The <dfn export>universal selector</dfn>, written as a 1.201 - <a href="http://www.w3.org/TR/css3-namespace/#css-qnames">CSS qualified 1.202 - name</a> [[!CSS3NAMESPACE]] with an asterisk (<code>*</code> 1.203 - U+002A) as the local name, represents the qualified name of any element 1.204 - type. It represents any single element in the document tree in any 1.205 - namespace (including those without a namespace) if no default 1.206 - namespace has been specified for selectors. If a default namespace has 1.207 - been specified, see <a href="#univnmsp">Universal selector and 1.208 - Namespaces</a> below. 1.209 - 1.210 - If a universal selector represented by ''*'' 1.211 - (i.e. without a namespace prefix) 1.212 - is not the only component of a <a>compound selector</a> 1.213 - or is immediately followed by a <a>pseudo-element</a>, 1.214 - then the ''*'' may be omitted 1.215 - and the universal selector's presence implied. 1.216 - 1.217 - <div class="example"> 1.218 - <ul> 1.219 - <li>''*[hreflang|=en]'' and ''[hreflang|=en]'' are equivalent, 1.220 - <li>''*.warning'' and ''.warning'' are equivalent, 1.221 - <li>''*#myid'' and ''#myid'' are equivalent. 1.222 - </ul> 1.223 + If a <a>default namespace</a> is declared, 1.224 + <a>compound selectors</a> without <a>type selectors</a> in them 1.225 + still only match elements in that default namespace. 1.226 + 1.227 + <div class='example'> 1.228 + For example, 1.229 + in the following stylesheet: 1.230 + 1.231 + <pre> 1.232 + @namespace url("http://example.com/foo"); 1.233 + 1.234 + .special { ... } 1.235 + </pre> 1.236 + 1.237 + The ''.special'' selector only matches elements in the "http://example.com/foo" namespace, 1.238 + even though no reference to the type name (which is paired with the namespace in the DOM) appeared. 1.239 </div> 1.240 1.241 - Note: It is recommended that the ''*'' not be omitted, 1.242 - because it decreases the potential confusion between, 1.243 - for example, ''div :first-child'' 1.244 - and ''div:first-child''. 1.245 - Here, ''div *:first-child'' is more readable. 1.246 - 1.247 -<h4 id="univnmsp"> 1.248 -Universal selector and namespaces</h4> 1.249 - 1.250 - The universal selector allows an optional namespace component. It 1.251 - is used as follows: 1.252 - 1.253 - <dl> 1.254 - <dt>''ns|*'' 1.255 - <dd> 1.256 - all elements in namespace ns 1.257 - 1.258 - <dt>''*|*'' 1.259 - <dd> 1.260 - all elements 1.261 - 1.262 - <dt>''|*'' 1.263 - <dd> 1.264 - all elements without a namespace 1.265 - 1.266 - <dt>''*'' 1.267 - <dd> 1.268 - if no default namespace has been specified, 1.269 - this is equivalent to *|*. 1.270 - Otherwise it is equivalent to ns|* 1.271 - where ns is the default namespace. 1.272 - </dl> 1.273 - 1.274 - A universal selector containing a namespace prefix 1.275 - that has not been previously <a href="#nsdecl">declared</a> 1.276 - is an <a>invalid selector</a>. 1.277 - 1.278 1.279 <h2 id="attribute-selectors"> 1.280 Attribute selectors</h2>
2.1 --- a/selectors/Overview.html Mon Aug 11 14:30:47 2014 -0700 2.2 +++ b/selectors/Overview.html Mon Aug 11 19:06:45 2014 -0700 2.3 @@ -59,7 +59,7 @@ 2.4 </p> 2.5 <h1 class="p-name no-ref" id=title>Selectors Level 4</h1> 2.6 <h2 class="no-num no-toc no-ref heading settled heading" id=subtitle><span class=content>Editor’s Draft, 2.7 - <span class=dt-updated><span class=value-title title=20140808>8 August 2014</span></span></span></h2> 2.8 + <span class=dt-updated><span class=value-title title=20140812>12 August 2014</span></span></span></h2> 2.9 <div data-fill-with=spec-metadata><dl> 2.10 <dt>This version: 2.11 <dd><a class=u-url href=http://dev.w3.org/csswg/selectors>http://dev.w3.org/csswg/selectors</a> 2.12 @@ -166,11 +166,8 @@ 2.13 <li><a href=#elemental-selectors><span class=secno>5</span> Elemental selectors</a> 2.14 <ul class=toc> 2.15 <li><a href=#type-selectors><span class=secno>5.1</span> Type (tag name) selector</a> 2.16 - <ul class=toc> 2.17 - <li><a href=#typenmsp><span class=secno>5.1.1</span> Type selectors and namespaces</a></ul> 2.18 <li><a href=#the-universal-selector><span class=secno>5.2</span> Universal selector </a> 2.19 - <ul class=toc> 2.20 - <li><a href=#univnmsp><span class=secno>5.2.1</span> Universal selector and namespaces</a></ul></ul> 2.21 + <li><a href=#type-nmsp><span class=secno>5.3</span> Namespaces in Selectors</a></ul> 2.22 <li><a href=#attribute-selectors><span class=secno>6</span> Attribute selectors</a> 2.23 <ul class=toc> 2.24 <li><a href=#attribute-representation><span class=secno>6.1</span> Attribute presence and value selectors</a> 2.25 @@ -903,11 +900,11 @@ 2.26 but not only elements with <a data-link-type=dfn href=http://dev.w3.org/csswg/css-scoping-1/#shadow-tree title="shadow trees">shadow trees</a> have <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-scoping-1/#selectordef-shadow title=::shadow>::shadow</a> pseudo-elements.</p> 2.27 </div> 2.28 2.29 -<p>Four aspects of a DOM element are especially relevant for selectors:</p> 2.30 +<p>Five aspects of a DOM element are especially relevant for selectors:</p> 2.31 2.32 <ul> 2.33 - <li>The element’s type (also known as tagname), 2.34 - which is a pair of strings: a namespace and a local name. 2.35 + <li>The element’s type (also known as tagname), which is a string. 2.36 + <li>The element’s namespace, which is a string. 2.37 <li>An ID, which is a string. 2.38 <li>Classes, which are strings. 2.39 <li>Attributes, which are pairs of strings consisting of an attribute name and an attribute value. 2.40 @@ -919,12 +916,11 @@ 2.41 are called <dfn data-dfn-type=dfn data-export="" id=feature-selector title="feature selector">feature selectors<a class=self-link href=#feature-selector></a></dfn>.</p> 2.42 2.43 <p>While elements may lack any of the individual <a data-link-type=dfn href=#feature title=features>features</a>, 2.44 - some elements are <dfn data-dfn-type=dfn data-export="" id=featureless>featureless<a class=self-link href=#featureless></a></dfn>, 2.45 - which means that not only do they lack any <a data-link-type=dfn href=#feature title=features>features</a> 2.46 - (and thus will never match a <a data-link-type=dfn href=#feature-selector title="feature selector">feature selector</a>), 2.47 - but any selectors that reference <a data-link-type=dfn href=#feature title=features>features</a>, 2.48 - such as <span class=css data-link-type=maybe title=:not(div)>:not(div)</span>, 2.49 - also never match them. 2.50 + some elements are <dfn data-dfn-type=dfn data-export="" id=featureless>featureless<a class=self-link href=#featureless></a></dfn>. 2.51 + A <a data-link-type=dfn href=#featureless title=featureless>featureless</a> element does not match any <a data-link-type=dfn href=#feature-selector title="feature selector">feature selector</a>, 2.52 + or any selector that resolves based on <a data-link-type=dfn href=#feature title=features>features</a> 2.53 + (such as <span class=css data-link-type=maybe title=:not(div)>:not(div)</span>), 2.54 + with the exception of namespace selectors—<wbr>a <a data-link-type=dfn href=#featureless title=featureless>featureless</a> element is treated as having <em>all</em> namespaces. 2.55 Thus, only <a data-link-type=dfn href=#pseudo-class title=pseudo-classes>pseudo-classes</a> or <a data-link-type=dfn href=#pseudo-element title=pseudo-elements>pseudo-elements</a> can be used to select them. 2.56 Individual <a data-link-type=dfn href=#featureless title=featureless>featureless</a> elements may define additional restrictions on what kinds of selectors can match them.</p> 2.57 2.58 @@ -933,6 +929,25 @@ 2.59 and can’t be matched by <em>any</em> <a data-link-type=dfn href=#pseudo-class title=pseudo-class>pseudo-class</a> except for <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-scoping-1/#selectordef-host0 title=:host>:host</a> and <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-scoping-1/#selectordef-host-context title=:host-context()>:host-context()</a>.) 2.60 </div> 2.61 2.62 + <details class=why> 2.63 + <summary>Why do featureless elements match all namespaces?</summary> 2.64 + 2.65 +<p>In a previous version of Selectors, 2.66 + all <a data-link-type=dfn href=#compound title="compound selectors">compound selectors</a> contained a <a data-link-type=dfn href=#type-selector title="type selector">type selector</a>; 2.67 + if you didn’t supply one explicitly, 2.68 + a <a data-link-type=dfn href=#universal-selector title="universal selector">universal selector</a> was implied. 2.69 + Default namespaces <a data-biblio-type=informative data-link-type=biblio href=#biblio-css3namespace title=biblio-CSS3NAMESPACE>[CSS3NAMESPACE]</a> affected the implied universal selector, 2.70 + so that selectors like <a class=css data-link-type=maybe href=#hover-pseudo title=:hover>:hover</a> actually meant <span class=css data-link-type=maybe title=defaultNS|*:hover>defaultNS|*:hover</span>.</p> 2.71 + 2.72 +<p>The universal selector is no longer implied, 2.73 + but default namespaces still exist, 2.74 + and have to apply to all compound selectors. 2.75 + The behavior of <a data-link-type=dfn href=#featureless title=featureless>featureless</a> elements, 2.76 + like the <a data-link-type=dfn href=http://dev.w3.org/csswg/css-scoping-1/#host-element0 title="host element">host element</a> in a shadow tree, 2.77 + thus needs to accommodate that and work appropriately. 2.78 + In this case, "appropriately" means "ignoring the default namespace".</p> 2.79 + </details> 2.80 + 2.81 <p>When matching a selector against a document which is in <a data-link-type=dfn title="quirks mode">quirks mode</a>, 2.82 class and ID selectors must be matched <a data-link-type=dfn href=http://dev.w3.org/csswg/css-syntax-3/#ascii-case-insensitive title="ASCII case-insensitive">ASCII case-insensitively</a> 2.83 against the classes and ID of the elements in the document.</p> 2.84 @@ -968,9 +983,9 @@ 2.85 2.86 <p>If this "type" can be separated into a "basic" name 2.87 and a "namespace" that groups names into higher-level groups, 2.88 - that should be reflected in the "namespace" and "local name" divisions of the "type" <a data-link-type=dfn href=#feature title=feature>feature</a>. 2.89 - Otherwise, the "namespace" part should be the empty string, 2.90 - and the entire name should be in the "local name" part.</p> 2.91 + the latter should be reflected as the "namespace" <a data-link-type=dfn href=#feature title=feature>feature</a>. 2.92 + Otherwise, the element shouldn’t have a "namespace" <a data-link-type=dfn href=#feature title=feature>feature</a>, 2.93 + and the entire name should be reflected as the "type" <a data-link-type=dfn href=#feature title=feature>feature</a>.</p> 2.94 2.95 <dt>id 2.96 <dd> 2.97 @@ -1445,8 +1460,11 @@ 2.98 <p>Pseudo-elements cannot be represented by the matches-any pseudo-class; 2.99 they are not valid within <a class=css data-link-type=maybe href=#matches-pseudo title=:matches()>:matches()</a>.</p> 2.100 2.101 -<p>Default namespace declarations do not affect any “implied” universal selectors 2.102 - within a <a class=css data-link-type=maybe href=#matches-pseudo title=:matches()>:matches()</a> pseudo-class.</p> 2.103 +<p>Within a <a class=css data-link-type=maybe href=#matches-pseudo title=:matches()>:matches()</a> pseudo-class, 2.104 + default namespace declarations only have an effect on compound selectors 2.105 + that contain a <a data-link-type=dfn href=#type-selector title="type selector">type selector</a>.</p> 2.106 + 2.107 +<p class=issue id=issue-fdaebe5f><a class=self-link href=#issue-fdaebe5f></a>Do we want to extend this protection from default namespaces to other things?</p> 2.108 2.109 <div class=example> 2.110 For example, the following selector matches any element that is being 2.111 @@ -1543,51 +1561,65 @@ 2.112 Type (tag name) selector</span><a class=self-link href=#type-selectors></a></h3> 2.113 2.114 <p>A <dfn data-dfn-type=dfn data-export="" id=type-selector>type selector<a class=self-link href=#type-selector></a></dfn> is the name of a document language element type 2.115 - written using the syntax of <a href=http://www.w3.org/TR/css3-namespace/#css-qnames>CSS qualified names</a> <a data-biblio-type=normative data-link-type=biblio href=#biblio-css3namespace title=biblio-CSS3NAMESPACE>[CSS3NAMESPACE]</a>. 2.116 - A type selector represents an instance of the element type in the document tree.</p> 2.117 + written as either an <a data-link-type=dfn href=http://dev.w3.org/csswg/css-syntax-3/#identifier title=identifier>identifier</a> 2.118 + or, if interacting with namespaces, 2.119 + a <a data-link-type=dfn href=http://dev.w3.org/csswg/css-namespaces-1/#css-qualified-name title="CSS qualified name">CSS qualified name</a> 2.120 + (see <a data-section="" href=#type-nmsp>§5.3 2.121 +Namespaces in Selectors</a>) 2.122 + <a data-biblio-type=normative data-link-type=biblio href=#biblio-css3namespace title=biblio-CSS3NAMESPACE>[CSS3NAMESPACE]</a>.</p> 2.123 + 2.124 +<p>A type selector represents an instance of the element type in the document tree.</p> 2.125 2.126 <div class=example> 2.127 - Example: 2.128 - The following selector represents an <a data-link-type=element title=h1>h1</a> element in the document tree: 2.129 - 2.130 -<pre>h1 </pre> 2.131 + For example, the selector <span class=css data-link-type=maybe title=h1>h1</span> represents an <a data-link-type=element title=h1>h1</a> element in the document. 2.132 </div> 2.133 2.134 -<h4 class="heading settled heading" data-level=5.1.1 id=typenmsp><span class=secno>5.1.1 </span><span class=content> 2.135 -Type selectors and namespaces</span><a class=self-link href=#typenmsp></a></h4> 2.136 - 2.137 -<p>Type selectors allow an optional namespace component: a namespace 2.138 - prefix that has been previously <a href=#nsdecl>declared</a> may be 2.139 - prepended to the element name separated by the namespace separator 2.140 - "vertical bar" (U+007C, <code>|</code>). (See, e.g., <a data-biblio-type=informative data-link-type=biblio href=#biblio-xml-names title=biblio-XML-NAMES>[XML-NAMES]</a> for the use of namespaces in 2.141 - XML.)</p> 2.142 - 2.143 -<p>The namespace component may be left empty (no prefix before the 2.144 - namespace separator) to indicate that the selector is only to 2.145 - represent elements with no namespace.</p> 2.146 - 2.147 -<p>An asterisk may be used for the namespace prefix, indicating that 2.148 - the selector represents elements in any namespace (including elements 2.149 - with no namespace).</p> 2.150 - 2.151 -<p>Element type selectors that have no namespace component (no 2.152 - namespace separator) represent elements without regard to the 2.153 - element’s namespace (equivalent to "<code>*|</code>") unless a default 2.154 - namespace has been <a href=#nsdecl>declared</a> for namespaced selectors (e.g. in CSS, in 2.155 - the style sheet). If a default namespace has been declared, such 2.156 - selectors will represent only elements in the default namespace.</p> 2.157 - 2.158 -<p>A type selector containing a namespace prefix that has not been 2.159 - previously <a href=#nsdecl>declared</a> for namespaced selectors is 2.160 - an <a href=#conformance>invalid</a> selector.</p> 2.161 - 2.162 -<p>In a namespace-aware client, 2.163 - the name part of element type selectors 2.164 - (the part after the namespace separator, if it is present) 2.165 - will only match against the <a href=http://www.w3.org/TR/REC-xml-names/#NT-LocalPart>local part</a> 2.166 - of the element’s <a href=http://www.w3.org/TR/REC-xml-names/#ns-qualnames>qualified name</a>.</p> 2.167 - 2.168 -<p>In summary:</p> 2.169 +<h3 class="heading settled heading" data-level=5.2 id=the-universal-selector><span class=secno>5.2 </span><span class=content> 2.170 +Universal selector </span><a class=self-link href=#the-universal-selector></a></h3> 2.171 + 2.172 +<p>The <dfn data-dfn-type=dfn data-export="" id=universal-selector>universal selector<a class=self-link href=#universal-selector></a></dfn> is a special <a data-link-type=dfn href=#type-selector title="type selector">type selector</a>, 2.173 + written either as the asterisk character (<code>*</code> U+002A), 2.174 + or as a <a data-link-type=dfn href=http://dev.w3.org/csswg/css-namespaces-1/#css-qualified-name title="CSS qualified name">CSS qualified name</a> 2.175 + with an asterisk as the local name (see <a data-section="" href=#type-nmsp>§5.3 2.176 +Namespaces in Selectors</a>). 2.177 + It represents an element with any name.</p> 2.178 + 2.179 +<p>Like a <a data-link-type=dfn href=#type-selector title="type selector">type selector</a>, 2.180 + the <a data-link-type=dfn href=#universal-selector title="universal selector">universal selector</a> can be qualified by a namespace, 2.181 + and is affected by a default namespace as defined in <a data-section="" href=#type-nmsp>§5.3 2.182 +Namespaces in Selectors</a>.</p> 2.183 + 2.184 +<p>Unless an element is <a data-link-type=dfn href=#featureless title=featureless>featureless</a>, 2.185 + the presence of a <a data-link-type=dfn href=#universal-selector title="universal selector">universal selector</a> has no effect on whether the element matches the selector. 2.186 + (<a data-link-type=dfn href=#featureless title=Featureless>Featureless</a> elements do not match any <a data-link-type=dfn href=#feature title=feature>feature</a> selector, 2.187 + including the <a data-link-type=dfn href=#universal-selector title="universal selector">universal selector</a>.)</p> 2.188 + 2.189 + <div class=example> 2.190 + <ul> 2.191 + <li> 2.192 + <span class=css>*[hreflang|=en]</span> and <span class=css>[hreflang|=en]</span> are equivalent, 2.193 + <li><span class=css data-link-type=maybe title=*.warning>*.warning</span> and <span class=css data-link-type=maybe title=.warning>.warning</span> are equivalent, 2.194 + <li><span class=css data-link-type=maybe title=*#myid>*#myid</span> and <span class=css data-link-type=maybe title=#myid>#myid</span> are equivalent. 2.195 + </ul> 2.196 + </div> 2.197 + 2.198 +<p>The <a data-link-type=dfn href=#universal-selector title="universal selector">universal selector</a> follows the same syntax rules as other <a data-link-type=dfn href=#type-selector title="type selectors">type selectors</a>: 2.199 + only one can appear per <a data-link-type=dfn href=#compound title="compound selector">compound selector</a>, 2.200 + and it must be the first <a data-link-type=dfn href=#simple title="simple selector">simple selector</a> in the <a data-link-type=dfn href=#compound title="compound selector">compound selector</a>.</p> 2.201 + 2.202 +<p class=note>Note: In some cases, adding a <a data-link-type=dfn href=#universal-selector title="universal selector">universal selector</a> can make a selector easier to read, 2.203 + even though it has no effect on the matching behavior. 2.204 + For example, <span class=css data-link-type=maybe title="div :first-child">div :first-child</span> and <span class=css data-link-type=maybe title=div:first-child>div:first-child</span> are somewhat difficult to tell apart at a quick glance, 2.205 + but writing the former as <span class=css data-link-type=maybe title="div *:first-child">div *:first-child</span> makes the difference obvious.</p> 2.206 + 2.207 +<h3 class="heading settled heading" data-level=5.3 id=type-nmsp><span class=secno>5.3 </span><span class=content> 2.208 +Namespaces in Selectors</span><a class=self-link href=#type-nmsp></a></h3> 2.209 + 2.210 +<p><a data-link-type=dfn href=#type-selector title="Type selectors">Type selectors</a> allow an optional namespace component: 2.211 + a namespace prefix that has been previously <a href=#nsdecl>declared</a> 2.212 + may be prepended to the element name separated by the namespace separator “vertical bar” (<code>|</code> U+007C). 2.213 + (See, e.g., <a data-biblio-type=informative data-link-type=biblio href=#biblio-xml-names title=biblio-XML-NAMES>[XML-NAMES]</a> for the use of namespaces in XML.) 2.214 + It has the following meaning in each form:</p> 2.215 2.216 <dl> 2.217 <dt><code>ns|E</code> 2.218 @@ -1639,71 +1671,22 @@ 2.219 namespace has been defined.</p> 2.220 </div> 2.221 2.222 -<h3 class="heading settled heading" data-level=5.2 id=the-universal-selector><span class=secno>5.2 </span><span class=content> 2.223 -Universal selector </span><a class=self-link href=#the-universal-selector></a></h3> 2.224 - 2.225 -<p>The <dfn data-dfn-type=dfn data-export="" id=universal-selector>universal selector<a class=self-link href=#universal-selector></a></dfn>, written as a 2.226 - <a href=http://www.w3.org/TR/css3-namespace/#css-qnames>CSS qualified 2.227 - name</a> <a data-biblio-type=normative data-link-type=biblio href=#biblio-css3namespace title=biblio-CSS3NAMESPACE>[CSS3NAMESPACE]</a> with an asterisk (<code>*</code> 2.228 - U+002A) as the local name, represents the qualified name of any element 2.229 - type. It represents any single element in the document tree in any 2.230 - namespace (including those without a namespace) if no default 2.231 - namespace has been specified for selectors. If a default namespace has 2.232 - been specified, see <a href=#univnmsp>Universal selector and 2.233 - Namespaces</a> below.</p> 2.234 - 2.235 -<p>If a universal selector represented by <span class=css data-link-type=maybe title=*>*</span> 2.236 - (i.e. without a namespace prefix) 2.237 - is not the only component of a <a data-link-type=dfn href=#compound title="compound selector">compound selector</a> 2.238 - or is immediately followed by a <a data-link-type=dfn href=#pseudo-element title=pseudo-element>pseudo-element</a>, 2.239 - then the <span class=css data-link-type=maybe title=*>*</span> may be omitted 2.240 - and the universal selector’s presence implied.</p> 2.241 +<p>If a <a data-link-type=dfn href=http://dev.w3.org/csswg/css-namespaces-1/#default-namespace title="default namespace">default namespace</a> is declared, 2.242 + <a data-link-type=dfn href=#compound title="compound selectors">compound selectors</a> without <a data-link-type=dfn href=#type-selector title="type selectors">type selectors</a> in them 2.243 + still only match elements in that default namespace.</p> 2.244 2.245 <div class=example> 2.246 - <ul> 2.247 - <li>''*[hreflang|=en]<span class=css data-link-type=maybe title=" and "> and </span>[hreflang|=en]'' are equivalent, 2.248 - <li><span class=css data-link-type=maybe title=*.warning>*.warning</span> and <span class=css data-link-type=maybe title=.warning>.warning</span> are equivalent, 2.249 - <li><span class=css data-link-type=maybe title=*#myid>*#myid</span> and <span class=css data-link-type=maybe title=#myid>#myid</span> are equivalent. 2.250 - </ul> 2.251 + For example, 2.252 + in the following stylesheet: 2.253 + 2.254 + <pre>@namespace url("http://example.com/foo"); 2.255 +.special { ... } 2.256 +</pre> 2.257 + 2.258 +<p>The <span class=css data-link-type=maybe title=.special>.special</span> selector only matches elements in the "http://example.com/foo" namespace, 2.259 + even though no reference to the type name (which is paired with the namespace in the DOM) appeared.</p> 2.260 </div> 2.261 2.262 -<p class=note>Note: It is recommended that the <span class=css data-link-type=maybe title=*>*</span> not be omitted, 2.263 - because it decreases the potential confusion between, 2.264 - for example, <span class=css data-link-type=maybe title="div :first-child">div :first-child</span> 2.265 - and <span class=css data-link-type=maybe title=div:first-child>div:first-child</span>. 2.266 - Here, <span class=css data-link-type=maybe title="div *:first-child">div *:first-child</span> is more readable.</p> 2.267 - 2.268 -<h4 class="heading settled heading" data-level=5.2.1 id=univnmsp><span class=secno>5.2.1 </span><span class=content> 2.269 -Universal selector and namespaces</span><a class=self-link href=#univnmsp></a></h4> 2.270 - 2.271 -<p>The universal selector allows an optional namespace component. It 2.272 - is used as follows:</p> 2.273 - 2.274 - <dl> 2.275 - <dt><span class=css data-link-type=maybe title=ns|*>ns|*</span> 2.276 - <dd> 2.277 - all elements in namespace ns 2.278 - 2.279 - <dt><span class=css data-link-type=maybe title=*|*>*|*</span> 2.280 - <dd> 2.281 - all elements 2.282 - 2.283 - <dt><span class=css data-link-type=maybe title=|*>|*</span> 2.284 - <dd> 2.285 - all elements without a namespace 2.286 - 2.287 - <dt><span class=css data-link-type=maybe title=*>*</span> 2.288 - <dd> 2.289 - if no default namespace has been specified, 2.290 - this is equivalent to *|*. 2.291 - Otherwise it is equivalent to ns|* 2.292 - where ns is the default namespace. 2.293 - </dl> 2.294 - 2.295 -<p>A universal selector containing a namespace prefix 2.296 - that has not been previously <a href=#nsdecl>declared</a> 2.297 - is an <a data-link-type=dfn href=#invalid-selector title="invalid selector">invalid selector</a>.</p> 2.298 - 2.299 2.300 <h2 class="heading settled heading" data-level=6 id=attribute-selectors><span class=secno>6 </span><span class=content> 2.301 Attribute selectors</span><a class=self-link href=#attribute-selectors></a></h2> 2.302 @@ -3927,7 +3910,7 @@ 2.303 or should we stick with defaulting to *not* allowing, 2.304 and requiring individual pseudo-classes to specify that they work on pseudo-elements? 2.305 2.306 - <a href=#issue-73b391d2> ↵ </a></div><div class=issue>Explain this better.<a href=#issue-2422b936> ↵ </a></div><div class=issue>Add comma-separated syntax for 2.307 + <a href=#issue-73b391d2> ↵ </a></div><div class=issue>Explain this better.<a href=#issue-2422b936> ↵ </a></div><div class=issue>Do we want to extend this protection from default namespaces to other things?<a href=#issue-fdaebe5f> ↵ </a></div><div class=issue>Add comma-separated syntax for 2.308 <a href=http://lists.w3.org/Archives/Public/www-style/2011Mar/0215.html>multiple-value matching</a>? 2.309 e.g. [rel ~= next, prev, up, first, last] 2.310