Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions dom.bs
Original file line number Diff line number Diff line change
Expand Up @@ -3621,6 +3621,7 @@ interface mixin NonDocumentTypeChildNode {
};
Element includes NonDocumentTypeChildNode;
CharacterData includes NonDocumentTypeChildNode;
Marker includes NonDocumentTypeChildNode;
</pre>

<dl class=domintro>
Expand Down Expand Up @@ -4421,6 +4422,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;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

love it, happy to provide a polyfill around this too, in case nobody else is already working on it

Copy link
Copy Markdown

@WebReflection WebReflection Jan 22, 2026

Choose a reason for hiding this comment

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

example:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</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) && /^(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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

forgot the devtools result:

image

readonly attribute unsigned short nodeType;
readonly attribute DOMString nodeName;

Expand Down Expand Up @@ -4520,6 +4522,9 @@ get a direct instance of it.

<dt>{{DocumentFragment}}
<dd><code>{{Node}} . {{Node/DOCUMENT_FRAGMENT_NODE}}</code> (11).

<dt>{{Marker}}
<dd><code>{{Node}} . {{Node/MARKER_NODE}}</code> (13).
</dl>

<dt><code><var>node</var> . {{Node/nodeName}}</code>
Expand Down Expand Up @@ -4553,6 +4558,9 @@ get a direct instance of it.

<dt>{{DocumentFragment}}
<dd>"<code>#document-fragment</code>".

<dt>{{Marker}}
<dd>"<code>#marker</code>".
</dl>
</dl>

Expand Down Expand Up @@ -4586,6 +4594,9 @@ statement, switching on the interface <a>this</a> <a>implements</a>:

<dt>{{DocumentFragment}}
<dd><dfn const for=Node>DOCUMENT_FRAGMENT_NODE</dfn> (11).

<dt>{{Marker}}
<dd><dfn const for=Node>MARKER_NODE</dfn> (13).
</dl>

<p>The <dfn attribute for=Node>nodeName</dfn> getter steps are to return the first matching
Expand Down Expand Up @@ -5034,6 +5045,10 @@ and an optional <a for=/>document</a> <dfn export for="clone a node"><var>docume
<dd><p>Set <var>copy</var>'s <a for=ProcessingInstruction>target</a> and
<a for=CharacterData>data</a> to those of <var>node</var>.

<dt>{{Marker}}
<dd><p>Set <var>copy</var>'s <a for=Marker>type</a> and <a for=Marker>name</a> to those of
<var>node</var>.

<dt>Otherwise
<dd><p>Do nothing.
</dl>
Expand Down Expand Up @@ -8550,6 +8565,42 @@ constructor steps are to set <a>this</a>'s <a for=CharacterData>data</a> to <var
</div>


<h3 id=interface-marker>Interface {{Marker}}</h3>

<pre class=idl>
enum MarkerType { "marker", "start", "end" };

[Exposed=Window]
interface Marker : Node {
constructor(MarkerType type, optional DOMString name = "");

readonly attribute MarkerType type;
readonly attribute DOMString name;
};
</pre>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should also include mixin NonDocumentTypeChildNode I think.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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


<dl class=domintro>
<dt><code><var ignore>marker</var> = new <a constructor lt="Marker()">Marker(<var>type</var> [, <var>name</var> = ""])</a></code>
<dd>Returns a new {{Marker}} <a for=/>node</a> whose <a for=Marker>type</a> is <var>type</var> and
<a for=Marker>name</a> is <var>name</var>.
</dl>

<p>{{Marker}} <a for=/>nodes</a> are simply known as
<dfn export id=concept-marker lt="marker">markers</dfn>.

<p><a>Markers</a> have an associated
<dfn export id=concept-marker-type for=Marker>type</dfn> and
<dfn export id=concept-marker-name for=Marker>name</dfn>.

<div algorithm>
<p>The <dfn constructor for=Marker lt="Marker(type)"><code>new Marker(<var>type</var>, <var>name</var>)</code></dfn>
constructor steps are to set <a>this</a>'s <a for=Marker>type</a> to <var>type</var>, <a>this</a>'s
<a for=Marker>name</a> to <var>name</var>, and <a>this</a>'s <a for=Node>node document</a> to
<a>current global object</a>'s <a>associated <code>Document</code></a>.
</div>




<h2 id=ranges>Ranges</h2>

Expand Down Expand Up @@ -10527,6 +10578,7 @@ callback interface NodeFilter {
const unsigned long SHOW_DOCUMENT_TYPE = 0x200;
const unsigned long SHOW_DOCUMENT_FRAGMENT = 0x400;
const unsigned long SHOW_NOTATION = 0x800; // legacy
const unsigned long SHOW_MARKER = 0x1000;

unsigned short acceptNode(Node node);
};
Expand Down Expand Up @@ -10558,6 +10610,7 @@ JavaScript function.
<li><dfn const for=NodeFilter><code>SHOW_DOCUMENT</code></dfn> (256, 100 in hexadecimal);
<li><dfn const for=NodeFilter><code>SHOW_DOCUMENT_TYPE</code></dfn> (512, 200 in hexadecimal);
<li><dfn const for=NodeFilter><code>SHOW_DOCUMENT_FRAGMENT</code></dfn> (1024, 400 in hexadecimal).
<li><dfn const for=NodeFilter><code>SHOW_MARKER</code></dfn> (4096, 1000 in hexadecimal).
</ul>


Expand Down