| 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.
|
|
|