-
Notifications
You must be signed in to change notification settings - Fork 100
Expand file tree
/
Copy pathcomment.js
More file actions
29 lines (25 loc) · 761 Bytes
/
comment.js
File metadata and controls
29 lines (25 loc) · 761 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
'use strict';
const {COMMENT_NODE} = require('../shared/constants.js');
const {VALUE, MIME} = require('../shared/symbols.js');
const {escape} = require('../shared/text-escaper.js');
const {CharacterData} = require('./character-data.js');
/**
* @implements globalThis.Comment
*/
class Comment extends CharacterData {
constructor(ownerDocument, data = '') {
super(ownerDocument, '#comment', COMMENT_NODE, data);
}
cloneNode() {
const {ownerDocument, [VALUE]: data} = this;
return new Comment(ownerDocument, data);
}
toString() {
const {ownerDocument} = this;
if (ownerDocument[MIME].escapeHtmlEntities) {
return `<!--${escape(this[VALUE])}-->`;
}
return `<!--${(this[VALUE])}-->`;
}
}
exports.Comment = Comment