Skip to content

Commit

Permalink
For consistency, make sure Polymer.dom(node).childNodes always return…
Browse files Browse the repository at this point in the history
…s an array. Helps address #1367.
  • Loading branch information
sorvell committed Apr 9, 2015
1 parent ba365fc commit 82882e6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib/dom-api.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
},

get childNodes() {
return getLightChildren(this.node);
var c$ = getLightChildren(this.node);
return Array.isArray(c$) ? c$ : Array.prototype.slice.call(c$);
},

get children() {
Expand Down Expand Up @@ -396,9 +397,8 @@
}
n = n.parentNode;
}

};

}

var CONTENT = 'content';
Expand Down
4 changes: 4 additions & 0 deletions test/unit/polymer-dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,4 +293,8 @@ suite('Polymer.dom', function() {
assert.equal(eventHandled, 2);
});

test('Polymer.dom.childNodes is an array', function() {
assert.isTrue(Array.isArray(Polymer.dom(document.body).childNodes));
});

});

0 comments on commit 82882e6

Please sign in to comment.