Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Unified Diff: tools/dom/templates/html/impl/impl_DocumentFragment.darttemplate

Issue 16374007: First rev of Safe DOM (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/dom/templates/html/impl/impl_DocumentFragment.darttemplate
diff --git a/tools/dom/templates/html/impl/impl_DocumentFragment.darttemplate b/tools/dom/templates/html/impl/impl_DocumentFragment.darttemplate
index 0f8a72b4248e5c02e39f6e10ea9da53ab6b1741a..769b793248b017524a78045a90aedff2af4580d2 100644
--- a/tools/dom/templates/html/impl/impl_DocumentFragment.darttemplate
+++ b/tools/dom/templates/html/impl/impl_DocumentFragment.darttemplate
@@ -7,21 +7,18 @@ part of $LIBRARYNAME;
$(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
factory $CLASSNAME() => document.createDocumentFragment();
- factory $CLASSNAME.html(String html) {
- final fragment = new DocumentFragment();
- fragment.innerHtml = html;
- return fragment;
+ factory $CLASSNAME.html(String html,
+ {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) {
+
+ return document.body.createFragment(html,
+ validator: validator, treeSanitizer: treeSanitizer);
Jennifer Messerly 2013/06/06 05:55:53 +2 spaces?
blois 2013/06/06 16:59:42 Done.
}
- factory $CLASSNAME.svg(String svgContent) {
- final fragment = new DocumentFragment();
- final e = new svg.SvgSvgElement();
- e.innerHtml = svgContent;
+ factory $CLASSNAME.svg(String svgContent,
+ {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) {
- // Copy list first since we don't want liveness during iteration.
- final List nodes = new List.from(e.nodes);
- fragment.nodes.addAll(nodes);
- return fragment;
+ return new svg.SvgSvgElement().createFragment(svgContent,
+ validator: validator, treeSanitizer: treeSanitizer);
}
$if DART2JS
@@ -57,17 +54,16 @@ $endif
return e.innerHtml;
}
- // TODO(nweiz): Do we want to support some variant of innerHtml for XML and/or
- // SVG strings?
void set innerHtml(String value) {
- this.nodes.clear();
+ this.setInnerHtml(value);
+ }
- final e = new Element.tag("div");
- e.innerHtml = value;
+ void setInnerHtml(String html,
+ {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) {
- // Copy list first since we don't want liveness during iteration.
- List nodes = new List.from(e.nodes, growable: false);
- this.nodes.addAll(nodes);
+ this.nodes.clear();
+ append(document.body.createFragment(
+ html, validator: validator, treeSanitizer: treeSanitizer));
}
/**

Powered by Google App Engine
This is Rietveld 408576698