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

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, 4 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 8cbbf2c27ef301b3b2b1ec25d28b9fe305686a3d..199b67ad3359fa261cf7b67adefafd2784230ccd 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_MODIFIERS)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);
}
- 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));
}
/**
« no previous file with comments | « tools/dom/templates/html/dartium/html_dartium.darttemplate ('k') | tools/dom/templates/html/impl/impl_Element.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698