|
1 | 1 | const BODY = '<body>Foo " " Bar</body>';
|
2 |
| -const REBODY = '<body>Foo " " Bar</body>'; |
| 2 | +const REBODY_IN_HTML = '<body>Foo " " Bar</body>'; |
| 3 | +const REBODY_IN_XML = '<body>Foo\xA0"\xA0"\xA0Bar</body>'; |
3 | 4 | const HTML = `<html id="html" class="live">${BODY}</html>`;
|
4 |
| -const REHTML = `<html id="html" class="live">${REBODY}</html>`; |
| 5 | +const REHTML_IN_HTML = `<html id="html" class="live">${REBODY_IN_HTML}</html>`; |
| 6 | +const REHTML_IN_XML = `<html id="html" class="live">${REBODY_IN_XML}</html>`; |
5 | 7 |
|
6 | 8 | const assert = require('../assert.js').for('Text Escaper');
|
7 | 9 |
|
8 |
| -const {parseHTML} = global[Symbol.for('linkedom')]; |
| 10 | +const {parseHTML, DOMParser} = global[Symbol.for('linkedom')]; |
9 | 11 |
|
10 |
| -const {document} = parseHTML('<!DOCTYPE html>' + HTML); |
| 12 | +let {document} = parseHTML('<!DOCTYPE html>' + HTML); |
11 | 13 |
|
12 |
| -assert(document.documentElement.toString(), REHTML); |
| 14 | +assert(document.documentElement.toString(), REHTML_IN_HTML); |
13 | 15 |
|
14 | 16 | document.documentElement.innerHTML = BODY;
|
15 | 17 |
|
16 |
| -assert(document.documentElement.toString(), REHTML); |
| 18 | +assert(document.documentElement.toString(), REHTML_IN_HTML); |
| 19 | + |
| 20 | +document.documentElement.innerHTML = '<body>&amp;</body>'; |
| 21 | +assert(document.documentElement.toString(), `<html id="html" class="live"><body>&amp;</body></html>`); |
| 22 | + |
| 23 | +document = (new DOMParser).parseFromString('<!DOCTYPE html>' + HTML, 'text/xml'); |
| 24 | + |
| 25 | +assert(document.documentElement.toString(), REHTML_IN_XML); |
| 26 | + |
| 27 | +document.documentElement.innerHTML = BODY; |
| 28 | + |
| 29 | +assert(document.documentElement.toString(), REHTML_IN_XML); |
17 | 30 |
|
18 | 31 | document.documentElement.innerHTML = '<body>&amp;</body>';
|
19 | 32 | assert(document.documentElement.toString(), `<html id="html" class="live"><body>&amp;</body></html>`);
|
0 commit comments