-
Notifications
You must be signed in to change notification settings - Fork 322
Add Marker interface #1447
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?
Add Marker interface #1447
Conversation
This node is intended for the `<!start>`, `<!end>` and `<!marker>` syntax, to be created by the HTML parser.
| 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; |
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.
love it, happy to provide a polyfill around this too, in case nobody else is already working on it
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.
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.
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.
|
@annevk this isn't complete, but I wanted to send it out because I'm not totally sure about a few choices.
|
|
We probably need to investigate why |
|
|
I wondered about this too, and guess it's because it inherits from
Is there some place you suspect the discussion might have happened that I can go investigate? |
|
Maybe in WebApps archives? I think there was also some aversion to introducing a new node type and having to revisit existing algorithms. But I'm not sure that ended up being good thing as we still have some technical debt to resolve from that. |
|
I found #1007 via list archives, but it's not a discussion on whether constant should be added or not. From a search of Chromium commit messages and WebKit bugs, I found some decisions:
I haven't looked at the spec history, but from this I gather the reasoning was that the new constant should only be added if the new interface inherits directly from We will also need a new "#marker" return value for |
|
The original spec edit to use |
|
to whom it might concern, I've read the proposed specs and created a polyfill: I took a chance to add attributes but it's unclear in this document how those would be handled. |
I missed that, updated the gist to reflect that too ... it's looking good to me as polyfill:
You can I hope this will help shaping the specs. edit P.S. as every polyfill in this world kinda requires, that module should be the very first one imported on top of everything else, yet it will play nicely with other polyfills, as it shouldn't bother any other related logic. |
| readonly attribute MarkerType type; | ||
| readonly attribute DOMString name; | ||
| }; | ||
| </pre> |
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.
Should also include mixin NonDocumentTypeChildNode I think.

This node is intended for the
<!start>,<!end>and<!marker>syntax, to be created by the HTML parser.
(See WHATWG Working Mode: Changes for more details.)