Skip to content

Commit

Permalink
Implement labels attribute of ElementInternals
Browse files Browse the repository at this point in the history
Differential Revision: https://phabricator.services.mozilla.com/D126130

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1556373
gecko-commit: f81d199dac44b846d3900de9abb6ec88d0c0ea69
gecko-reviewers: smaug
  • Loading branch information
EdgarChen authored and moz-wptsync-bot committed Oct 7, 2021
1 parent c01f637 commit b63a9c7
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions custom-elements/form-associated/ElementInternals-labels.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
const labels = container.querySelectorAll('label');
control = container.querySelector('my-control');
assert_array_equals(control.i.labels, labels);

container.innerHTML = '<my-control></my-control>';
control = container.querySelector('my-control');
assert_array_equals(control.i.labels, []);
}, 'LABEL association');

test(() => {
Expand All @@ -46,5 +50,14 @@
container.querySelector('label').click();
assert_equals(clickCount, 1);
}, 'LABEL click');

test(() => {
class NotFormAssociatedElement extends HTMLElement {}
customElements.define('not-form-associated-element', NotFormAssociatedElement);
const element = new NotFormAssociatedElement();
const i = element.attachInternals();
assert_throws_dom('NotSupportedError', () => i.labels);
}, "ElementInternals.labels should throw NotSupportedError if the target element is not a form-associated custom element");

</script>
</body>

0 comments on commit b63a9c7

Please sign in to comment.