OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of $LIBRARYNAME; | 5 part of $LIBRARYNAME; |
6 | 6 |
7 @DocsEditable() | 7 @DocsEditable() |
8 $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME extends Node | 8 $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME extends Node |
9 { | 9 { |
10 | 10 |
11 $!MEMBERS | 11 $!MEMBERS |
12 /** | 12 /** |
13 * Finds all descendant elements of this document that match the specified | 13 * Finds all descendant elements of this document that match the specified |
14 * group of selectors. | 14 * group of selectors. |
15 * | 15 * |
16 * Unless your webpage contains multiple documents, the top-level | 16 * Unless your webpage contains multiple documents, the top-level |
17 * [querySelectorAll] | 17 * [querySelectorAll] |
18 * method behaves the same as this method, so you should use it instead to | 18 * method behaves the same as this method, so you should use it instead to |
19 * save typing a few characters. | 19 * save typing a few characters. |
20 * | 20 * |
21 * [selectors] should be a string using CSS selector syntax. | 21 * [selectors] should be a string using CSS selector syntax. |
22 * | 22 * |
23 * var items = document.querySelectorAll('.itemClassName'); | 23 * var items = document.querySelectorAll('.itemClassName'); |
24 * | 24 * |
25 * For details about CSS selector syntax, see the | 25 * For details about CSS selector syntax, see the |
26 * [CSS selector specification](http://www.w3.org/TR/css3-selectors/). | 26 * [CSS selector specification](http://www.w3.org/TR/css3-selectors/). |
27 */ | 27 */ |
28 ElementList<Element> querySelectorAll(String selectors) { | 28 ElementList<Element> querySelectorAll(String selectors) { |
| 29 $if JSINTEROP |
| 30 return _querySelectorAll(selectors); |
| 31 $else |
29 return new _FrozenElementList._wrap(_querySelectorAll(selectors)); | 32 return new _FrozenElementList._wrap(_querySelectorAll(selectors)); |
| 33 $endif |
30 } | 34 } |
31 | 35 |
32 /** | 36 /** |
33 * Alias for [querySelector]. Note this function is deprecated because its | 37 * Alias for [querySelector]. Note this function is deprecated because its |
34 * semantics will be changing in the future. | 38 * semantics will be changing in the future. |
35 */ | 39 */ |
36 @deprecated | 40 @deprecated |
37 @Experimental() | 41 @Experimental() |
38 @DomName('Document.querySelector') | 42 @DomName('Document.querySelector') |
39 Element query(String relativeSelectors) => querySelector(relativeSelectors); | 43 Element query(String relativeSelectors) => querySelector(relativeSelectors); |
(...skipping 19 matching lines...) Expand all Loading... |
59 | 63 |
60 /// *Deprecated*: use [supportsRegisterElement] instead. | 64 /// *Deprecated*: use [supportsRegisterElement] instead. |
61 @deprecated | 65 @deprecated |
62 bool get supportsRegister => supportsRegisterElement; | 66 bool get supportsRegister => supportsRegisterElement; |
63 | 67 |
64 @DomName('Document.createElement') | 68 @DomName('Document.createElement') |
65 Element createElement(String tagName, [String typeExtension]) { | 69 Element createElement(String tagName, [String typeExtension]) { |
66 $if DART2JS | 70 $if DART2JS |
67 return _createElement(tagName, typeExtension); | 71 return _createElement(tagName, typeExtension); |
68 $else | 72 $else |
69 var newElement = (typeExtension == null) ? | 73 $if JSINTEROP |
70 _blink.BlinkDocument.instance.createElement_Callback_1_(unwrap_jso(this),
tagName) : | 74 return _createElement(tagName, typeExtension); |
71 _blink.BlinkDocument.instance.createElement_Callback_2_(unwrap_jso(this),
tagName, typeExtension); | 75 $else |
72 | 76 if (typeExtension != null) { |
73 var wrapped; | 77 return _createElement(tagName, typeExtension); |
74 | 78 } else { |
75 if (newElement['dart_class'] != null) { | 79 // Fast-path for Dartium when typeExtension is not needed. |
76 wrapped = newElement['dart_class']; // Here's our Dart class. | 80 return _Utils.createElement(this, tagName); |
77 wrapped.blink_jsObject = newElement; | 81 } |
78 } else { | 82 $endif |
79 wrapped = wrap_jso(newElement); | |
80 if (wrapped == null) { | |
81 wrapped = wrap_jso_custom_element(newElement); | |
82 } | |
83 } | |
84 | |
85 return wrapped; | |
86 $endif | 83 $endif |
87 } | 84 } |
88 | 85 |
89 @DomName('Document.createElementNS') | |
90 @DocsEditable() | |
91 Element createElementNS(String namespaceURI, String qualifiedName, [String typ
eExtension]) { | |
92 $if DART2JS | |
93 return _createElementNS(tagName, qualifiedName, typeExtension); | |
94 $else | |
95 var newElement = (typeExtension == null) ? | |
96 _blink.BlinkDocument.instance.createElementNS_Callback_2_(unwrap_jso(this)
, namespaceURI, qualifiedName) : | |
97 _blink.BlinkDocument.instance.createElementNS_Callback_3_(unwrap_jso(this)
, namespaceURI, qualifiedName, typeExtension); | |
98 | |
99 var wrapped; | |
100 | |
101 if (newElement['dart_class'] != null) { | |
102 wrapped = newElement['dart_class']; // Here's our Dart class. | |
103 wrapped.blink_jsObject = newElement; | |
104 } else { | |
105 wrapped = wrap_jso(newElement); | |
106 if (wrapped == null) { | |
107 wrapped = wrap_jso_custom_element(newElement); | |
108 } | |
109 } | |
110 | |
111 return wrapped; | |
112 $endif | |
113 } | |
114 | |
115 $if DART2JS | 86 $if DART2JS |
116 @DomName('Document.createNodeIterator') | 87 @DomName('Document.createNodeIterator') |
117 NodeIterator _createNodeIterator(Node root, | 88 NodeIterator _createNodeIterator(Node root, |
118 [int whatToShow, NodeFilter filter]) | 89 [int whatToShow, NodeFilter filter]) |
119 => JS('NodeIterator', '#.createNodeIterator(#, #, #, false)', | 90 => JS('NodeIterator', '#.createNodeIterator(#, #, #, false)', |
120 this, root, whatToShow, filter); | 91 this, root, whatToShow, filter); |
121 | 92 |
122 @DomName('Document.createTreeWalker') | 93 @DomName('Document.createTreeWalker') |
123 TreeWalker _createTreeWalker(Node root, | 94 TreeWalker _createTreeWalker(Node root, |
124 [int whatToShow, NodeFilter filter]) | 95 [int whatToShow, NodeFilter filter]) |
125 => JS('TreeWalker', '#.createTreeWalker(#, #, #, false)', | 96 => JS('TreeWalker', '#.createTreeWalker(#, #, #, false)', |
126 this, root, whatToShow, filter); | 97 this, root, whatToShow, filter); |
127 $endif | 98 $endif |
128 } | 99 } |
OLD | NEW |