Skip to content

Conversation

estelle
Copy link
Member

@estelle estelle commented Oct 20, 2025

This was originally part of #41583, but as another option is just to remove the entire section, i pulled this into a different PR. We can add something like this, or, optionally, get rid of the list altogether.

@estelle estelle requested a review from a team as a code owner October 20, 2025 09:54
@estelle estelle requested review from chrisdavidmills and removed request for a team October 20, 2025 09:54
@github-actions github-actions bot added Content:SVG SVG docs size/m [PR only] 51-500 LoC changed labels Oct 20, 2025
Copy link
Contributor

github-actions bot commented Oct 20, 2025

Preview URLs

Flaws (14)

URL: /en-US/docs/Web/SVG/Reference/Attribute
Title: SVG Attribute reference
Flaw count: 14

  • macros:
    • Can't resolve /en-US/docs/Web/SVG/Reference/Attribute/hreflang
    • Can't resolve /en-US/docs/Web/SVG/Reference/Attribute/offset
    • Can't resolve /en-US/docs/Web/SVG/Reference/Attribute/ping
    • Can't resolve /en-US/docs/Web/SVG/Reference/Attribute/referrerPolicy
    • Can't resolve /en-US/docs/Web/SVG/Reference/Attribute/rel
    • and 9 more flaws omitted

(comment last updated: 2025-10-20 11:47:04)

Copy link
Contributor

@chrisdavidmills chrisdavidmills left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@estelle sure, makes sense. One suggestion for you to look at.

Co-authored-by: Chris Mills <chrisdavidmills@gmail.com>
@Josh-Cena
Copy link
Member

Josh-Cena commented Oct 20, 2025

Sooo, I took the same approach as #41264. I took the union of event handlers documented before and after this PR, and also all onxxx properties exposed on HTMLElement, Element, and SVGElement.

Code
<!doctype html>
<html>
  <head>
    <meta charset="utf-8" />
    <style>
      body {
        width: 1400px;
        display: flex;
        flex-wrap: wrap;
      }
      div {
        width: 150px;
        border: 2px solid black;
        text-align: center;
        margin: 0.2em;
        padding: 0.2em;
      }
      [data-svg-fired]:not([data-text-fired]) {
        background: lightcoral;
      }
      [data-text-fired]:not([data-svg-fired]) {
        background: lightyellow;
      }
      [data-svg-fired][data-text-fired] {
        background: lightgreen;
      }
    </style>
  </head>
  <body>
    <script>
      const attrs = `onabort
onactivate
onauxclick
onbeforeinput
onbeforematch
onbeforetoggle
onbegin
onblur
oncancel
oncanplay
oncanplaythrough
onchange
onclick
onclose
oncommand
oncontextlost
oncontextmenu
oncontextrestored
oncopy
oncuechange
oncut
ondblclick
ondrag
ondragend
ondragenter
ondragleave
ondragover
ondragstart
ondrop
ondurationchange
onemptied
onend
onended
onerror
onfocus
onfocusin
onfocusout
onformdata
oninput
oninvalid
onkeydown
onkeypress
onkeyup
onload
onloadeddata
onloadedmetadata
onloadstart
onmousedown
onmouseenter
onmouseleave
onmousemove
onmouseout
onmouseover
onmouseup
onmousewheel
onpaste
onpause
onplay
onplaying
onprogress
onratechange
onrepeat
onreset
onresize
onscroll
onscrollend
onsecuritypolicyviolation
onseeked
onseeking
onselect
onshow
onslotchange
onstalled
onsubmit
onsuspend
ontimeupdate
ontoggle
onunload
onvolumechange
onwaiting
onwheel`.split("\n");
      function testEvent(type) {
        const div = document.createElement("div");
        div.id = `event-${type}`;
        div.textContent = type;
        document.body.appendChild(div);
        const svg = document.createElementNS(
          "http://www.w3.org/2000/svg",
          "svg",
        );
        svg.setAttribute(
          `on${type}`,
          `document.getElementById('event-${type}').setAttribute('data-svg-fired', 'yes')`,
        );
        svg.dispatchEvent(new Event(type));
        const text = document.createElementNS(
          "http://www.w3.org/2000/svg",
          "tspan",
        );
        text.setAttribute(
          `on${type}`,
          `document.getElementById('event-${type}').setAttribute('data-text-fired', 'yes')`,
        );
        text.dispatchEvent(new Event(type));
      }
      const set1 = new Set(
        [
          ...Object.getOwnPropertyNames(SVGElement.prototype),
          ...Object.getOwnPropertyNames(HTMLElement.prototype),
          ...Object.getOwnPropertyNames(Element.prototype),
        ]
          .filter((p) => p.startsWith("on"))
          .sort(),
      );
      const set2 = new Set(attrs);
      const unconfirmed = set2.difference(set1);
      console.log(unconfirmed);
      for (const type of [...set1, ...unconfirmed]) {
        testEvent(type.slice(2));
      }
      const supported = new Set([...document.querySelectorAll("[data-svg-fired], [data-text-fired]")].map((div) => `on${div.innerText}`));
      const undocumented = supported.difference(set2);
      const documentedUnsupported = set2.difference(supported);
      for (const type of undocumented) {
        document.getElementById(`event-${type.slice(2)}`).style.border = "2px solid red";
      }
      for (const type of documentedUnsupported) {
        document.getElementById(`event-${type.slice(2)}`).style.border = "2px dashed blue";
      }
    </script>
  </body>
</html>

In this diagram, green background means "supported"; yellow means "supported on <tspan> but not <svg>"; red border means "supported but undocumented", and blue dashed border means "documented but unsupported".

image

So, it appears that we have the following anomalies:

  • abort, error, resize, scroll are supported on <tspan> elements but not the root <svg> element, which is weird but probably acceptable as-is.
  • animationend, animationiteration, animationstart, beforecopy, beforecut, beforepaste, contentvisibilityautostatechange, gotpointercapture, lostpointercapture, pointercancel, pointerdown, pointerenter, pointerleave, pointermove, pointerout, pointerover, pointerrawupdate, pointerup, scrollsnapchange, scrollsnapchanging, selectstart, webkitfullscreenchange, webkitfullscreenerror are supported on SVG elements and should be documented.
  • activate, beforematch, begin, end, repeat, show, unload have no evidence of support on SVG elements

This is tested in Chrome only. It woudl take significantly more effort to do cross-browser testing but this is a good starting point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Content:SVG SVG docs size/m [PR only] 51-500 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants