-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix active element detection in shadow root (#25)
Co-authored-by: Keith Cirkel <keithamus@users.noreply.github.com>
- Loading branch information
1 parent
77e88f4
commit 56a3fe9
Showing
3 changed files
with
57 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
export class WrapperComponent extends HTMLElement { | ||
constructor() { | ||
super() | ||
const shadow = this.attachShadow({mode: 'open'}) | ||
const textExpander = document.createElement('text-expander') | ||
textExpander.setAttribute('keys', '@') | ||
const textarea = document.createElement('textarea') | ||
textExpander.append(textarea) | ||
shadow.appendChild(textExpander) | ||
} | ||
|
||
connectedCallback() { | ||
const textExpander = this.shadowRoot.querySelector('text-expander') | ||
textExpander.addEventListener('text-expander-change', function (event) { | ||
const {key, provide} = event.detail | ||
|
||
if (key !== '@') return | ||
|
||
const suggestions = document.createElement('ul') | ||
suggestions.innerHTML = ` | ||
<li role="option" data-value="a">a</li> | ||
<li role="option" data-value="aa">aa</li> | ||
` | ||
provide(Promise.resolve({matched: true, fragment: suggestions})) | ||
}) | ||
} | ||
} |
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