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

Commit 6c4490e

Browse files
committed
Merge pull request #453 from azakus/fix-efp
Scope elementFromPoint to the current TreeScope
2 parents 565320e + 92cd922 commit 6c4490e

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/wrappers/events.js

+9
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,15 @@
815815
if (!element)
816816
return null;
817817
var path = getEventPath(element, null);
818+
819+
// scope the path to this TreeScope
820+
var idx = path.lastIndexOf(self);
821+
if (idx == -1)
822+
return null;
823+
else
824+
path = path.slice(0, idx);
825+
826+
// TODO(dfreedm): pass idx to eventRetargetting to avoid array copy
818827
return eventRetargetting(path, self);
819828
}
820829

test/js/ShadowRoot.js

+4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ suite('ShadowRoot', function() {
2424
'background: green';
2525

2626
assert.equal(sr.elementFromPoint(5, 5), a);
27+
28+
var sr2 = a.createShadowRoot();
29+
assert.equal(sr.elementFromPoint(5, 5), a);
30+
assert.equal(sr2.elementFromPoint(5, 5), null);
2731
});
2832

2933
test('getElementById', function() {

0 commit comments

Comments
 (0)