Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Event path should return every nodes in the event path
Browse files Browse the repository at this point in the history
  • Loading branch information
arv committed May 29, 2014
1 parent 79acf9a commit 2695aa7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
22 changes: 4 additions & 18 deletions src/wrappers/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,25 +475,11 @@
return eventPhaseTable.get(this);
},
get path() {
var nodeList = new wrappers.NodeList();
var eventPath = eventPathTable.get(this);
if (eventPath) {
var index = 0;
var lastIndex = eventPath.length - 1;
var baseRoot = getTreeScope(currentTargetTable.get(this));

for (var i = 0; i <= lastIndex; i++) {
var currentTarget = eventPath[i];
var currentRoot = getTreeScope(currentTarget);
if (currentRoot.contains(baseRoot) &&
// Make sure we do not add Window to the path.
(i !== lastIndex || currentTarget instanceof wrappers.Node)) {
nodeList[index++] = currentTarget;
}
}
nodeList.length = index;
}
return nodeList;
if (!eventPath)
return [];
// TODO(arv): Event path should contain window.
return eventPath.slice();
},
stopPropagation: function() {
stopPropagationTable.set(this, true);
Expand Down
9 changes: 9 additions & 0 deletions test/js/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,9 @@ test('retarget order (multiple shadow roots)', function() {
[
tree.c,
tree.content,
tree.content2,
tree.e,
tree.sr2,
tree.d,
tree.sr,
tree.b,
Expand All @@ -1209,6 +1212,12 @@ test('retarget order (multiple shadow roots)', function() {
assertArrayEqual(
[
tree.c,
tree.content,
tree.content2,
tree.e,
tree.sr2,
tree.d,
tree.sr,
tree.b,
tree.a,
tree.div,
Expand Down

0 comments on commit 2695aa7

Please sign in to comment.