From c3fbd10da8a1da33a5b560d442c1061db200b2cf Mon Sep 17 00:00:00 2001 From: Steven Orvell Date: Mon, 14 Dec 2015 11:41:25 -0800 Subject: [PATCH] remove unused code; minor changes based on review. --- src/lib/experimental/patch-dom.html | 42 +++++++++-------------------- src/mini/shady.html | 2 -- test/smoke/patch/patch-dom.html | 36 ------------------------- 3 files changed, 13 insertions(+), 67 deletions(-) diff --git a/src/lib/experimental/patch-dom.html b/src/lib/experimental/patch-dom.html index 397c40b2f5..e1005d5436 100644 --- a/src/lib/experimental/patch-dom.html +++ b/src/lib/experimental/patch-dom.html @@ -123,7 +123,7 @@ methods: ['appendChild', 'insertBefore', 'removeChild', 'replaceChild', 'querySelector', 'querySelectorAll', 'getDestinationInsertionPoints', - 'cloneNode', /*'importNode',*/ 'setAttribute', 'removeAttribute'], + 'cloneNode', 'setAttribute', 'removeAttribute'], // : getDistributedNodes accessors: ['parentNode', 'childNodes', @@ -192,10 +192,6 @@ } var info = { get: function() { - //log && console.log(this, name); - if (window.nug) { - debugger; - } return dom(this)[name]; }, configurable: true @@ -243,6 +239,8 @@ Polymer.DomApi.patchImpl = patchImpl; + // NOTE: patch logical implementations here so we can use + // composed getters Polymer.TreeApi.Logical.saveChildNodes = function(node) { if (!this.hasChildNodes(node)) { node.__firstChild = node.firstChild; @@ -277,10 +275,6 @@ Polymer.TreeApi.Composed = { - - ensureParentNodes: function(parent, children) { - }, - hasParentNode: function(node) { return Boolean(node.__composedParent !== undefined); }, @@ -290,10 +284,7 @@ }, getChildNodes: function(node) { - // return node.__composedChildNodes || - // (!node.__patched && TreeApi.arrayCopy(node.childNodes)); - return (node.__composedChildNodes && - TreeApi.arrayCopy(node.__composedChildNodes)) || + return node.__composedChildNodes || (!node.__patched && TreeApi.arrayCopy(node.childNodes)); }, @@ -326,25 +317,25 @@ getNextSibling: function(node) { // TODO(sorvell): linked list var parent = this.getParentNode(node); - //if (parent.__patched) { + if (parent.__patched) { var c$ = this.getChildNodes(parent); var i = c$.indexOf(node); return c$[i+1]; - //} else if (!node.__patched) { - // return node.nextSibling; - //} + } else if (!node.__patched) { + return node.nextSibling; + } }, getPreviousSibling: function(node) { // TODO(sorvell): linked list var parent = this.getParentNode(node); - //if (parent.__patched) { + if (parent.__patched) { var c$ = this.getChildNodes(parent); var i = c$.indexOf(node); return c$[i-1]; - //} else if (!node.__patched) { - // return node.previousSibling; - //} + } else if (!node.__patched) { + return node.previousSibling; + } }, // composed tracking needs to reset composed children here in case @@ -407,8 +398,8 @@ } this._removeChild(parentNode, node); if (currentParent === parentNode) { + // TODO(sorvell); abort if the composedParent is not expected... if (!node.__patched && node.parentNode !== node.__composedParent) { - //console.warn('composedParent wrong for', node); return; } return nativeRemoveChild.call(parentNode, node); @@ -445,13 +436,6 @@ }; - // TODO(sorvell): only necessary if we allow document.importNode to be patched. - // var nativeImportNode = document.importNode; - // Polymer.Base.instanceTemplate = function(template) { - // return nativeImportNode.call(document, - // template._content || template.content, true); - // } - // patch important nodes if (window.document) { Polymer.dom(document); diff --git a/src/mini/shady.html b/src/mini/shady.html index 90ae45ddd2..314a6fb847 100644 --- a/src/mini/shady.html +++ b/src/mini/shady.html @@ -353,8 +353,6 @@ composed.splice(j, 0, n); } } - // ensure composed parent is set - TreeApi.Composed.ensureParentNodes(container, children); }, _matchesContentSelect: function(node, contentElement) { diff --git a/test/smoke/patch/patch-dom.html b/test/smoke/patch/patch-dom.html index 9cdc74dfd7..1db4259f93 100644 --- a/test/smoke/patch/patch-dom.html +++ b/test/smoke/patch/patch-dom.html @@ -247,8 +247,6 @@ s.id = 'light'; s.textContent = 'Light'; rere.appendChild(s); - // TODO(sorvell); patch - Polymer.dom(s); assert.equal(rere.querySelector('#light'), s); assert.equal(s.parentNode, rere); Polymer.dom.flush(); @@ -298,35 +296,6 @@ assert.notOk(projected); }); - test('Polymer.dom event', function() { - var test = document.querySelector('x-test'); - var rere = test.root.querySelector('x-rereproject'); - var re = rere.root.querySelector('x-reproject'); - var p = re.root.querySelector('x-project'); - var eventHandled = 0; - test.addEventListener('test-event', function(e) { - eventHandled++; - assert.equal(Polymer.dom(e).rootTarget, p); - assert.equal(Polymer.dom(e).localTarget, test); - var path = Polymer.dom(e).path; - // path includes window only on more recent Shadow DOM implementations - // account for that here. - assert.ok(path.length >= 10); - assert.equal(path[0], p); - assert.equal(path[2], re); - assert.equal(path[4], rere); - assert.equal(path[6], test); - }); - - rere.addEventListener('test-event', function(e) { - eventHandled++; - assert.equal(Polymer.dom(e).localTarget, rere); - }); - - p.fire('test-event'); - assert.equal(eventHandled, 2); - }); - test('Polymer.dom.childNodes is an array', function() { assert.isTrue(Array.isArray(Polymer.dom(document.body).childNodes)); }); @@ -395,17 +364,12 @@ testNoAttr(); // set / unset `test` attr and see if it distributes properly child.setAttribute('test', ''); - //d.distributeContent(); Polymer.dom.flush(); testWithAttr(); - // child.removeAttribute('test'); - //d.distributeContent(); Polymer.dom.flush(); testNoAttr(); - // child.setAttribute('test', ''); - //d.distributeContent(); Polymer.dom.flush(); testWithAttr(); });