| Index: third_party/polymer/v1_0/components-chromium/polymer/polymer-mini-extracted.js
|
| diff --git a/third_party/polymer/v1_0/components-chromium/polymer/polymer-mini-extracted.js b/third_party/polymer/v1_0/components-chromium/polymer/polymer-mini-extracted.js
|
| index d1083c107ac0f51da8e3a8f4a930d0bb51847c47..55d8f1ac17e88924799e1bfb15744a22d3874676 100644
|
| --- a/third_party/polymer/v1_0/components-chromium/polymer/polymer-mini-extracted.js
|
| +++ b/third_party/polymer/v1_0/components-chromium/polymer/polymer-mini-extracted.js
|
| @@ -447,42 +447,43 @@ Polymer.dom.addDebouncer(host.debounce('_distribute', host._distributeContent));
|
| }
|
| },
|
| appendChild: function (node) {
|
| -var handled;
|
| -this._removeNodeFromHost(node, true);
|
| -if (this._nodeIsInLogicalTree(this.node)) {
|
| -this._addLogicalInfo(node, this.node);
|
| -this._addNodeToHost(node);
|
| -handled = this._maybeDistribute(node, this.node);
|
| -}
|
| -if (!handled && !this._tryRemoveUndistributedNode(node)) {
|
| -var container = this.node._isShadyRoot ? this.node.host : this.node;
|
| -addToComposedParent(container, node);
|
| -nativeAppendChild.call(container, node);
|
| -}
|
| -return node;
|
| +return this._addNode(node);
|
| },
|
| insertBefore: function (node, ref_node) {
|
| -if (!ref_node) {
|
| -return this.appendChild(node);
|
| -}
|
| -var handled;
|
| +return this._addNode(node, ref_node);
|
| +},
|
| +_addNode: function (node, ref_node) {
|
| this._removeNodeFromHost(node, true);
|
| -if (this._nodeIsInLogicalTree(this.node)) {
|
| -saveLightChildrenIfNeeded(this.node);
|
| +var addedInsertionPoint;
|
| +var root = this.getOwnerRoot();
|
| +if (root) {
|
| +addedInsertionPoint = this._maybeAddInsertionPoint(node, this.node);
|
| +}
|
| +if (this._nodeHasLogicalChildren(this.node)) {
|
| +if (ref_node) {
|
| var children = this.childNodes;
|
| var index = children.indexOf(ref_node);
|
| if (index < 0) {
|
| throw Error('The ref_node to be inserted before is not a child ' + 'of this node');
|
| }
|
| +}
|
| this._addLogicalInfo(node, this.node, index);
|
| -this._addNodeToHost(node);
|
| -handled = this._maybeDistribute(node, this.node);
|
| }
|
| -if (!handled && !this._tryRemoveUndistributedNode(node)) {
|
| +this._addNodeToHost(node);
|
| +if (!this._maybeDistribute(node, this.node) && !this._tryRemoveUndistributedNode(node)) {
|
| +if (ref_node) {
|
| ref_node = ref_node.localName === CONTENT ? this._firstComposedNode(ref_node) : ref_node;
|
| +}
|
| var container = this.node._isShadyRoot ? this.node.host : this.node;
|
| addToComposedParent(container, node, ref_node);
|
| +if (ref_node) {
|
| nativeInsertBefore.call(container, node, ref_node);
|
| +} else {
|
| +nativeAppendChild.call(container, node);
|
| +}
|
| +}
|
| +if (addedInsertionPoint) {
|
| +this._updateInsertionPoints(root.host);
|
| }
|
| return node;
|
| },
|
| @@ -490,12 +491,8 @@ removeChild: function (node) {
|
| if (factory(node).parentNode !== this.node) {
|
| console.warn('The node to be removed is not a child of this node', node);
|
| }
|
| -var handled;
|
| -if (this._nodeIsInLogicalTree(this.node)) {
|
| this._removeNodeFromHost(node);
|
| -handled = this._maybeDistribute(node, this.node);
|
| -}
|
| -if (!handled) {
|
| +if (!this._maybeDistribute(node, this.node)) {
|
| var container = this.node._isShadyRoot ? this.node.host : this.node;
|
| if (container === node.parentNode) {
|
| removeFromComposedParent(container, node);
|
| @@ -543,7 +540,6 @@ if (hasContent) {
|
| var root = this._ownerShadyRootForNode(parent);
|
| if (root) {
|
| var host = root.host;
|
| -this._updateInsertionPoints(host);
|
| this._lazyDistribute(host);
|
| }
|
| }
|
| @@ -553,19 +549,44 @@ this._lazyDistribute(parent);
|
| }
|
| return parentNeedsDist || hasContent && !wrappedContent;
|
| },
|
| +_maybeAddInsertionPoint: function (node, parent) {
|
| +var added;
|
| +if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE && !node.__noContent) {
|
| +var c$ = factory(node).querySelectorAll(CONTENT);
|
| +for (var i = 0, n, np, na; i < c$.length && (n = c$[i]); i++) {
|
| +np = factory(n).parentNode;
|
| +if (np === node) {
|
| +np = parent;
|
| +}
|
| +na = this._maybeAddInsertionPoint(n, np);
|
| +added = added || na;
|
| +}
|
| +} else if (node.localName === CONTENT) {
|
| +saveLightChildrenIfNeeded(parent);
|
| +saveLightChildrenIfNeeded(node);
|
| +added = true;
|
| +}
|
| +return added;
|
| +},
|
| _tryRemoveUndistributedNode: function (node) {
|
| if (this.node.shadyRoot) {
|
| -if (node._composedParent) {
|
| -nativeRemoveChild.call(node._composedParent, node);
|
| +var parent = getComposedParent(node);
|
| +if (parent) {
|
| +nativeRemoveChild.call(parent, node);
|
| }
|
| return true;
|
| }
|
| },
|
| _updateInsertionPoints: function (host) {
|
| -host.shadyRoot._insertionPoints = factory(host.shadyRoot).querySelectorAll(CONTENT);
|
| +var i$ = host.shadyRoot._insertionPoints = factory(host.shadyRoot).querySelectorAll(CONTENT);
|
| +for (var i = 0, c; i < i$.length; i++) {
|
| +c = i$[i];
|
| +saveLightChildrenIfNeeded(c);
|
| +saveLightChildrenIfNeeded(factory(c).parentNode);
|
| +}
|
| },
|
| -_nodeIsInLogicalTree: function (node) {
|
| -return Boolean(node._lightParent !== undefined || node._isShadyRoot || this._ownerShadyRootForNode(node) || node.shadyRoot);
|
| +_nodeHasLogicalChildren: function (node) {
|
| +return Boolean(node._lightChildren !== undefined);
|
| },
|
| _parentNeedsDistribution: function (parent) {
|
| return parent && parent.shadyRoot && hasInsertionPoint(parent.shadyRoot);
|
| @@ -575,6 +596,7 @@ var hostNeedsDist;
|
| var root;
|
| var parent = node._lightParent;
|
| if (parent) {
|
| +factory(node)._distributeParent();
|
| root = this._ownerShadyRootForNode(node);
|
| if (root) {
|
| root.host._elementRemove(node);
|
| @@ -587,7 +609,7 @@ if (root && hostNeedsDist) {
|
| this._updateInsertionPoints(root.host);
|
| this._lazyDistribute(root.host);
|
| } else if (ensureComposedRemoval) {
|
| -removeFromComposedParent(parent || node.parentNode, node);
|
| +removeFromComposedParent(getComposedParent(node), node);
|
| }
|
| },
|
| _removeDistributedChildren: function (root, container) {
|
| @@ -619,14 +641,12 @@ node = factory(node).parentNode;
|
| }
|
| },
|
| _addNodeToHost: function (node) {
|
| -var checkNode = node.nodeType === Node.DOCUMENT_FRAGMENT_NODE ? node.firstChild : node;
|
| -var root = this._ownerShadyRootForNode(checkNode);
|
| +var root = this.getOwnerRoot();
|
| if (root) {
|
| root.host._elementAdd(node);
|
| }
|
| },
|
| _addLogicalInfo: function (node, container, index) {
|
| -saveLightChildrenIfNeeded(container);
|
| var children = factory(container).childNodes;
|
| index = index === undefined ? children.length : index;
|
| if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
|
| @@ -813,7 +833,7 @@ configurable: true
|
| },
|
| parentNode: {
|
| get: function () {
|
| -return this.node._lightParent || (this.node.__patched ? this.node._composedParent : this.node.parentNode);
|
| +return this.node._lightParent || getComposedParent(this.node);
|
| },
|
| configurable: true
|
| },
|
| @@ -935,6 +955,18 @@ DomApi.prototype._getComposedInnerHTML = function () {
|
| return getInnerHTML(this.node, true);
|
| };
|
| } else {
|
| +var forwardMethods = [
|
| +'cloneNode',
|
| +'appendChild',
|
| +'insertBefore',
|
| +'removeChild',
|
| +'replaceChild'
|
| +];
|
| +forwardMethods.forEach(function (name) {
|
| +DomApi.prototype[name] = function () {
|
| +return this.node[name].apply(this.node, arguments);
|
| +};
|
| +});
|
| DomApi.prototype.querySelectorAll = function (selector) {
|
| return Array.prototype.slice.call(this.node.querySelectorAll(selector));
|
| };
|
| @@ -947,9 +979,6 @@ return n;
|
| n = n.parentNode;
|
| }
|
| };
|
| -DomApi.prototype.cloneNode = function (deep) {
|
| -return this.node.cloneNode(deep);
|
| -};
|
| DomApi.prototype.importNode = function (externalNode, deep) {
|
| var doc = this.node instanceof Document ? this.node : this.node.ownerDocument;
|
| return doc.importNode(externalNode, deep);
|
| @@ -996,7 +1025,7 @@ return this.node.innerHTML = value;
|
| configurable: true
|
| }
|
| });
|
| -var forwards = [
|
| +var forwardProperties = [
|
| 'parentNode',
|
| 'firstChild',
|
| 'lastChild',
|
| @@ -1007,7 +1036,7 @@ var forwards = [
|
| 'nextElementSibling',
|
| 'previousElementSibling'
|
| ];
|
| -forwards.forEach(function (name) {
|
| +forwardProperties.forEach(function (name) {
|
| Object.defineProperty(DomApi.prototype, name, {
|
| get: function () {
|
| return this.node[name];
|
| @@ -1091,6 +1120,9 @@ node._composedChildren = null;
|
| addNodeToComposedChildren(node, parent, children, i);
|
| }
|
| }
|
| +function getComposedParent(node) {
|
| +return node.__patched ? node._composedParent : node.parentNode;
|
| +}
|
| function addNodeToComposedChildren(node, parent, children, i) {
|
| node._composedParent = parent;
|
| children.splice(i >= 0 ? i : children.length, 0, node);
|
| @@ -1115,12 +1147,13 @@ node._lightChildren = c$;
|
| }
|
| }
|
| function hasInsertionPoint(root) {
|
| -return Boolean(root._insertionPoints.length);
|
| +return Boolean(root && root._insertionPoints.length);
|
| }
|
| var p = Element.prototype;
|
| var matchesSelector = p.matches || p.matchesSelector || p.mozMatchesSelector || p.msMatchesSelector || p.oMatchesSelector || p.webkitMatchesSelector;
|
| return {
|
| getLightChildren: getLightChildren,
|
| +getComposedParent: getComposedParent,
|
| getComposedChildren: getComposedChildren,
|
| removeFromComposedParent: removeFromComposedParent,
|
| saveLightChildrenIfNeeded: saveLightChildrenIfNeeded,
|
| @@ -1153,8 +1186,13 @@ this.shadyRoot = this.root;
|
| this.shadyRoot._distributionClean = false;
|
| this.shadyRoot._isShadyRoot = true;
|
| this.shadyRoot._dirtyRoots = [];
|
| -this.shadyRoot._insertionPoints = !this._notes || this._notes._hasContent ? this.shadyRoot.querySelectorAll('content') : [];
|
| +var i$ = this.shadyRoot._insertionPoints = !this._notes || this._notes._hasContent ? this.shadyRoot.querySelectorAll('content') : [];
|
| saveLightChildrenIfNeeded(this.shadyRoot);
|
| +for (var i = 0, c; i < i$.length; i++) {
|
| +c = i$[i];
|
| +saveLightChildrenIfNeeded(c);
|
| +saveLightChildrenIfNeeded(c.parentNode);
|
| +}
|
| this.shadyRoot.host = this;
|
| },
|
| get domHost() {
|
| @@ -1304,7 +1342,9 @@ var composed = getComposedChildren(container);
|
| var splices = Polymer.ArraySplice.calculateSplices(children, composed);
|
| for (var i = 0, d = 0, s; i < splices.length && (s = splices[i]); i++) {
|
| for (var j = 0, n; j < s.removed.length && (n = s.removed[j]); j++) {
|
| +if (getComposedParent(n) === container) {
|
| remove(n);
|
| +}
|
| composed.splice(s.index + d, 1);
|
| }
|
| d -= s.addedCount;
|
| @@ -1317,6 +1357,7 @@ insertBefore(container, n, next);
|
| composed.splice(j, 0, n);
|
| }
|
| }
|
| +ensureComposedParent(container, children);
|
| },
|
| _matchesContentSelect: function (node, contentElement) {
|
| var select = contentElement.getAttribute('select');
|
| @@ -1346,6 +1387,7 @@ var getLightChildren = Polymer.DomApi.getLightChildren;
|
| var matchesSelector = Polymer.DomApi.matchesSelector;
|
| var hasInsertionPoint = Polymer.DomApi.hasInsertionPoint;
|
| var getComposedChildren = Polymer.DomApi.getComposedChildren;
|
| +var getComposedParent = Polymer.DomApi.getComposedParent;
|
| var removeFromComposedParent = Polymer.DomApi.removeFromComposedParent;
|
| function distributeNodeInto(child, insertionPoint) {
|
| insertionPoint._distributedNodes.push(child);
|
| @@ -1389,20 +1431,20 @@ if (newChildParent !== parentNode) {
|
| removeFromComposedParent(newChildParent, newChild);
|
| }
|
| remove(newChild);
|
| -saveLightChildrenIfNeeded(parentNode);
|
| nativeInsertBefore.call(parentNode, newChild, refChild || null);
|
| newChild._composedParent = parentNode;
|
| }
|
| function remove(node) {
|
| var parentNode = getComposedParent(node);
|
| if (parentNode) {
|
| -saveLightChildrenIfNeeded(parentNode);
|
| node._composedParent = null;
|
| nativeRemoveChild.call(parentNode, node);
|
| }
|
| }
|
| -function getComposedParent(node) {
|
| -return node.__patched ? node._composedParent : node.parentNode;
|
| +function ensureComposedParent(parent, children) {
|
| +for (var i = 0, n; i < children.length; i++) {
|
| +children[i]._composedParent = parent;
|
| +}
|
| }
|
| function getTopDistributingHost(host) {
|
| while (host && hostNeedsRedistribution(host)) {
|
|
|