File tree Expand file tree Collapse file tree 4 files changed +9
-5
lines changed
Expand file tree Collapse file tree 4 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -182,7 +182,8 @@ class Element extends ParentNode {
182182 const text = [ ] ;
183183 let { [ NEXT ] : next , [ END ] : end } = this ;
184184 while ( next !== end ) {
185- if ( next . nodeType === TEXT_NODE )
185+ const nodeType = next . nodeType ;
186+ if ( nodeType === TEXT_NODE || nodeType === CDATA_SECTION_NODE )
186187 text . push ( next . textContent ) ;
187188 next = next [ NEXT ] ;
188189 }
Original file line number Diff line number Diff line change @@ -184,7 +184,8 @@ export class Element extends ParentNode {
184184 const text = [ ] ;
185185 let { [ NEXT ] : next , [ END ] : end } = this ;
186186 while ( next !== end ) {
187- if ( next . nodeType === TEXT_NODE )
187+ const nodeType = next . nodeType ;
188+ if ( nodeType === TEXT_NODE || nodeType === CDATA_SECTION_NODE )
188189 text . push ( next . textContent ) ;
189190 next = next [ NEXT ] ;
190191 }
Original file line number Diff line number Diff line change @@ -8,9 +8,10 @@ let document = (new DOMParser).parseFromString('<html><body><![CDATA[test]]>text
88const [ cdata , text ] = document . documentElement . lastChild . childNodes ;
99
1010assert ( JSON . stringify ( cdata . cloneNode ( ) ) , '[4,"test"]' ) ;
11-
1211assert ( JSON . stringify ( text . cloneNode ( ) ) , '[3,"text"]' ) ;
1312
13+ assert ( document . documentElement . textContent , 'testtext' ) ;
14+
1415assert ( text . data , 'text' ) ;
1516assert ( text . nodeValue , 'text' ) ;
1617assert ( text . textContent , 'text' ) ;
@@ -34,4 +35,4 @@ document = (new DOMParser).parseFromString('<?xml version="1.0" encoding="utf-8"
3435assert ( document . toString ( ) , '<?xml version="1.0" encoding="utf-8"?><html><body><![CDATA[cdata with a <div> tag]]></body></html>' ) ;
3536
3637document = ( new DOMParser ) . parseFromString ( '<?xml version="1.0" encoding="utf-8"?><html><body><script>/*<![CDATA[*/test/*]]>*/</script></body></html>' , 'text/xml' ) ;
37- assert ( document . toString ( ) , '<?xml version="1.0" encoding="utf-8"?><html><body><script>/*<![CDATA[*/test/*]]>*/</script></body></html>' ) ;
38+ assert ( document . toString ( ) , '<?xml version="1.0" encoding="utf-8"?><html><body><script>/*<![CDATA[*/test/*]]>*/</script></body></html>' ) ;
Original file line number Diff line number Diff line change @@ -7764,7 +7764,8 @@ let Element$1 = class Element extends ParentNode {
77647764 const text = [ ] ;
77657765 let { [ NEXT ] : next , [ END ] : end } = this ;
77667766 while ( next !== end ) {
7767- if ( next . nodeType === TEXT_NODE )
7767+ const nodeType = next . nodeType ;
7768+ if ( nodeType === TEXT_NODE || nodeType === CDATA_SECTION_NODE )
77687769 text . push ( next . textContent ) ;
77697770 next = next [ NEXT ] ;
77707771 }
You can’t perform that action at this time.
0 commit comments