OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS
{ | 7 $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS
{ |
8 factory $CLASSNAME() => document.createDocumentFragment(); | 8 factory $CLASSNAME() => document.createDocumentFragment(); |
9 | 9 |
10 factory $CLASSNAME.html(String html, | 10 factory $CLASSNAME.html(String html, |
(...skipping 20 matching lines...) Expand all Loading... |
31 $endif | 31 $endif |
32 List<Element> _docChildren; | 32 List<Element> _docChildren; |
33 | 33 |
34 List<Element> get children { | 34 List<Element> get children { |
35 if (_docChildren == null) { | 35 if (_docChildren == null) { |
36 _docChildren = new FilteredElementList(this); | 36 _docChildren = new FilteredElementList(this); |
37 } | 37 } |
38 return _docChildren; | 38 return _docChildren; |
39 } | 39 } |
40 | 40 |
41 void set children(List<Element> value) { | 41 set children(List<Element> value) { |
42 // Copy list first since we don't want liveness during iteration. | 42 // Copy list first since we don't want liveness during iteration. |
43 List copy = new List.from(value); | 43 List copy = new List.from(value); |
44 var children = this.children; | 44 var children = this.children; |
45 children.clear(); | 45 children.clear(); |
46 children.addAll(copy); | 46 children.addAll(copy); |
47 } | 47 } |
48 | 48 |
49 /** | 49 /** |
50 * Finds all descendant elements of this document fragment that match the | 50 * Finds all descendant elements of this document fragment that match the |
51 * specified group of selectors. | 51 * specified group of selectors. |
52 * | 52 * |
53 * [selectors] should be a string using CSS selector syntax. | 53 * [selectors] should be a string using CSS selector syntax. |
54 * | 54 * |
55 * var items = document.querySelectorAll('.itemClassName'); | 55 * var items = document.querySelectorAll('.itemClassName'); |
56 * | 56 * |
57 * For details about CSS selector syntax, see the | 57 * For details about CSS selector syntax, see the |
58 * [CSS selector specification](http://www.w3.org/TR/css3-selectors/). | 58 * [CSS selector specification](http://www.w3.org/TR/css3-selectors/). |
59 */ | 59 */ |
60 ElementList<Element> querySelectorAll(String selectors) => | 60 ElementList<Element> querySelectorAll(String selectors) => |
61 $if JSINTEROP | |
62 _querySelectorAll(selectors); | |
63 $else | |
64 new _FrozenElementList._wrap(_querySelectorAll(selectors)); | 61 new _FrozenElementList._wrap(_querySelectorAll(selectors)); |
65 $endif | |
66 | |
67 | 62 |
68 String get innerHtml { | 63 String get innerHtml { |
69 final e = new Element.tag("div"); | 64 final e = new Element.tag("div"); |
70 e.append(this.clone(true)); | 65 e.append(this.clone(true)); |
71 return e.innerHtml; | 66 return e.innerHtml; |
72 } | 67 } |
73 | 68 |
74 void set innerHtml(String value) { | 69 set innerHtml(String value) { |
75 this.setInnerHtml(value); | 70 this.setInnerHtml(value); |
76 } | 71 } |
77 | 72 |
78 void setInnerHtml(String html, | 73 void setInnerHtml(String html, |
79 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) { | 74 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) { |
80 | 75 |
81 this.nodes.clear(); | 76 this.nodes.clear(); |
82 append(document.body.createFragment( | 77 append(document.body.createFragment( |
83 html, validator: validator, treeSanitizer: treeSanitizer)); | 78 html, validator: validator, treeSanitizer: treeSanitizer)); |
84 } | 79 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 * semantics will be changing in the future. | 113 * semantics will be changing in the future. |
119 */ | 114 */ |
120 @deprecated | 115 @deprecated |
121 @Experimental() | 116 @Experimental() |
122 @DomName('DocumentFragment.querySelectorAll') | 117 @DomName('DocumentFragment.querySelectorAll') |
123 ElementList<Element> queryAll(String relativeSelectors) { | 118 ElementList<Element> queryAll(String relativeSelectors) { |
124 return querySelectorAll(relativeSelectors); | 119 return querySelectorAll(relativeSelectors); |
125 } | 120 } |
126 $!MEMBERS | 121 $!MEMBERS |
127 } | 122 } |
OLD | NEW |