Skip to content

Commit

Permalink
Fixes #2341: branch Polymer.dom to use native dom methods under Shado…
Browse files Browse the repository at this point in the history
…w DOM for: appendChild, insertBefore, removeChild, replaceChild, cloneNode.
  • Loading branch information
Steven Orvell committed Aug 22, 2015
1 parent b0733d3 commit 9b1f706
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/lib/dom-api.html
Original file line number Diff line number Diff line change
Expand Up @@ -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));
};
Expand All @@ -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;
Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit 9b1f706

Please sign in to comment.