OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script src="../htmlrunner.js"></script> | 3 <script type="application/dart" src="dom-modify-htmlfast.dart"></script> |
4 <script> | 4 <script src="http://dart.googlecode.com/svn/branches/bleeding_edge/dart/client/d
art.js"></script> |
5 window.onload = function(){ | |
6 startTest("dom-query"); | |
7 | |
8 // Try to force real results | |
9 var ret, tmp; | |
10 var num = 40; | |
11 var html = document.body.innerHTML; | |
12 | |
13 » prep(function(){ | |
14 » » html = html.replace(/id="test(\w).*?"/g, 'id="test$1' + num + '"
'); | |
15 » » html = html.replace(/name="test.*?"/g, 'name="test' + num + '"')
; | |
16 » » html = html.replace(/class="foo.*?"/g, 'class="foo test' + num +
' bar"'); | |
17 » » var div = document.createElement("div"); | |
18 » » div.innerHTML = html; | |
19 » » document.body.appendChild( div ); | |
20 » }); | |
21 | |
22 » test( "getElementById", function(){ | |
23 » » for ( var i = 0; i < num * 30; i++ ) { | |
24 » » » ret = document.getElementById("testA" + num).nodeType; | |
25 » » » ret = document.getElementById("testB" + num).nodeType; | |
26 » » » ret = document.getElementById("testC" + num).nodeType; | |
27 » » » ret = document.getElementById("testD" + num).nodeType; | |
28 » » » ret = document.getElementById("testE" + num).nodeType; | |
29 » » » ret = document.getElementById("testF" + num).nodeType; | |
30 » » } | |
31 » }); | |
32 | |
33 » test( "getElementById (not in document)", function(){ | |
34 » » for ( var i = 0; i < num * 30; i++ ) { | |
35 » » » ret = document.getElementById("testA"); | |
36 » » » ret = document.getElementById("testB"); | |
37 » » » ret = document.getElementById("testC"); | |
38 » » » ret = document.getElementById("testD"); | |
39 » » » ret = document.getElementById("testE"); | |
40 » » » ret = document.getElementById("testF"); | |
41 » » } | |
42 » }); | |
43 | |
44 » test( "getElementsByTagName(div)", function(){ | |
45 » » for ( var i = 0; i < num; i++ ) { | |
46 » » » var elems = document.getElementsByTagName("div"); | |
47 » » » ret = elems[elems.length-1].nodeType; | |
48 » » } | |
49 » }); | |
50 | |
51 » test( "getElementsByTagName(p)", function(){ | |
52 » » for ( var i = 0; i < num; i++ ) { | |
53 » » » var elems = document.getElementsByTagName("p"); | |
54 » » » ret = elems[elems.length-1].nodeType; | |
55 » » } | |
56 » }); | |
57 | |
58 » test( "getElementsByTagName(a)", function(){ | |
59 » » for ( var i = 0; i < num; i++ ) { | |
60 » » » var elems = document.getElementsByTagName("a"); | |
61 » » » ret = elems[elems.length-1].nodeType; | |
62 » » } | |
63 » }); | |
64 | |
65 » test( "getElementsByTagName(*)", function(){ | |
66 » » for ( var i = 0; i < num; i++ ) { | |
67 » » » var elems = document.getElementsByTagName("*"); | |
68 » » » ret = elems[elems.length-1].nodeType; | |
69 » » } | |
70 » }); | |
71 | |
72 » test( "getElementsByTagName (not in document)", function(){ | |
73 » » for ( var i = 0; i < num; i++ ) { | |
74 » » » var elems = document.getElementsByTagName("strong"); | |
75 » » » ret = elems.length == 0; | |
76 » » } | |
77 » }); | |
78 | |
79 » test( "getElementsByName", function(){ | |
80 » » for ( var i = 0; i < num * 20; i++ ) { | |
81 » » » var elems = document.getElementsByName("test" + num); | |
82 » » » ret = elems[elems.length-1].nodeType; | |
83 » » » var elems = document.getElementsByName("test" + num); | |
84 » » » ret = elems[elems.length-1].nodeType; | |
85 » » » var elems = document.getElementsByName("test" + num); | |
86 » » » ret = elems[elems.length-1].nodeType; | |
87 » » » var elems = document.getElementsByName("test" + num); | |
88 » » » ret = elems[elems.length-1].nodeType; | |
89 » » } | |
90 » }); | |
91 | |
92 » test( "getElementsByName (not in document)", function(){ | |
93 » » for ( var i = 0; i < num * 20; i++ ) { | |
94 » » » ret = document.getElementsByName("test").length == 0; | |
95 » » » ret = document.getElementsByName("test").length == 0; | |
96 » » » ret = document.getElementsByName("test").length == 0; | |
97 » » » ret = document.getElementsByName("test").length == 0; | |
98 » » » ret = document.getElementsByName("test").length == 0; | |
99 » » } | |
100 » }); | |
101 | |
102 endTest(); | |
103 }; | |
104 </script> | |
105 </head> | 5 </head> |
106 <body> | 6 <body> |
107 <div class="head"> | 7 <div class="head"> |
108 <p><a href="http://www.w3.org/"><img height=48 alt=W3C src="http://www.w3.org
/Icons/w3c_home" width=72></a> | 8 <p><a href="http://www.w3.org/"><img height=48 alt=W3C src="http://www.w3.org
/Icons/w3c_home" width=72></a> |
109 | 9 |
110 <h1 id="title">Selectors</h1> | 10 <h1 id="title">Selectors</h1> |
111 | 11 |
112 <h2>W3C Working Draft 15 December 2005</h2> | 12 <h2>W3C Working Draft 15 December 2005</h2> |
113 | 13 |
114 <dl> | 14 <dl> |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 obsoleted by other documents at any time. It is inappropriate to | 141 obsoleted by other documents at any time. It is inappropriate to |
242 cite a W3C Working Draft as other than "work in progress". | 142 cite a W3C Working Draft as other than "work in progress". |
243 | 143 |
244 <p>This document may be available in <a | 144 <p>This document may be available in <a |
245 href="http://www.w3.org/Style/css3-selectors-updates/translations">translation
</a>. | 145 href="http://www.w3.org/Style/css3-selectors-updates/translations">translation
</a>. |
246 The English version of this specification is the only normative | 146 The English version of this specification is the only normative |
247 version. | 147 version. |
248 | 148 |
249 <div class="subtoc"> | 149 <div class="subtoc"> |
250 | 150 |
251 <h2 id="testF10"><a name=contents>Table of contents</a></h2> | 151 <h2 id="test1"><a name=contents>Table of contents</a></h2> |
252 | 152 |
253 <ul class="toc"> | 153 <ul class="toc"> |
254 <li class="tocline2"><a href="#context">1. Introduction</a> | 154 <li class="tocline2"><a href="#context">1. Introduction</a> |
255 <ul> | 155 <ul> |
256 <li><a href="#dependencies">1.1. Dependencies</a> </li> | 156 <li><a href="#dependencies">1.1. Dependencies</a> </li> |
257 <li><a href="#terminology">1.2. Terminology</a> </li> | 157 <li><a href="#terminology">1.2. Terminology</a> </li> |
258 <li><a href="#changesFromCSS2">1.3. Changes from CSS2</a> </li> | 158 <li><a href="#changesFromCSS2">1.3. Changes from CSS2</a> </li> |
259 </ul> | 159 </ul> |
260 <li class="tocline2"><a href="#selectors">2. Selectors</a> | 160 <li class="tocline2"><a href="#selectors">2. Selectors</a> |
261 <li class="tocline2"><a href="#casesens">3. Case sensitivity</a> | 161 <li class="tocline2"><a href="#casesens">3. Case sensitivity</a> |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 <li class="tocline2"><a href="#downlevel">11. Namespaces and down-level clie
nts</a> | 232 <li class="tocline2"><a href="#downlevel">11. Namespaces and down-level clie
nts</a> |
333 <li class="tocline2"><a href="#profiling">12. Profiles</a> | 233 <li class="tocline2"><a href="#profiling">12. Profiles</a> |
334 <li><a href="#Conformance">13. Conformance and requirements</a> | 234 <li><a href="#Conformance">13. Conformance and requirements</a> |
335 <li><a href="#Tests">14. Tests</a> | 235 <li><a href="#Tests">14. Tests</a> |
336 <li><a href="#ACKS">15. Acknowledgements</a> | 236 <li><a href="#ACKS">15. Acknowledgements</a> |
337 <li class="tocline2"><a href="#references">16. References</a> | 237 <li class="tocline2"><a href="#references">16. References</a> |
338 </ul> | 238 </ul> |
339 | 239 |
340 </div> | 240 </div> |
341 | 241 |
342 <h2 id="testA10"><a name=context>1. Introduction</a></h2> | 242 <h2><a name=context>1. Introduction</a></h2> |
343 | 243 |
344 <h3><a name=dependencies></a>1.1. Dependencies</h3> | 244 <h3><a name=dependencies></a>1.1. Dependencies</h3> |
345 | 245 |
346 <p>Some features of this specification are specific to CSS, or have | 246 <p>Some features of this specification are specific to CSS, or have |
347 particular limitations or rules specific to CSS. In this | 247 particular limitations or rules specific to CSS. In this |
348 specification, these have been described in terms of CSS2.1. <a | 248 specification, these have been described in terms of CSS2.1. <a |
349 href="#refsCSS21">[CSS21]</a></p> | 249 href="#refsCSS21">[CSS21]</a></p> |
350 | 250 |
351 <h3><a name=terminology></a>1.2. Terminology</h3> | 251 <h3><a name=terminology></a>1.2. Terminology</h3> |
352 | 252 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 each specification</li> | 287 each specification</li> |
388 | 288 |
389 <li>Selectors are now a CSS3 Module and an independent | 289 <li>Selectors are now a CSS3 Module and an independent |
390 specification; other specifications can now refer to this document | 290 specification; other specifications can now refer to this document |
391 independently of CSS</li> | 291 independently of CSS</li> |
392 | 292 |
393 <li>the specification now has its own test suite</li> | 293 <li>the specification now has its own test suite</li> |
394 | 294 |
395 </ul> | 295 </ul> |
396 | 296 |
397 <h2 id="testB10"><a name=selectors></a>2. Selectors</h2> | 297 <h2><a name=selectors></a>2. Selectors</h2> |
398 | 298 |
399 <p><em>This section is non-normative, as it merely summarizes the | 299 <p><em>This section is non-normative, as it merely summarizes the |
400 following sections.</em></p> | 300 following sections.</em></p> |
401 | 301 |
402 <p>A Selector represents a structure. This structure can be used as a | 302 <p>A Selector represents a structure. This structure can be used as a |
403 condition (e.g. in a CSS rule) that determines which elements a | 303 condition (e.g. in a CSS rule) that determines which elements a |
404 selector matches in the document tree, or as a flat description of the | 304 selector matches in the document tree, or as a flat description of the |
405 HTML or XML fragment corresponding to that structure.</p> | 305 HTML or XML fragment corresponding to that structure.</p> |
406 | 306 |
407 <p>Selectors may range from simple element names to rich contextual | 307 <p>Selectors may range from simple element names to rich contextual |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 <td class="pattern">E ~ F</td> | 601 <td class="pattern">E ~ F</td> |
702 <td class="meaning">an F element preceded by an E element</td> | 602 <td class="meaning">an F element preceded by an E element</td> |
703 <td class="described"><a | 603 <td class="described"><a |
704 href="#general-sibling-combinators">General sibling combinator</a></td> | 604 href="#general-sibling-combinators">General sibling combinator</a></td> |
705 <td class="origin">3</td></tr></tbody></table> | 605 <td class="origin">3</td></tr></tbody></table> |
706 | 606 |
707 <p>The meaning of each selector is derived from the table above by | 607 <p>The meaning of each selector is derived from the table above by |
708 prepending "matches" to the contents of each cell in the "Meaning" | 608 prepending "matches" to the contents of each cell in the "Meaning" |
709 column.</p> | 609 column.</p> |
710 | 610 |
711 <h2 id="testC10"><a name=casesens>3. Case sensitivity</a></h2> | 611 <h2><a name=casesens>3. Case sensitivity</a></h2> |
712 | 612 |
713 <p>The case sensitivity of document language element names, attribute | 613 <p>The case sensitivity of document language element names, attribute |
714 names, and attribute values in selectors depends on the document | 614 names, and attribute values in selectors depends on the document |
715 language. For example, in HTML, element names are case-insensitive, | 615 language. For example, in HTML, element names are case-insensitive, |
716 but in XML, they are case-sensitive.</p> | 616 but in XML, they are case-sensitive.</p> |
717 | 617 |
718 <h2 id="testD10"><a name=selector-syntax>4. Selector syntax</a></h2> | 618 <h2><a name=selector-syntax>4. Selector syntax</a></h2> |
719 | 619 |
720 <p>A <dfn><a name=selector>selector</a></dfn> is a chain of one | 620 <p>A <dfn><a name=selector>selector</a></dfn> is a chain of one |
721 or more <a href="#sequence">sequences of simple selectors</a> | 621 or more <a href="#sequence">sequences of simple selectors</a> |
722 separated by <a href="#combinators">combinators</a>.</p> | 622 separated by <a href="#combinators">combinators</a>.</p> |
723 | 623 |
724 <p>A <dfn><a name=sequence>sequence of simple selectors</a></dfn> | 624 <p>A <dfn><a name=sequence>sequence of simple selectors</a></dfn> |
725 is a chain of <a href="#simple-selectors-dfn">simple selectors</a> | 625 is a chain of <a href="#simple-selectors-dfn">simple selectors</a> |
726 that are not separated by a <a href="#combinators">combinator</a>. It | 626 that are not separated by a <a href="#combinators">combinator</a>. It |
727 always begins with a <a href="#type-selectors">type selector</a> or a | 627 always begins with a <a href="#type-selectors">type selector</a> or a |
728 <a href="#universal-selector">universal selector</a>. No other type | 628 <a href="#universal-selector">universal selector</a>. No other type |
(...skipping 27 matching lines...) Expand all Loading... |
756 represents any element satisfying its requirements. Prepending another | 656 represents any element satisfying its requirements. Prepending another |
757 sequence of simple selectors and a combinator to a sequence imposes | 657 sequence of simple selectors and a combinator to a sequence imposes |
758 additional matching constraints, so the subjects of a selector are | 658 additional matching constraints, so the subjects of a selector are |
759 always a subset of the elements represented by the last sequence of | 659 always a subset of the elements represented by the last sequence of |
760 simple selectors.</p> | 660 simple selectors.</p> |
761 | 661 |
762 <p>An empty selector, containing no sequence of simple selectors and | 662 <p>An empty selector, containing no sequence of simple selectors and |
763 no pseudo-element, is an <a href="#Conformance">invalid | 663 no pseudo-element, is an <a href="#Conformance">invalid |
764 selector</a>.</p> | 664 selector</a>.</p> |
765 | 665 |
766 <h2 id="testE10"><a name=grouping>5. Groups of selectors</a></h2> | 666 <h2><a name=grouping>5. Groups of selectors</a></h2> |
767 | 667 |
768 <p>When several selectors share the same declarations, they may be | 668 <p>When several selectors share the same declarations, they may be |
769 grouped into a comma-separated list. (A comma is U+002C.)</p> | 669 grouped into a comma-separated list. (A comma is U+002C.)</p> |
770 | 670 |
771 <div class="example"> | 671 <div class="example"> |
772 <p>CSS examples:</p> | 672 <p>CSS examples:</p> |
773 <p>In this example, we condense three rules with identical | 673 <p>In this example, we condense three rules with identical |
774 declarations into one. Thus,</p> | 674 declarations into one. Thus,</p> |
775 <pre>h1 { font-family: sans-serif } | 675 <pre>h1 { font-family: sans-serif } |
776 h2 { font-family: sans-serif } | 676 h2 { font-family: sans-serif } |
(...skipping 2065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2842 | 2742 |
2843 <p>namespaces</td></tr> | 2743 <p>namespaces</td></tr> |
2844 <tr> | 2744 <tr> |
2845 <th>Excludes</th> | 2745 <th>Excludes</th> |
2846 <td>non-accepted pseudo-classes<br>pseudo-elements<br></td></tr> | 2746 <td>non-accepted pseudo-classes<br>pseudo-elements<br></td></tr> |
2847 <tr> | 2747 <tr> |
2848 <th>Extra constraints</th> | 2748 <th>Extra constraints</th> |
2849 <td>some selectors and combinators are not allowed in fragment | 2749 <td>some selectors and combinators are not allowed in fragment |
2850 descriptions on the right side of STTS declarations.</td></tr></tbody></ta
ble> | 2750 descriptions on the right side of STTS declarations.</td></tr></tbody></ta
ble> |
2851 <form> | 2751 <form> |
2852 <input type="text" name="test10"/> | 2752 <input type="text" name="test1"/> |
2853 <input type="text" name="foo"/> | 2753 <input type="text" name="foo"/> |
2854 <input type="text" name="foo"/> | 2754 <input type="text" name="foo"/> |
2855 <input type="text" name="foo"/> | 2755 <input type="text" name="foo"/> |
2856 <input type="text" name="foo"/> | 2756 <input type="text" name="foo"/> |
2857 <input type="text" name="foo"/> | 2757 <input type="text" name="foo"/> |
2858 <input type="text" name="foo"/> | 2758 <input type="text" name="foo"/> |
2859 <input type="text" name="foo"/> | 2759 <input type="text" name="foo"/> |
2860 <input type="text" name="foo"/> | 2760 <input type="text" name="foo"/> |
2861 <input type="text" name="foo"/> | 2761 <input type="text" name="foo"/> |
2862 <input type="text" name="foo"/> | 2762 <input type="text" name="foo"/> |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2902 which is not allowed at the current parsing point. | 2802 which is not allowed at the current parsing point. |
2903 | 2803 |
2904 <p>User agents must observe the rules for handling parsing errors: | 2804 <p>User agents must observe the rules for handling parsing errors: |
2905 <ul> | 2805 <ul> |
2906 <li>a simple selector containing an undeclared namespace prefix is invalid</li
> | 2806 <li>a simple selector containing an undeclared namespace prefix is invalid</li
> |
2907 <li>a selector containing an invalid simple selector, an invalid combinator | 2807 <li>a selector containing an invalid simple selector, an invalid combinator |
2908 or an invalid token is invalid. </li> | 2808 or an invalid token is invalid. </li> |
2909 <li>a group of selectors containing an invalid selector is invalid.</li> | 2809 <li>a group of selectors containing an invalid selector is invalid.</li> |
2910 </ul> | 2810 </ul> |
2911 | 2811 |
2912 <p class="foo test10 bar">Specifications reusing Selectors must define how to ha
ndle parsing | 2812 <p class="foo test1 bar">Specifications reusing Selectors must define how to han
dle parsing |
2913 errors. (In the case of CSS, the entire rule in which the selector is | 2813 errors. (In the case of CSS, the entire rule in which the selector is |
2914 used is dropped.)</p> | 2814 used is dropped.)</p> |
2915 | 2815 |
2916 <!-- Apparently all these references are out of date: | 2816 <!-- Apparently all these references are out of date: |
2917 <p>Implementations of this specification must behave as | 2817 <p>Implementations of this specification must behave as |
2918 "recipients of text data" as defined by <a href="#refsCWWW">[CWWW]</a> | 2818 "recipients of text data" as defined by <a href="#refsCWWW">[CWWW]</a> |
2919 when parsing selectors and attempting matches. (In particular, | 2819 when parsing selectors and attempting matches. (In particular, |
2920 implementations must assume the data is normalized and must not | 2820 implementations must assume the data is normalized and must not |
2921 normalize it.) Normative rules for matching strings are defined in | 2821 normalize it.) Normative rules for matching strings are defined in |
2922 <a href="#refsCWWW">[CWWW]</a> and <a | 2822 <a href="#refsCWWW">[CWWW]</a> and <a |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2991 <dt>[XMLNAMES] | 2891 <dt>[XMLNAMES] |
2992 <dd><a name="refsXMLNAMES"></a> Tim Bray, Dave Hollander, Andrew Layman, edito
rs; "<cite>Namespaces in XML</cite>", W3C Recommendation, 14 January 1999 | 2892 <dd><a name="refsXMLNAMES"></a> Tim Bray, Dave Hollander, Andrew Layman, edito
rs; "<cite>Namespaces in XML</cite>", W3C Recommendation, 14 January 1999 |
2993 <dd>(<a href="http://www.w3.org/TR/REC-xml-names/"><code>http://www.w3.org/TR/
REC-xml-names/</code></a>) | 2893 <dd>(<a href="http://www.w3.org/TR/REC-xml-names/"><code>http://www.w3.org/TR/
REC-xml-names/</code></a>) |
2994 | 2894 |
2995 <dt>[YACC] | 2895 <dt>[YACC] |
2996 <dd><a name="refsYACC"></a> S. C. Johnson; "<cite>YACC — Yet another com
piler compiler</cite>", Technical Report, Murray Hill, 1975 | 2896 <dd><a name="refsYACC"></a> S. C. Johnson; "<cite>YACC — Yet another com
piler compiler</cite>", Technical Report, Murray Hill, 1975 |
2997 | 2897 |
2998 </dl> | 2898 </dl> |
2999 </body> | 2899 </body> |
3000 </html> | 2900 </html> |
OLD | NEW |