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

Unified Diff: pkg/template_binding/lib/src/template.dart

Issue 105203006: Reverting 30868 and 30873. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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
« no previous file with comments | « pkg/template_binding/lib/src/instance_binding_map.dart ('k') | pkg/template_binding/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/template_binding/lib/src/template.dart
diff --git a/pkg/template_binding/lib/src/template.dart b/pkg/template_binding/lib/src/template.dart
index 552c5cf3baa3fae3ae60d469bc327c7f15b6bdb4..ad35eb816beac4368f76a302765389a99d889966 100644
--- a/pkg/template_binding/lib/src/template.dart
+++ b/pkg/template_binding/lib/src/template.dart
@@ -17,8 +17,6 @@ class TemplateBindExtension extends _ElementExtension {
DocumentFragment _content;
bool _templateIsDecorated;
- HtmlDocument _stagingDocument;
-
var _bindingMap;
TemplateBindExtension._(Element node) : super(node);
@@ -120,8 +118,9 @@ class TemplateBindExtension extends _ElementExtension {
ref._bindingMap = map;
}
- var staging = _getTemplateStagingDocument();
- var instance = _deepCloneIgnoreTemplateContent(content, staging);
+ var instance = map.hasSubTemplate
+ ? _deepCloneIgnoreTemplateContent(content)
+ : content.clone(true);
_addMapBindings(instance, map, model, delegate, bound);
// TODO(rafaelw): We can do this more lazily, but setting a sentinel
@@ -139,12 +138,12 @@ class TemplateBindExtension extends _ElementExtension {
_ensureSetModelScheduled();
}
- static Node _deepCloneIgnoreTemplateContent(Node node, stagingDocument) {
- var clone = stagingDocument.importNode(node, false);
+ static Node _deepCloneIgnoreTemplateContent(Node node) {
+ var clone = node.clone(false); // Shallow clone.
if (isSemanticTemplate(clone)) return clone;
for (var c = node.firstChild; c != null; c = c.nextNode) {
- clone.append(_deepCloneIgnoreTemplateContent(c, stagingDocument));
+ clone.append(_deepCloneIgnoreTemplateContent(c));
}
return clone;
}
@@ -242,7 +241,8 @@ class TemplateBindExtension extends _ElementExtension {
}
if (!isNative) {
- var doc = _getOrCreateTemplateContentsOwner(templateElementExt._node);
+ var doc = _getTemplateContentsOwner(
+ templateElementExt._node.ownerDocument);
templateElementExt._content = doc.createDocumentFragment();
}
@@ -260,13 +260,12 @@ class TemplateBindExtension extends _ElementExtension {
}
static final _contentsOwner = new Expando();
- static final _ownerStagingDocument = new Expando();
// http://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/templates/index.html#dfn-template-contents-owner
- static HtmlDocument _getOrCreateTemplateContentsOwner(Element template) {
- var doc = template.ownerDocument;
- if (doc.window == null) return doc;
-
+ static Document _getTemplateContentsOwner(HtmlDocument doc) {
+ if (doc.window == null) {
+ return doc;
+ }
var d = _contentsOwner[doc];
if (d == null) {
// TODO(arv): This should either be a Document or HTMLDocument depending
@@ -280,19 +279,6 @@ class TemplateBindExtension extends _ElementExtension {
return d;
}
- HtmlDocument _getTemplateStagingDocument() {
- if (_stagingDocument == null) {
- var owner = _node.ownerDocument;
- var doc = _ownerStagingDocument[owner];
- if (doc == null) {
- doc = owner.implementation.createHtmlDocument('');
- _ownerStagingDocument[owner] = doc;
- }
- _stagingDocument = doc;
- }
- return _stagingDocument;
- }
-
// For non-template browsers, the parser will disallow <template> in certain
// locations, so we allow "attribute templates" which combine the template
// element with the top-level container node of the content, e.g.
« no previous file with comments | « pkg/template_binding/lib/src/instance_binding_map.dart ('k') | pkg/template_binding/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698