Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions ElementInternalsType/explainer.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,17 @@ class CustomButton extends HTMLElement {
const command = this.getAttribute('command');
const target = document.getElementById(targetId);

if (target) {
if (target) {
// Create and fire command event at the target element
const commandEvent = new CommandEvent('command', {
bubbles: true,
cancelable: true
command: command,
});
// Don't commit the action if `.preventDefault()` was called
if (!target.dispatchEvent(commandEvent)) {
return;
}
if (command === "toggle-popover") {
target.togglePopover();
} else if (command === "show-popover") {
Expand All @@ -177,14 +187,6 @@ class CustomButton extends HTMLElement {
} else if (command === "request-close") {
target.requestClose()
}

// Create and fire command event at the target element
const commandEvent = new CustomEvent('command', {
bubbles: true,
cancelable: true
});
commandEvent.command = command;
target.dispatchEvent(commandEvent);
}
}
}
Expand Down Expand Up @@ -672,4 +674,5 @@ Many thanks for valuable feedback and advice from:
- [Leo Lee](https://github.com/leotlee)
- [Open UI Community Group](https://www.w3.org/community/open-ui/)
- [WHATWG](https://whatwg.org/)
- [ARIA Working Group](https://www.w3.org/WAI/about/groups/ariawg/)

- [ARIA Working Group](https://www.w3.org/WAI/about/groups/ariawg/)