Chromium Code Reviews| 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() => document.createDocumentFragment(); | 8 factory $CLASSNAME() => document.createDocumentFragment(); | 
| 9 | 9 | 
| 10 factory $CLASSNAME.html(String html) { | 10 factory $CLASSNAME.html(String html, | 
| 11 final fragment = new DocumentFragment(); | 11 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) { | 
| 12 fragment.innerHtml = html; | 12 | 
| 13 return fragment; | 13 return document.body.createFragment(html, | 
| 14 validator: validator, treeSanitizer: treeSanitizer); | |
| 
 
Jennifer Messerly
2013/06/06 05:55:53
+2 spaces?
 
blois
2013/06/06 16:59:42
Done.
 
 | |
| 14 } | 15 } | 
| 15 | 16 | 
| 16 factory $CLASSNAME.svg(String svgContent) { | 17 factory $CLASSNAME.svg(String svgContent, | 
| 17 final fragment = new DocumentFragment(); | 18 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) { | 
| 18 final e = new svg.SvgSvgElement(); | |
| 19 e.innerHtml = svgContent; | |
| 20 | 19 | 
| 21 // Copy list first since we don't want liveness during iteration. | 20 return new svg.SvgSvgElement().createFragment(svgContent, | 
| 22 final List nodes = new List.from(e.nodes); | 21 validator: validator, treeSanitizer: treeSanitizer); | 
| 23 fragment.nodes.addAll(nodes); | |
| 24 return fragment; | |
| 25 } | 22 } | 
| 26 | 23 | 
| 27 $if DART2JS | 24 $if DART2JS | 
| 28 // Native field is used only by Dart code so does not lead to instantiation | 25 // Native field is used only by Dart code so does not lead to instantiation | 
| 29 // of native classes | 26 // of native classes | 
| 30 @Creates('Null') | 27 @Creates('Null') | 
| 31 $endif | 28 $endif | 
| 32 List<Element> _children; | 29 List<Element> _children; | 
| 33 | 30 | 
| 34 List<Element> get children { | 31 List<Element> get children { | 
| (...skipping 15 matching lines...) Expand all Loading... | |
| 50 | 47 | 
| 51 List<Element> queryAll(String selectors) => | 48 List<Element> queryAll(String selectors) => | 
| 52 new _FrozenElementList._wrap($dom_querySelectorAll(selectors)); | 49 new _FrozenElementList._wrap($dom_querySelectorAll(selectors)); | 
| 53 | 50 | 
| 54 String get innerHtml { | 51 String get innerHtml { | 
| 55 final e = new Element.tag("div"); | 52 final e = new Element.tag("div"); | 
| 56 e.append(this.clone(true)); | 53 e.append(this.clone(true)); | 
| 57 return e.innerHtml; | 54 return e.innerHtml; | 
| 58 } | 55 } | 
| 59 | 56 | 
| 60 // TODO(nweiz): Do we want to support some variant of innerHtml for XML and/or | |
| 61 // SVG strings? | |
| 62 void set innerHtml(String value) { | 57 void set innerHtml(String value) { | 
| 58 this.setInnerHtml(value); | |
| 59 } | |
| 60 | |
| 61 void setInnerHtml(String html, | |
| 62 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) { | |
| 63 | |
| 63 this.nodes.clear(); | 64 this.nodes.clear(); | 
| 64 | 65 append(document.body.createFragment( | 
| 65 final e = new Element.tag("div"); | 66 html, validator: validator, treeSanitizer: treeSanitizer)); | 
| 66 e.innerHtml = value; | |
| 67 | |
| 68 // Copy list first since we don't want liveness during iteration. | |
| 69 List nodes = new List.from(e.nodes, growable: false); | |
| 70 this.nodes.addAll(nodes); | |
| 71 } | 67 } | 
| 72 | 68 | 
| 73 /** | 69 /** | 
| 74 * Adds the specified text as a text node after the last child of this | 70 * Adds the specified text as a text node after the last child of this | 
| 75 * document fragment. | 71 * document fragment. | 
| 76 */ | 72 */ | 
| 77 void appendText(String text) { | 73 void appendText(String text) { | 
| 78 this.append(new Text(text)); | 74 this.append(new Text(text)); | 
| 79 } | 75 } | 
| 80 | 76 | 
| 81 | 77 | 
| 82 /** | 78 /** | 
| 83 * Parses the specified text as HTML and adds the resulting node after the | 79 * Parses the specified text as HTML and adds the resulting node after the | 
| 84 * last child of this document fragment. | 80 * last child of this document fragment. | 
| 85 */ | 81 */ | 
| 86 void appendHtml(String text) { | 82 void appendHtml(String text) { | 
| 87 this.append(new DocumentFragment.html(text)); | 83 this.append(new DocumentFragment.html(text)); | 
| 88 } | 84 } | 
| 89 | 85 | 
| 90 $!MEMBERS | 86 $!MEMBERS | 
| 91 } | 87 } | 
| OLD | NEW |