1 | const Node = require('./Node');
|
2 | const CharacterData = require('./CharacterData');
|
3 |
|
4 |
|
5 | module.exports = class Text extends CharacterData {
|
6 | constructor(ownerDocument, text) {
|
7 | super(ownerDocument, text);
|
8 | this.nodeType = Node.TEXT_NODE;
|
9 | this.nodeName = '#text';
|
10 | }
|
11 |
|
12 | get wholeText() {
|
13 | let text = this.textContent;
|
14 | let prev = this.previousSibling;
|
15 | while (prev && prev.nodeType === 3) {
|
16 | text = prev.textContent + text;
|
17 | prev = prev.previousSibling;
|
18 | }
|
19 | let next = this.nextSibling;
|
20 | while (next && next.nodeType === 3) {
|
21 | text = text + next.textContent;
|
22 | next = next.nextSibling;
|
23 | }
|
24 | return text;
|
25 | }
|
26 |
|
27 | set wholeText(val) {}
|
28 | };
|