From 45cb1506a610a4f4421f84ac9e0d690902537335 Mon Sep 17 00:00:00 2001 From: Steven Orvell Date: Mon, 10 Aug 2015 18:34:22 -0700 Subject: [PATCH] Add logical info iff an element being added is an insertion point; do not add logical info for any element in a shady root. --- src/lib/dom-api.html | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/lib/dom-api.html b/src/lib/dom-api.html index 5282130508..929c1ac912 100644 --- a/src/lib/dom-api.html +++ b/src/lib/dom-api.html @@ -65,11 +65,15 @@ // 3. node is (host of container needs distribution) appendChild: function(node) { var handled; + // if a is added, make sure it's parent has logical info. + this._ensureContentLogicalInfo(node); this._removeNodeFromHost(node, true); if (this._nodeIsInLogicalTree(this.node)) { this._addLogicalInfo(node, this.node); this._addNodeToHost(node); handled = this._maybeDistribute(node, this.node); + } else { + this._addNodeToHost(node); } // if not distributing and not adding to host, do a fast path addition if (!handled && !this._tryRemoveUndistributedNode(node)) { @@ -86,9 +90,10 @@ return this.appendChild(node); } var handled; + // if a is added, make sure it's parent has logical info. + this._ensureContentLogicalInfo(node); this._removeNodeFromHost(node, true); if (this._nodeIsInLogicalTree(this.node)) { - saveLightChildrenIfNeeded(this.node); var children = this.childNodes; var index = children.indexOf(ref_node); if (index < 0) { @@ -98,6 +103,8 @@ this._addLogicalInfo(node, this.node, index); this._addNodeToHost(node); handled = this._maybeDistribute(node, this.node); + } else { + this._addNodeToHost(node); } // if not distributing and not adding to host, do a fast path addition if (!handled && !this._tryRemoveUndistributedNode(node)) { @@ -125,6 +132,8 @@ if (this._nodeIsInLogicalTree(this.node)) { this._removeNodeFromHost(node); handled = this._maybeDistribute(node, this.node); + } else { + this._removeNodeFromHost(node); } if (!handled) { // if removing from a shadyRoot, remove form host instead @@ -237,10 +246,23 @@ // or has a lightParent _nodeIsInLogicalTree: function(node) { return Boolean((node._lightParent !== undefined) || node._isShadyRoot || - this._ownerShadyRootForNode(node) || node.shadyRoot); }, + _ensureContentLogicalInfo: function(node) { + if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) { + saveLightChildrenIfNeeded(this.node); + var c$ = Array.prototype.slice.call(node.childNodes); + for (var i=0, n; (i