| 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)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { | 7 $(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { |
| 8 factory $CLASSNAME() => _$(CLASSNAME)FactoryProvider.createDocumentFragment(); | 8 factory $CLASSNAME() => _$(CLASSNAME)FactoryProvider.createDocumentFragment(); |
| 9 | 9 |
| 10 factory $CLASSNAME.html(String html) => | 10 factory $CLASSNAME.html(String html) => |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 children.addAll(copy); | 35 children.addAll(copy); |
| 36 } | 36 } |
| 37 | 37 |
| 38 Element query(String selectors) => $dom_querySelector(selectors); | 38 Element query(String selectors) => $dom_querySelector(selectors); |
| 39 | 39 |
| 40 List<Element> queryAll(String selectors) => | 40 List<Element> queryAll(String selectors) => |
| 41 new _FrozenElementList._wrap($dom_querySelectorAll(selectors)); | 41 new _FrozenElementList._wrap($dom_querySelectorAll(selectors)); |
| 42 | 42 |
| 43 String get innerHtml { | 43 String get innerHtml { |
| 44 final e = new Element.tag("div"); | 44 final e = new Element.tag("div"); |
| 45 e.nodes.add(this.clone(true)); | 45 e.append(this.clone(true)); |
| 46 return e.innerHtml; | 46 return e.innerHtml; |
| 47 } | 47 } |
| 48 | 48 |
| 49 // TODO(nweiz): Do we want to support some variant of innerHtml for XML and/or | 49 // TODO(nweiz): Do we want to support some variant of innerHtml for XML and/or |
| 50 // SVG strings? | 50 // SVG strings? |
| 51 void set innerHtml(String value) { | 51 void set innerHtml(String value) { |
| 52 this.nodes.clear(); | 52 this.nodes.clear(); |
| 53 | 53 |
| 54 final e = new Element.tag("div"); | 54 final e = new Element.tag("div"); |
| 55 e.innerHtml = value; | 55 e.innerHtml = value; |
| 56 | 56 |
| 57 // Copy list first since we don't want liveness during iteration. | 57 // Copy list first since we don't want liveness during iteration. |
| 58 List nodes = new List.from(e.nodes); | 58 List nodes = new List.from(e.nodes); |
| 59 this.nodes.addAll(nodes); | 59 this.nodes.addAll(nodes); |
| 60 } | 60 } |
| 61 | 61 |
| 62 /** | 62 /** |
| 63 * Adds the specified element after the last child of this | |
| 64 * document fragment. | |
| 65 */ | |
| 66 void append(Element element) { | |
| 67 this.children.add(element); | |
| 68 } | |
| 69 | |
| 70 /** | |
| 71 * Adds the specified text as a text node after the last child of this | 63 * Adds the specified text as a text node after the last child of this |
| 72 * document fragment. | 64 * document fragment. |
| 73 */ | 65 */ |
| 74 void appendText(String text) { | 66 void appendText(String text) { |
| 75 this.nodes.add(new Text(text)); | 67 this.append(new Text(text)); |
| 76 } | 68 } |
| 77 | 69 |
| 78 | 70 |
| 79 /** | 71 /** |
| 80 * Parses the specified text as HTML and adds the resulting node after the | 72 * Parses the specified text as HTML and adds the resulting node after the |
| 81 * last child of this document fragment. | 73 * last child of this document fragment. |
| 82 */ | 74 */ |
| 83 void appendHtml(String text) { | 75 void appendHtml(String text) { |
| 84 this.nodes.add(new DocumentFragment.html(text)); | 76 this.append(new DocumentFragment.html(text)); |
| 85 } | 77 } |
| 86 | 78 |
| 87 $!MEMBERS | 79 $!MEMBERS |
| 88 } | 80 } |
| OLD | NEW |