@@ -52,6 +52,22 @@ describe('HtmlParser', () => {
5252 ] ) ;
5353 } ) ;
5454
55+ it ( 'should parse text nodes with HTML entities (5+ hex digits)' , ( ) => {
56+ // Test with 🛈 (U+1F6C8 - Circled Information Source)
57+ expect ( humanizeDom ( parser . parse ( '<div>🛈</div>' , 'TestComp' ) ) ) . toEqual ( [
58+ [ html . Element , 'div' , 0 ] ,
59+ [ html . Text , '\u{1F6C8}' , 1 , [ '' ] , [ '\u{1F6C8}' , '🛈' ] , [ '' ] ] ,
60+ ] ) ;
61+ } ) ;
62+
63+ it ( 'should parse text nodes with decimal HTML entities (5+ digits)' , ( ) => {
64+ // Test with 🛈 (U+1F6C8 - Circled Information Source) as decimal 128712
65+ expect ( humanizeDom ( parser . parse ( '<div>🛈</div>' , 'TestComp' ) ) ) . toEqual ( [
66+ [ html . Element , 'div' , 0 ] ,
67+ [ html . Text , '\u{1F6C8}' , 1 , [ '' ] , [ '\u{1F6C8}' , '🛈' ] , [ '' ] ] ,
68+ ] ) ;
69+ } ) ;
70+
5571 it ( 'should normalize line endings within CDATA' , ( ) => {
5672 const parsed = parser . parse ( '<![CDATA[ line 1 \r\n line 2 ]]>' , 'TestComp' ) ;
5773 expect ( humanizeDom ( parsed ) ) . toEqual ( [
@@ -326,6 +342,22 @@ describe('HtmlParser', () => {
326342 ] ) ;
327343 } ) ;
328344
345+ it ( 'should parse attributes containing encoded entities (5+ hex digits)' , ( ) => {
346+ // Test with 🛈 (U+1F6C8 - Circled Information Source)
347+ expect ( humanizeDom ( parser . parse ( '<div foo="🛈"></div>' , 'TestComp' ) ) ) . toEqual ( [
348+ [ html . Element , 'div' , 0 ] ,
349+ [ html . Attribute , 'foo' , '\u{1F6C8}' , [ '' ] , [ '\u{1F6C8}' , '🛈' ] , [ '' ] ] ,
350+ ] ) ;
351+ } ) ;
352+
353+ it ( 'should parse attributes containing encoded decimal entities (5+ digits)' , ( ) => {
354+ // Test with 🛈 (U+1F6C8 - Circled Information Source) as decimal 128712
355+ expect ( humanizeDom ( parser . parse ( '<div foo="🛈"></div>' , 'TestComp' ) ) ) . toEqual ( [
356+ [ html . Element , 'div' , 0 ] ,
357+ [ html . Attribute , 'foo' , '\u{1F6C8}' , [ '' ] , [ '\u{1F6C8}' , '🛈' ] , [ '' ] ] ,
358+ ] ) ;
359+ } ) ;
360+
329361 it ( 'should parse attributes containing unquoted interpolation' , ( ) => {
330362 expect ( humanizeDom ( parser . parse ( '<div foo={{message}}></div>' , 'TestComp' ) ) ) . toEqual ( [
331363 [ html . Element , 'div' , 0 ] ,
@@ -1632,6 +1664,25 @@ describe('HtmlParser', () => {
16321664 ] ) ;
16331665 } ) ;
16341666
1667+ it ( 'should decode HTML entities with 5+ hex digits in interpolations' , ( ) => {
1668+ // Test with 🛈 (U+1F6C8 - Circled Information Source)
1669+ expect (
1670+ humanizeDomSourceSpans ( parser . parse ( '{{🛈}}' + '{{🛈}}' , 'TestComp' ) ) ,
1671+ ) . toEqual ( [
1672+ [
1673+ html . Text ,
1674+ '{{\u{1F6C8}}}' + '{{\u{1F6C8}}}' ,
1675+ 0 ,
1676+ [ '' ] ,
1677+ [ '{{' , '🛈' , '}}' ] ,
1678+ [ '' ] ,
1679+ [ '{{' , '🛈' , '}}' ] ,
1680+ [ '' ] ,
1681+ '{{🛈}}' + '{{🛈}}' ,
1682+ ] ,
1683+ ] ) ;
1684+ } ) ;
1685+
16351686 it ( 'should support interpolations in text' , ( ) => {
16361687 expect (
16371688 humanizeDomSourceSpans ( parser . parse ( '<div> pre {{ value }} post </div>' , 'TestComp' ) ) ,
0 commit comments