Replace support for event.path.

This commit is contained in:
Steven Orvell
2016-09-26 10:49:52 -07:00
parent 4db55ea588
commit dc52cafb1e
2 changed files with 22 additions and 0 deletions

View File

@@ -320,6 +320,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
get localTarget() {
return this.event.target;
}
get path() {
return this.event.composedPath();
}
}
Polymer.dom = function(obj) {

View File

@@ -253,6 +253,24 @@ suite('ShadyDOM event patching', function() {
assert.equal(el.events[0], el.$.child);
assert.equal(el.events[1], el);
});
test('Polymer.dom events', function(done) {
var el = fixture('scoped');
el.addEventListener('composed', function(e) {
assert.equal(Polymer.dom(e).rootTarget, el.$.scoped);
assert.equal(Polymer.dom(e).localTarget, el);
let nodes = [];
let p = el.$.scoped;
while (p) {
nodes.push(p);
p = p.parentNode || p.host;
}
nodes.push(window);
assert.deepEqual(Array.from(Polymer.dom(e).path), nodes);
done();
});
el.fireComposed();
});
});
</script>
</body>