-
Notifications
You must be signed in to change notification settings - Fork 400
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: event retargeting issue with nested component (#338)
* fix: event retrageting issue with nested component * test(engine): integration test for shadow root retargeting * docs: add back removed comment
- Loading branch information
Showing
9 changed files
with
118 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
.../src/components/events/test-root-listener-event-target/root-listener-event-target.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const assert = require('assert'); | ||
|
||
describe('Event target in slot elements', () => { | ||
const URL = 'http://localhost:4567/root-listener-event-target/'; | ||
|
||
before(() => { | ||
browser.url(URL); | ||
}); | ||
|
||
it('should receive event with correct target', function () { | ||
const element = browser.element('x-grand-child'); | ||
element.click(); | ||
|
||
const verifyElement = browser.element('.event-target-correct'); | ||
assert.strictEqual(verifyElement.getText(), 'Event Target is correct element'); | ||
}); | ||
}); |
3 changes: 3 additions & 0 deletions
3
...est-root-listener-event-target/root-listener-event-target/root-listener-event-target.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<template> | ||
<x-child></x-child> | ||
</template> |
5 changes: 5 additions & 0 deletions
5
.../test-root-listener-event-target/root-listener-event-target/root-listener-event-target.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Element } from 'engine'; | ||
|
||
export default class RootListenerEventTarget extends Element { | ||
|
||
} |
4 changes: 4 additions & 0 deletions
4
...wc-integration/src/components/events/test-root-listener-event-target/x-child/x-child.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<template> | ||
<x-grand-child></x-grand-child> | ||
<div class="event-target-correct" if:true={eventTargetIsCorrect}>Event Target is correct element</div> | ||
</template> |
11 changes: 11 additions & 0 deletions
11
.../lwc-integration/src/components/events/test-root-listener-event-target/x-child/x-child.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Element, track } from 'engine'; | ||
|
||
export default class Child extends Element { | ||
@track eventTargetIsCorrect = false; | ||
|
||
connectedCallback() { | ||
this.template.addEventListener('click', (evt) => { | ||
this.eventTargetIsCorrect = evt.target.tagName === 'X-GRAND-CHILD'; | ||
}); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...on/src/components/events/test-root-listener-event-target/x-grand-child/x-grand-child.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<template> | ||
Click me | ||
</template> |
5 changes: 5 additions & 0 deletions
5
...tion/src/components/events/test-root-listener-event-target/x-grand-child/x-grand-child.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Element } from 'engine'; | ||
|
||
export default class GrandChild extends Element { | ||
|
||
} |