File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ const assert = require ( '../assert.js' ) . for ( 'HTMLTitleElement' ) ;
2
+
3
+ const { DOMParser, parseHTML} = global [ Symbol . for ( 'linkedom' ) ] ;
4
+
5
+ const { document : htmlDoc } = parseHTML ( '<title>abc&<>"\t\n\r\xA0</title>' ) ;
6
+ assert (
7
+ htmlDoc . toString ( ) ,
8
+ '<title>abc&<>"\t\n\r </title>'
9
+ ) ;
10
+
11
+ const htmlTitle = htmlDoc . querySelector ( 'title' ) ;
12
+ htmlTitle . innerHTML = '<a>sub element</a>' ;
13
+ assert (
14
+ htmlTitle . innerHTML ,
15
+ '<a>sub element</a>'
16
+ ) ;
17
+ assert (
18
+ htmlDoc . toString ( ) ,
19
+ '<title><a>sub element</a></title>'
20
+ ) ;
21
+ assert ( htmlDoc . querySelectorAll ( 'a' ) . length , 0 ) ;
22
+
23
+ const xmlDoc = ( new DOMParser ) . parseFromString ( '<title>abc&<>"\t\n\r\xA0</title>' , 'text/xml' ) ;
24
+ assert (
25
+ xmlDoc . toString ( ) ,
26
+ '<?xml version="1.0" encoding="utf-8"?><title>abc&<>"\t\n\r\xA0</title>'
27
+ ) ;
28
+
29
+ const xmlTitle = xmlDoc . querySelector ( 'title' ) ;
30
+ xmlTitle . innerHTML = '<a>sub element</a>' ;
31
+ assert (
32
+ xmlTitle . innerHTML ,
33
+ '<a>sub element</a>'
34
+ ) ;
35
+ assert (
36
+ xmlDoc . toString ( ) ,
37
+ '<?xml version="1.0" encoding="utf-8"?><title><a>sub element</a></title>'
38
+ ) ;
39
+ assert ( xmlDoc . querySelectorAll ( 'a' ) . length , 1 ) ;
You can’t perform that action at this time.
0 commit comments