Skip to content

Commit c2b92c1

Browse files
committed
Add imperative access to invoker, and connect to implicit anchor element
This includes two related changes: 1. The `showPopover()` and `togglePopover()` methods now include an options bag that allows setting the popover invoker. 2. Popover invokers (declaratively or imperatively set) now create an implicit anchor reference for that popover. This new behavior was resolved in the [WHATWG/CSSWG/OpenUI joint task force meeting on June 26, 2024](whatwg#9144 (comment)). Closes whatwg#10442 Closes whatwg#10675
1 parent 27f948a commit c2b92c1

File tree

1 file changed

+41
-10
lines changed

1 file changed

+41
-10
lines changed

source

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4192,6 +4192,12 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
41924192
<li><dfn data-x-href="https://drafts.csswg.org/css-contain/#content-visibility">'content-visibility'</dfn> property</li>
41934193
<li><dfn data-x-href="https://drafts.csswg.org/css-contain/#propdef-content-visibility" data-x="content-visibility-auto">'auto'</dfn> value for <span>'content-visibility'</span></li>
41944194
</ul>
4195+
4196+
<p>The following terms are defined in <cite>CSS Anchor Positioning</cite>: <ref>CSSANCHOR</ref></p>
4197+
4198+
<ul class="brief">
4199+
<li><dfn data-x-href="https://www.w3.org/TR/css-anchor-position-1/#implicit-anchor-element">implicit anchor element</dfn></li>
4200+
</ul>
41954201
</dd>
41964202

41974203

@@ -11924,12 +11930,21 @@ interface <dfn interface>HTMLElement</dfn> : <span>Element</span> {
1192411930
<span>ElementInternals</span> <span data-x="dom-attachInternals">attachInternals</span>();
1192511931

1192611932
// The popover API
11927-
undefined <span data-x="dom-showPopover">showPopover</span>();
11933+
undefined <span data-x="dom-showPopover">showPopover</span>(optional ShowPopoverOptions options);
1192811934
undefined <span data-x="dom-hidePopover">hidePopover</span>();
11929-
boolean <span data-x="dom-togglePopover">togglePopover</span>(optional boolean force);
11935+
boolean <span data-x="dom-togglePopover">togglePopover</span>(optional (TogglePopoverOptions or boolean) options);
1193011936
[<span>CEReactions</span>] attribute DOMString? <span data-x="dom-popover">popover</span>;
1193111937
};
1193211938

11939+
dictionary <dfn dictionary>TogglePopoverOptions</dfn> {
11940+
boolean force;
11941+
<span>HTMLElement</span> invoker;
11942+
};
11943+
11944+
dictionary <dfn dictionary>ShowPopoverOptions</dfn> {
11945+
<span>HTMLElement</span> invoker;
11946+
};
11947+
1193311948
<span>HTMLElement</span> includes <span>GlobalEventHandlers</span>;
1193411949
<span>HTMLElement</span> includes <span>ElementContentEditable</span>;
1193511950
<span>HTMLElement</span> includes <span>HTMLOrSVGElement</span>;
@@ -85447,8 +85462,10 @@ dictionary <dfn dictionary>DragEventInit</dfn> : <span>MouseEventInit</span> {
8544785462
false.</dd>
8544885463
</dl>
8544985464

85450-
<p>The <dfn method for="HTMLElement"><code data-x="dom-showPopover">showPopover()</code></dfn>
85451-
method steps are to run <span>show popover</span> given <span>this</span>, true, and null.</p>
85465+
<p>The
85466+
<dfn method for="HTMLElement"><code data-x="dom-showPopover">showPopover(<var>options</var>)</code></dfn>
85467+
method steps are to run <span>show popover</span> given <span>this</span>, true, and
85468+
<var>options</var>["<code data-x="">invoker</code>"].</p>
8545285469

8545385470
<p>To <dfn>show popover</dfn>, given an <span data-x="HTML elements">HTML element</span>
8545485471
<var>element</var>, a boolean <var>throwExceptions</var>, and an <span data-x="HTML elements">HTML
@@ -85582,6 +85599,8 @@ dictionary <dfn dictionary>DragEventInit</dfn> : <span>MouseEventInit</span> {
8558285599

8558385600
<li><p>Set <var>element</var>'s <span>popover invoker</span> to <var>invoker</var>.</p></li>
8558485601

85602+
<li><p>Set <var>element</var>'s <span>implicit anchor element</span> to <var>invoker</var>.</p></li>
85603+
8558585604
<li><p>Run the <span>popover focusing steps</span> given <var>element</var>.</p></li>
8558685605

8558785606
<li><p>If <var>shouldRestoreFocus</var> is true and <var>element</var>'s <code
@@ -85732,6 +85751,8 @@ dictionary <dfn dictionary>DragEventInit</dfn> : <span>MouseEventInit</span> {
8573285751

8573385752
<li><p><span>Request an element to be removed from the top layer</span> given
8573485753
<var>element</var>.</p></li>
85754+
85755+
<li><p>Set <var>element</var>'s <span>implicit anchor element</span> to null.</p></li>
8573585756
</ol>
8573685757
</li>
8573785758

@@ -85766,16 +85787,23 @@ dictionary <dfn dictionary>DragEventInit</dfn> : <span>MouseEventInit</span> {
8576685787
</ol>
8576785788

8576885789
<p>The <dfn method for="HTMLElement"><code
85769-
data-x="dom-togglePopover">togglePopover(<var>force</var>)</code></dfn> method steps are:</p>
85790+
data-x="dom-togglePopover">togglePopover(<var>options</var>)</code></dfn> method steps are:</p>
8577085791

8577185792
<ol>
85793+
<!-- TODO: I'm not sure what the correct way to handle a tri-state like this. This is generally
85794+
just trying to make it cleaner to use `force` in the algorithm. -->
85795+
<li><p>Let <var>force</var> be one of true, false, or unset, initially unset.</p></li>
85796+
85797+
<li><p>If <var>options</var> is a boolean, set <var>force</var> to <var>options</var>. Otherwise,
85798+
if <var>options</var>["<code data-x="">force</code>"] <span data-x="map exists">exists</span>,
85799+
set <var>force</var> to <var>options</var>["<code data-x="">force</code>"].</p></li>
85800+
8577285801
<li><p>If <span>this</span>'s <span>popover visibility state</span> is <span
85773-
data-x="popover-showing-state">showing</span>, and <var>force</var> is not present or false, then
85774-
run the <span>hide popover algorithm</span> given <span>this</span>, true, true, and
85775-
true.</p></li>
85802+
data-x="popover-showing-state">showing</span>, and <var>force</var> is unset or false, then run
85803+
the <span>hide popover algorithm</span> given <span>this</span>, true, true, and true.</p></li>
8577685804

85777-
<li><p>Otherwise, if <var>force</var> is not present or true, then run <span>show popover</span>
85778-
given <span>this</span>, true, and null.</p></li>
85805+
<li><p>Otherwise, if <var>force</var> is unset or true, then run <span>show popover</span> given
85806+
<span>this</span>, true, and <var>options</var>["<code data-x="">invoker</code>"].</p></li>
8577985807

8578085808
<li>
8578185809
<p>Otherwise:</p>
@@ -144093,6 +144121,9 @@ INSERT INTERFACES HERE
144093144121
<dt id="refsCSSALIGN">[CSSALIGN]</dt>
144094144122
<dd><cite><a href="https://w3c.github.io/csswg-drafts/css-align/">CSS Box Alignment</a></cite>, E. Etemad, T. Atkins. W3C.</dd>
144095144123

144124+
<dt id="refsCSSANCHOR">[CSSANCHOR]</dt>
144125+
<dd><cite><a href="https://www.w3.org/TR/css-anchor-position-1/">CSS Anchor Positioning</a></cite>, T. Atkins, E. Etemad, I. Kilpatrick. W3C.</dd>
144126+
144096144127
<dt id="refsCSSANIMATIONS">[CSSANIMATIONS]</dt>
144097144128
<dd><cite><a href="https://w3c.github.io/csswg-drafts/css-animations/">CSS Animations</a></cite>, D. Jackson, D. Hyatt, C. Marrin, S. Galineau, L. Baron. W3C.</dd>
144098144129

0 commit comments

Comments
 (0)