From 78eb24034576e4ecc39a3633967799ea75bead50 Mon Sep 17 00:00:00 2001 From: David Ortner Date: Tue, 31 Dec 2024 13:50:53 +0100 Subject: [PATCH] fix: [#1564] Fixes issue where text in script and style elements should not be decoded or encoded (#1654) --- packages/happy-dom/src/html-parser/HTMLParser.ts | 6 ++---- .../test/html-serializer/HTMLSerializer.test.ts | 14 +++++++++++++- .../test/xml-serializer/XMLSerializer.test.ts | 15 +++++++++++++++ 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/packages/happy-dom/src/html-parser/HTMLParser.ts b/packages/happy-dom/src/html-parser/HTMLParser.ts index 36f10957..e664d399 100755 --- a/packages/happy-dom/src/html-parser/HTMLParser.ts +++ b/packages/happy-dom/src/html-parser/HTMLParser.ts @@ -738,10 +738,8 @@ export default class HTMLParser { } // Plain text elements such as ', + 'text/html' + ) + )).body + ) + ).toBe('
'); + }); }); }); diff --git a/packages/happy-dom/test/xml-serializer/XMLSerializer.test.ts b/packages/happy-dom/test/xml-serializer/XMLSerializer.test.ts index a06b19c2..d62c79d6 100644 --- a/packages/happy-dom/test/xml-serializer/XMLSerializer.test.ts +++ b/packages/happy-dom/test/xml-serializer/XMLSerializer.test.ts @@ -456,5 +456,20 @@ describe('XMLSerializer', () => { ` ); }); + + it("Doesn't escape text in ', + 'text/html' + ) + )).body + ) + ).toBe( + '
' + ); + }); }); });