Skip to content

Commit 4926f1d

Browse files
ziransunmoz-wptsync-bot
authored andcommitted
Remove the popovertarget attribute or set it to an invalid value should clear the explicitly set attr-element.
Differential Revision: https://phabricator.services.mozilla.com/D201711 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1879001 gecko-commit: 6f0ebcced75f999a360fdd4f2e00d66fe811dc84 gecko-reviewers: emilio
1 parent 2492b90 commit 4926f1d

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed
Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,53 @@
11
<!DOCTYPE html>
22
<link rel=author href="mailto:[email protected]">
33
<link rel=help href="https://bugs.chromium.org/p/chromium/issues/detail?id=1523410">
4+
<link rel=help href="https://bugzilla.mozilla.org/show_bug.cgi?id=1879001">
45
<link rel=help href="https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#reflecting-content-attributes-in-idl-attributes:element">
56
<script src="/resources/testharness.js"></script>
67
<script src="/resources/testharnessreport.js"></script>
78

8-
<button id=mybutton>toggle popover</button>
9+
<button id=mybutton popovertarget="mypopover">toggle popover</button>
910
<div id=mypopover popover=auto>popover</div>
1011

1112
<script>
1213
test(() => {
14+
assert_equals(mybutton.popoverTargetElement.id, "mypopover",
15+
'Setting element.popoverTargetElement to a valid element should work');
16+
17+
mybutton.popoverTargetElement = null;
18+
assert_false(mybutton.hasAttribute('popovertarget'),
19+
'Setting element.popoverTargetElement to null should unset popovertarget attribute.');
20+
assert_equals(mybutton.popoverTargetElement, null,
21+
'Setting element.popoverTargetElement to null should remove the existing element from element.popoverTargetElement.');
22+
1323
mybutton.popoverTargetElement = mypopover;
1424
assert_true(mybutton.hasAttribute('popovertarget'),
1525
'Assigning to element.popoverTargetElement should set the popovertarget attribute.');
1626

1727
mybutton.removeAttribute('popovertarget');
1828
assert_equals(mybutton.popoverTargetElement, null,
1929
'Removing the popovertarget attribute should remove the element from element.popoverTargetElement.');
30+
31+
mybutton.popoverTargetElement = mypopover;
32+
assert_true(mybutton.hasAttribute('popovertarget'),
33+
'Assigning to element.popoverTargetElement should set the popovertarget attribute.');
34+
35+
mybutton.setAttribute("popovertarget", 'invalid');
36+
assert_equals(mybutton.popoverTargetElement, null,
37+
'Setting the popovertarget attribute to a localName that is not attr should remove the existing element from element.popoverTargetElement.');
38+
39+
mybutton.popoverTargetElement = mypopover;
40+
mybutton.setAttribute("popovertarget", "");
41+
assert_equals(mybutton.popoverTargetElement.id, "mypopover",
42+
'Setting the popovertarget attribute to empty string right after explicitly setting attribute element should have no effect.');
43+
44+
mybutton.setAttribute("popovertarget", "mypopover");
45+
assert_equals(mybutton.popoverTargetElement.id, "mypopover",
46+
'Setting the popovertarget attribute to a value should set the popover target element.');
47+
mybutton.setAttribute("popovertarget", "");
48+
assert_equals(mybutton.getAttribute('popovertarget'), "",
49+
'Assigning to element.popoverTargetElement to empty string should update the attribute value to empty string.');
50+
assert_equals(mybutton.popoverTargetElement, null,
51+
'Setting the popovertarget attribute to empty string should remove the existing element from element.popoverTargetElement.');
2052
}, 'Element attribute reflection of popoverTargetElement/popovertarget should be kept in sync.');
2153
</script>

0 commit comments

Comments
 (0)