-
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(engine): fixing event target from slotted element (#359)
* fix(engine): fixing event target from slotted element * fix(engine): linting * fix(engine): linting * fix(engine): pr fixes
- Loading branch information
1 parent
01c7eb8
commit 594e508
Showing
14 changed files
with
110 additions
and
9 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
3 changes: 3 additions & 0 deletions
3
...tegration/src/components/events/test-slotted-custom-element-event-target/child/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> | ||
Child | ||
</template> |
5 changes: 5 additions & 0 deletions
5
...integration/src/components/events/test-slotted-custom-element-event-target/child/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 Child extends Element { | ||
|
||
} |
6 changes: 6 additions & 0 deletions
6
...gration/src/components/events/test-slotted-custom-element-event-target/parent/parent.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,6 @@ | ||
<template> | ||
<div onclick={handleClick}> | ||
<slot></slot> | ||
</div> | ||
<div class="correct-event-target" if:true={eventTargetIsCorrectTag}>Event target is correct</div> | ||
</template> |
8 changes: 8 additions & 0 deletions
8
...tegration/src/components/events/test-slotted-custom-element-event-target/parent/parent.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,8 @@ | ||
import { Element, track } from 'engine'; | ||
|
||
export default class XParent extends Element { | ||
@track eventTargetIsCorrectTag = false; | ||
handleClick(evt) { | ||
this.eventTargetIsCorrectTag = evt.target.tagName === 'X-CHILD'; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...ents/test-slotted-custom-element-event-target/slotted-custom-element-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,16 @@ | ||
const assert = require('assert'); | ||
|
||
describe('Event target in slot elements', () => { | ||
const URL = 'http://localhost:4567/slotted-custom-element-event-target/'; | ||
|
||
before(() => { | ||
browser.url(URL); | ||
}); | ||
|
||
it('should receive event with correct target', function () { | ||
browser.execute(function () { | ||
document.querySelector('x-child').click(); | ||
}); | ||
assert.strictEqual(browser.getText('.correct-event-target'), 'Event target is correct'); | ||
}); | ||
}); |
5 changes: 5 additions & 0 deletions
5
...event-target/slotted-custom-element-event-target/slotted-custom-element-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,5 @@ | ||
<template> | ||
<x-parent> | ||
<x-child></x-child> | ||
</x-parent> | ||
</template> |
5 changes: 5 additions & 0 deletions
5
...t-event-target/slotted-custom-element-event-target/slotted-custom-element-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 SlottedElementEventTarget extends Element { | ||
|
||
} |
6 changes: 6 additions & 0 deletions
6
...tegration/src/components/events/test-slotted-native-element-event-target/child/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,6 @@ | ||
<template> | ||
<div class="div-click" onclick={handleClick}> | ||
<slot></slot> | ||
</div> | ||
<div class="correct-event-target" if:true={eventTargetIsPTag}>Event target is correct</div> | ||
</template> |
8 changes: 8 additions & 0 deletions
8
...integration/src/components/events/test-slotted-native-element-event-target/child/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,8 @@ | ||
import { Element, track } from 'engine'; | ||
|
||
export default class Child extends Element { | ||
@track eventTargetIsPTag = false; | ||
handleClick(evt) { | ||
this.eventTargetIsPTag = evt.target.tagName === 'P'; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...ents/test-slotted-native-element-event-target/slotted-native-element-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,16 @@ | ||
const assert = require('assert'); | ||
|
||
describe('Event target in slot elements', () => { | ||
const URL = 'http://localhost:4567/slotted-native-element-event-target/'; | ||
|
||
before(() => { | ||
browser.url(URL); | ||
}); | ||
|
||
it('should receive event with correct target', function () { | ||
browser.execute(function () { | ||
document.querySelector('p').click(); | ||
}); | ||
assert.strictEqual(browser.getText('.correct-event-target'), 'Event target is correct'); | ||
}); | ||
}); |
5 changes: 5 additions & 0 deletions
5
...event-target/slotted-native-element-event-target/slotted-native-element-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,5 @@ | ||
<template> | ||
<x-child> | ||
<p>Click Me</p> | ||
</x-child> | ||
</template> |
5 changes: 5 additions & 0 deletions
5
...t-event-target/slotted-native-element-event-target/slotted-native-element-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 SlottedElementEventTarget extends Element { | ||
|
||
} |