Skip to content

Commit

Permalink
Merge pull request #3215 from nazar-pc/fix-for-missing-_query-method
Browse files Browse the repository at this point in the history
Fix for `Polymer.dom(...)._query()` method doesn't exist which causes `Polymer.updateStyles()` to fail
  • Loading branch information
Steve Orvell committed Jan 5, 2016
2 parents 31c71d4 + 0eea7a6 commit 7c20170
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
28 changes: 25 additions & 3 deletions src/lib/dom-api-shadow.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,28 @@
return TreeApi.arrayCopy(this.node.querySelectorAll(selector));
},

_query: function(matcher, node) {
node = node || this.node;
var list = [];
this._queryElements(node.childNodes, matcher, list);
return list;
},

_queryElements: function(elements, matcher, list) {
for (var i=0, l=elements.length, c; (i<l) && (c=elements[i]); i++) {
if (c.nodeType === Node.ELEMENT_NODE) {
this._queryElement(c, matcher, list);
}
}
},

_queryElement: function(node, matcher, list) {
if (matcher(node)) {
list.push(node);
}
this._queryElements(node.childNodes, matcher, list);
},

getOwnerRoot: function() {
var n = this.node;
while (n) {
Expand Down Expand Up @@ -57,7 +79,7 @@
});

Object.defineProperties(DomApi.prototype, {

childNodes: {
get: function() {
return TreeApi.arrayCopyChildNodes(this.node);
Expand Down Expand Up @@ -108,7 +130,7 @@
};

forwardMethods(['cloneNode', 'appendChild', 'insertBefore',
'removeChild', 'replaceChild', 'setAttribute', 'removeAttribute',
'removeChild', 'replaceChild', 'setAttribute', 'removeAttribute',
'querySelector']);

var forwardProperties = function(f$) {
Expand All @@ -131,4 +153,4 @@
'lastElementChild', 'nextElementSibling', 'previousElementSibling']);

})();
</script>
</script>
1 change: 1 addition & 0 deletions test/runner.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
// 'unit/styling-cross-scope-apply.html?dom=shadow',
'unit/styling-cross-scope-unknown-host.html',
'unit/custom-style.html',
'unit/custom-style.html?dom=shadow',
'unit/custom-style-late.html',
'unit/dynamic-import.html',
'unit/templatizer.html',
Expand Down

0 comments on commit 7c20170

Please sign in to comment.