From a353297cbaa6701662ffc652e02ebf76c472915d Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Sat, 7 Dec 2024 14:52:49 +0000 Subject: [PATCH 1/4] Add imperative invoker updates to popover API - showPopover and togglePopover can now take an options parameter. --- files/en-us/web/api/htmlelement/showpopover/index.md | 8 ++++++-- .../en-us/web/api/htmlelement/togglepopover/index.md | 12 +++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/files/en-us/web/api/htmlelement/showpopover/index.md b/files/en-us/web/api/htmlelement/showpopover/index.md index c94a9da9db106bd..047373999e97fe1 100644 --- a/files/en-us/web/api/htmlelement/showpopover/index.md +++ b/files/en-us/web/api/htmlelement/showpopover/index.md @@ -15,12 +15,16 @@ When `showPopover()` is called on an element with the [`popover`](/en-US/docs/We ## Syntax ```js-nolint -showPopover() +showPopover(options) ``` ### Parameters -None. +- `options` {{optional_inline}} + - : An object with the following properties: + - `source` {{optional_inline}} + - An {{domxref("HTMLElement")}} that triggered the popover, if any. This provides all the same functionality that using + [`popovertarget`](/en-US/docs/Web/HTML/Element/button#popovertarget) would provide. ### Return value diff --git a/files/en-us/web/api/htmlelement/togglepopover/index.md b/files/en-us/web/api/htmlelement/togglepopover/index.md index 0bc696cd1599f1d..a6e5a1de4de2c56 100644 --- a/files/en-us/web/api/htmlelement/togglepopover/index.md +++ b/files/en-us/web/api/htmlelement/togglepopover/index.md @@ -22,14 +22,24 @@ When `togglePopover()` is called on an element with the [`popover`](/en-US/docs/ ```js-nolint togglePopover(force) +togglePopover(options) ``` ### Parameters -- `force` +- `force` {{optional_inline}} - : A boolean, which causes `togglePopover()` to behave like {{domxref("HTMLElement.showPopover", "showPopover()")}} or {{domxref("HTMLElement.hidePopover", "hidePopover()")}}, except that it doesn't throw an exception if the popover is already in the target state. - If set to `true`, the popover is shown if it was initially hidden. If it was initially shown, nothing happens. - If set to `false`, the popover is hidden if it was initially shown. If it was initially hidden, nothing happens. +- `options` {{optional_inline}} + - : An object with the following properties: + - `force` {{optional_inline}} + - : A boolean, which causes `togglePopover()` to behave like {{domxref("HTMLElement.showPopover", "showPopover()")}} or {{domxref("HTMLElement.hidePopover", "hidePopover()")}}, except that it doesn't throw an exception if the popover is already in the target state. + - If set to `true`, the popover is shown if it was initially hidden. If it was initially shown, nothing happens. + - If set to `false`, the popover is hidden if it was initially shown. If it was initially hidden, nothing happens. + - `source` {{optional_inline}} + - An {{domxref("HTMLElement")}} that triggered the popover, if any. This provides all the same functionality that using + [`popovertarget`](/en-US/docs/Web/HTML/Element/button#popovertarget) would provide. ### Return value From 56f91b89e7ac6e30b796b2a8859237b1f03b8016 Mon Sep 17 00:00:00 2001 From: Hamish Willee Date: Mon, 9 Dec 2024 12:26:08 +1100 Subject: [PATCH 2/4] fix arbitrary line breaks --- files/en-us/web/api/htmlelement/showpopover/index.md | 4 ++-- files/en-us/web/api/htmlelement/togglepopover/index.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/files/en-us/web/api/htmlelement/showpopover/index.md b/files/en-us/web/api/htmlelement/showpopover/index.md index 047373999e97fe1..e6e7ca38eecd373 100644 --- a/files/en-us/web/api/htmlelement/showpopover/index.md +++ b/files/en-us/web/api/htmlelement/showpopover/index.md @@ -23,8 +23,8 @@ showPopover(options) - `options` {{optional_inline}} - : An object with the following properties: - `source` {{optional_inline}} - - An {{domxref("HTMLElement")}} that triggered the popover, if any. This provides all the same functionality that using - [`popovertarget`](/en-US/docs/Web/HTML/Element/button#popovertarget) would provide. + - An {{domxref("HTMLElement")}} that triggered the popover, if any. + This provides all the same functionality that using [`popovertarget`](/en-US/docs/Web/HTML/Element/button#popovertarget) would provide. ### Return value diff --git a/files/en-us/web/api/htmlelement/togglepopover/index.md b/files/en-us/web/api/htmlelement/togglepopover/index.md index a6e5a1de4de2c56..547591dcbafdf6f 100644 --- a/files/en-us/web/api/htmlelement/togglepopover/index.md +++ b/files/en-us/web/api/htmlelement/togglepopover/index.md @@ -38,8 +38,8 @@ togglePopover(options) - If set to `true`, the popover is shown if it was initially hidden. If it was initially shown, nothing happens. - If set to `false`, the popover is hidden if it was initially shown. If it was initially hidden, nothing happens. - `source` {{optional_inline}} - - An {{domxref("HTMLElement")}} that triggered the popover, if any. This provides all the same functionality that using - [`popovertarget`](/en-US/docs/Web/HTML/Element/button#popovertarget) would provide. + - An {{domxref("HTMLElement")}} that triggered the popover, if any. + This provides all the same functionality that using [`popovertarget`](/en-US/docs/Web/HTML/Element/button#popovertarget) would provide. ### Return value From 5e15b52221b411745de67bb31207f46e81dafd4e Mon Sep 17 00:00:00 2001 From: Hamish Willee Date: Mon, 9 Dec 2024 12:42:37 +1100 Subject: [PATCH 3/4] Fix definition lists --- files/en-us/web/api/htmlelement/showpopover/index.md | 5 +++-- files/en-us/web/api/htmlelement/togglepopover/index.md | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/files/en-us/web/api/htmlelement/showpopover/index.md b/files/en-us/web/api/htmlelement/showpopover/index.md index e6e7ca38eecd373..2e27e5554c8f73d 100644 --- a/files/en-us/web/api/htmlelement/showpopover/index.md +++ b/files/en-us/web/api/htmlelement/showpopover/index.md @@ -10,7 +10,8 @@ browser-compat: api.HTMLElement.showPopover The **`showPopover()`** method of the {{domxref("HTMLElement")}} interface shows a {{domxref("Popover_API", "popover", "", "nocode")}} element (i.e. one that has a valid [`popover`](/en-US/docs/Web/HTML/Global_attributes/popover) attribute) by adding it to the {{glossary("top layer")}}. -When `showPopover()` is called on an element with the [`popover`](/en-US/docs/Web/HTML/Global_attributes/popover) attribute that is currently hidden, a {{domxref("HTMLElement/beforetoggle_event", "beforetoggle")}} event will be fired, followed by the popover showing, and then the {{domxref("HTMLElement/toggle_event", "toggle")}} event firing. If the element is already showing, an error will be thrown. +When `showPopover()` is called on an element with the [`popover`](/en-US/docs/Web/HTML/Global_attributes/popover) attribute that is currently hidden, a {{domxref("HTMLElement/beforetoggle_event", "beforetoggle")}} event will be fired, followed by the popover showing, and then the {{domxref("HTMLElement/toggle_event", "toggle")}} event firing. +If the element is already showing, an error will be thrown. ## Syntax @@ -23,7 +24,7 @@ showPopover(options) - `options` {{optional_inline}} - : An object with the following properties: - `source` {{optional_inline}} - - An {{domxref("HTMLElement")}} that triggered the popover, if any. + - : An {{domxref("HTMLElement")}} that triggered the popover, if any. This provides all the same functionality that using [`popovertarget`](/en-US/docs/Web/HTML/Element/button#popovertarget) would provide. ### Return value diff --git a/files/en-us/web/api/htmlelement/togglepopover/index.md b/files/en-us/web/api/htmlelement/togglepopover/index.md index 547591dcbafdf6f..ab0d249fb7fadfb 100644 --- a/files/en-us/web/api/htmlelement/togglepopover/index.md +++ b/files/en-us/web/api/htmlelement/togglepopover/index.md @@ -21,6 +21,7 @@ When `togglePopover()` is called on an element with the [`popover`](/en-US/docs/ ## Syntax ```js-nolint +togglePopover() togglePopover(force) togglePopover(options) ``` @@ -32,13 +33,15 @@ togglePopover(options) - If set to `true`, the popover is shown if it was initially hidden. If it was initially shown, nothing happens. - If set to `false`, the popover is hidden if it was initially shown. If it was initially hidden, nothing happens. - `options` {{optional_inline}} + - : An object with the following properties: + - `force` {{optional_inline}} - : A boolean, which causes `togglePopover()` to behave like {{domxref("HTMLElement.showPopover", "showPopover()")}} or {{domxref("HTMLElement.hidePopover", "hidePopover()")}}, except that it doesn't throw an exception if the popover is already in the target state. - If set to `true`, the popover is shown if it was initially hidden. If it was initially shown, nothing happens. - If set to `false`, the popover is hidden if it was initially shown. If it was initially hidden, nothing happens. - `source` {{optional_inline}} - - An {{domxref("HTMLElement")}} that triggered the popover, if any. + - : An {{domxref("HTMLElement")}} that triggered the popover, if any. This provides all the same functionality that using [`popovertarget`](/en-US/docs/Web/HTML/Element/button#popovertarget) would provide. ### Return value From ac996b06d6489238386924652aaccd65f0327043 Mon Sep 17 00:00:00 2001 From: Hamish Willee Date: Mon, 9 Dec 2024 12:44:26 +1100 Subject: [PATCH 4/4] Update files/en-us/web/api/htmlelement/showpopover/index.md --- files/en-us/web/api/htmlelement/showpopover/index.md | 1 + 1 file changed, 1 insertion(+) diff --git a/files/en-us/web/api/htmlelement/showpopover/index.md b/files/en-us/web/api/htmlelement/showpopover/index.md index 2e27e5554c8f73d..4c34bbc84db3359 100644 --- a/files/en-us/web/api/htmlelement/showpopover/index.md +++ b/files/en-us/web/api/htmlelement/showpopover/index.md @@ -16,6 +16,7 @@ If the element is already showing, an error will be thrown. ## Syntax ```js-nolint +showPopover() showPopover(options) ```