Re: [whatwg/dom] Add Marker interface (PR #1447)

@WebReflection commented on this pull request.



> @@ -4421,6 +4421,7 @@ interface Node : EventTarget {
   const unsigned short DOCUMENT_TYPE_NODE = 10;
   const unsigned short DOCUMENT_FRAGMENT_NODE = 11;
   const unsigned short NOTATION_NODE = 12; // legacy
+  const unsigned short MARKER_NODE = 13;

example:

```html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Marker</title>
  <script type="module">
    class Marker extends CharacterData {
      get nodeType() {
        return 13;
      }
      hasAttribute(name) {
        return new RegExp(` ${name}(=(['"])?(.*)?\\2)?`).test(this.data);
      }
      getAttribute(name) {
        return this.hasAttribute(name) ? RegExp.$3 : null;
      }
    }

    const promoted = new WeakSet;
    const tw = document.createTreeWalker(document.body, NodeFilter.SHOW_COMMENT);
    let node;
    while (node = tw.nextNode()) {
      if (promoted.has(node)) continue;
      if (/^(start|end|marker)(?:$|\s+)/.test(node.data)) {
        promoted.add(node);
        const kind = RegExp.$1;
        Object.setPrototypeOf(node, Marker.prototype);
        console.log({ name: node.getAttribute('name') });
      }
    }
  </script>
</head>
<body>
  <!start>
  O
  <!marker name=unquoted>
  <!marker name="double quoted">
  <!marker name='single quoted'>
  <!marker-nope name="value">
  <!nope name="value">
  K
  <!end>
</body>
</html>
```

now, I've no idea how people out there are supposed to distinguish `<!marker>` from `<!--marker-->`, as example, but the polyfill would take those starting content for granted and produce a *Marker* node already.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/pull/1447#discussion_r2717450187
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/dom/pull/1447/review/3693119555@github.com>

Received on Thursday, 22 January 2026 15:40:17 UTC