From 9b1f7069ee5a6683e8c3f0f7c0ac3e0a8f86f2dc Mon Sep 17 00:00:00 2001 From: Steven Orvell Date: Fri, 21 Aug 2015 17:34:17 -0700 Subject: [PATCH] Fixes #2341: branch Polymer.dom to use native dom methods under Shadow DOM for: appendChild, insertBefore, removeChild, replaceChild, cloneNode. --- src/lib/dom-api.html | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/lib/dom-api.html b/src/lib/dom-api.html index 1be13b3bde..7295e4422a 100644 --- a/src/lib/dom-api.html +++ b/src/lib/dom-api.html @@ -711,6 +711,15 @@ } 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)); }; @@ -725,10 +734,6 @@ } }; - 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; @@ -788,11 +793,11 @@ }); - var forwards = ['parentNode', 'firstChild', 'lastChild', 'nextSibling', - 'previousSibling', 'firstElementChild', 'lastElementChild', + var forwardProperties = ['parentNode', 'firstChild', 'lastChild', + 'nextSibling', 'previousSibling', 'firstElementChild', 'lastElementChild', 'nextElementSibling', 'previousElementSibling']; - forwards.forEach(function(name) { + forwardProperties.forEach(function(name) { Object.defineProperty(DomApi.prototype, name, { get: function() { return this.node[name];