-
Notifications
You must be signed in to change notification settings - Fork 22.8k
Technical review: Document the ToggleEvent.source property #40533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Can I get a tech review, please, @josepharhar? I'm on vacation for a week next week, so there might be a bit of a delay getting it merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for writing this!
@@ -29,6 +29,8 @@ _This interface inherits properties from its parent, {{DOMxRef("Event")}}._ | |||
- : A string (either `"open"` or `"closed"`), representing the state the element is transitioning to. | |||
- {{DOMxRef("ToggleEvent.oldState")}} {{ReadOnlyInline}} | |||
- : A string (either `"open"` or `"closed"`), representing the state the element is transitioning from. | |||
- {{DOMxRef("ToggleEvent.source")}} {{Experimental_Inline}} {{ReadOnlyInline}} | |||
- : An {{domxref("Element")}} object instance representing the HTML control that initiated the toggle. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ToggleEvent.source may be null, for example if you just call popover.showPopover() from script. Not sure if this is worth mentioning here.
|
||
The **`source`** read-only property of the {{domxref("ToggleEvent")}} interface is an {{domxref("Element")}} object instance representing the HTML popover control element that initiated the toggle. | ||
|
||
A {{htmlelement("button")}} or `<input type="button">` element can be specified as a popover control by specifying the [`id`](/en-US/docs/Web/HTML/Reference/Global_attributes/id) of the popover element in its [`commandfor`](/en-US/docs/Web/HTML/Reference/Elements/button#commandfor) or [`popovertarget`](/en-US/docs/Web/HTML/Reference/Elements/button#popovertarget) attribute. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think command attribute work on <input type=button>
?
|
||
## Value | ||
|
||
An {{domxref("Element")}} object instance, or `null` if the popover does not have a control element (for example, if the popover is being controlled using a JavaScript method such as {{domxref("HTMLElement.togglePopover()")}}). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of saying "if the popover does not have a control element" id say "if the popover was not triggered (or activated?) by a control element"
In this example, the popover does have a control element but the ToggleEvent fired will have a null source:
<button commandfor=popover command=show-popover>control</button>
<div id=popover popover=auto>popover</div>
<script>
popover.showPopover();
</script>
Description
Chrome 140 adds support for the
ToggleEvent.source
property. See #39723 for details.This PR adds documentation for the new property.
Motivation
Additional details
Related issues and pull requests
Fixes #39723.