-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComment.js
More file actions
82 lines (71 loc) · 1.41 KB
/
Comment.js
File metadata and controls
82 lines (71 loc) · 1.41 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
'use strict';
/*
global module,
require
*/
const TextElement = require( './TextElement' );
/**
* Provides a comment element. It inherits from `Text` but won't be included in the `textContent`
* property.
*
* @class
* @extends Text
* @extends Element
* @extends Node
*/
class Comment extends TextElement {
/**
* Creates a new text element.
*
* @param {string} [content=''] text content
* @param {*} args arguments to the Node constructor
*
* @constructor
*/
constructor ( content = '', ...args ) {
super( {}, ...args );
this.textContent = content;
}
/**
* Appends text to the content.
*
* @param {string} text new text to append
*/
appendText ( text = '' ) {
this.textContent = this.textContent + text;
}
/**
* Replaces the content with new text.
*
* @param {string} text new content text
*/
replaceWith ( text = '' ) {
this.textContent = String( text );
}
/**
* Retrieves the content string length
*
* @return {number}
*/
get length () {
return this.textContent.length;
}
/**
* Retrieves the text content
*
* @return {string}
*/
get nodeValue () {
return this.textContent;
}
// noinspection JSCheckFunctionSignatures
/**
* Sets the text content
*
* @param {string} newText
*/
set nodeValue ( newText ) {
this.textContent = newText;
}
}
module.exports = Comment;