- From: Luke Warlow via GitHub <noreply@w3.org>
- Date: Wed, 03 Sep 2025 13:16:32 +0000
- To: public-svg-issues@w3.org
lukewarlow has just created a new issue for https://github.com/w3c/svgwg: == Add a `.click()` method to SVGElement == ### What problem are you trying to solve? In HTML you can simulate a click on an element via a `el.click()` function, this is particularly useful when trying to trigger an action on page load or during testing of your UI. This function doesn't exist in SVG. ### What solutions exist today? You can write `el.dispatchEvent(new MouseEvent('click'));` which works but isn't intuitive and sticks out when you're used to writing this for HTML elements. ### How would you solve it? Define a new click method on SVGElement. ```webidl partial interface SVGElement { undefined click(); }; ``` The method steps should largely follow that of [`HTMLElement.click()`](https://html.spec.whatwg.org/multipage/interaction.html#dom-click) except step 1 isn't needed as SVG has no form elements. ### Anything else? Alternatively this function could be moved to the HTMLOrForeignElement (currently named HTMLOrSVGElement in the html spec) mixin and would then work for MathML too. Please view or discuss this issue at https://github.com/w3c/svgwg/issues/1005 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Wednesday, 3 September 2025 13:16:33 UTC