Skip to content

Commit 2dfdd7b

Browse files
committed
Make sure event.path is an array
Can be a NodeList on older Chromes
1 parent 8066919 commit 2dfdd7b

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

‎src/lib/dom-api-event.html‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@
4242
},
4343

4444
get path() {
45-
return this.event.path;
45+
var path = this.event.path;
46+
if (!Array.isArray(path)) {
47+
path = Array.prototype.slice.call(path);
48+
}
49+
return path;
4650
}
4751

4852
};

‎test/unit/polymer-dom.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,10 @@ suite('Polymer.dom', function() {
552552
assert.equal(path[2], re);
553553
assert.equal(path[4], rere);
554554
assert.equal(path[6], testElement);
555+
// event.path *should* be an array
556+
assert.isArray(path);
557+
assert.isFunction(path.indexOf);
558+
assert(path.indexOf(testElement) > -1);
555559
});
556560

557561
rere.addEventListener('test-event', function(e) {

0 commit comments

Comments
 (0)