Skip to content

Commit

Permalink
Remove togglePopover() supports boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
hamishwillee committed Jul 17, 2023
1 parent 2aedb6e commit 1ebe729
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions files/en-us/web/api/htmlelement/togglepopover/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ togglePopover(force)

### Return value

None ({{jsxref("undefined")}}).

<!-- Spec requirement - from undefined to boolean. Waiting on implementation such as https://bugzilla.mozilla.org/show_bug.cgi?id=1842845
`true` if the popup is open after the call, and `false` otherwise.
{{jsxref("undefined")}} may be returned in older browsers (see [browser compatibility](#browser_compatibility)).
-->

## Examples

Expand Down Expand Up @@ -92,19 +96,24 @@ We also log whether the popup was open or closed after the call, but only if a `
if (HTMLElement.prototype.hasOwnProperty("popover")) {
document.addEventListener("keydown", (event) => {
if (event.key === "h") {
popover.togglePopover();
}
});
}
```

<!-- modifications to code once togglePopover() returns boolean
const popupOpened = popover.togglePopover();
// If not undefined, you can check if popover is opened or closed.
console.log(`popupOpened: ${popupOpened}`)
if (popupOpened === true) instructions.innerText += `\nOpened`;
if (popupOpened === false) instructions.innerText += `\nClosed`;
}
});
}
```
-->

You can test this out using the live example below.

{{EmbedLiveSample('Examples', 700, 300)}}
{{EmbedLiveSample('Examples', 700, 290)}}

## Specifications

Expand Down

0 comments on commit 1ebe729

Please sign in to comment.