3 <link rel=
"author" href=
"mailto:masonf@chromium.org">
4 <link rel=help
href=
"https://open-ui.org/components/popover.research.explainer">
5 <link rel=help
href=
"https://html.spec.whatwg.org/multipage/popover.html">
6 <script src=
"/resources/testharness.js"></script>
7 <script src=
"/resources/testharnessreport.js"></script>
9 <button id=b1
>This is an anchor button
</button>
10 <div popover id=p1 anchor=b1
>This is a popover
</div>
11 <button id=b2 popovertarget=p1
>This button invokes the popover but isn't an anchor
</button>
15 assert_equals(p1
.anchorElement
,b1
);
16 }, "popover anchorElement IDL property returns the anchor element");
19 assert_equals(p1
.anchorElement
,b1
);
20 p1
.anchorElement
= b2
;
21 assert_equals(p1
.anchorElement
,b2
);
22 assert_equals(p1
.getAttribute('anchor'),'','Idref is empty after setting element');
23 p1
.anchorElement
= b1
; // Reset
24 }, "popover anchorElement is settable");
27 <button id=b1
>button
</button>
28 <div id=p2
>Anchored div
</div>
30 * {margin:
0;padding:
0;}
40 assert_equals(p2
.anchorElement
,null);
41 const button
= document
.getElementById('b1');
42 assert_true(!!button
);
43 p2
.anchorElement
= button
;
44 assert_equals(p2
.getAttribute('anchor'),'','Idref should be empty after setting element');
45 assert_equals(p2
.anchorElement
,button
,'Element reference should be button');
46 assert_equals(p2
.offsetLeft
, 200, 'The anchor relationship should be functional');
47 }, "anchorElement affects anchor positioning");