Skip to content

Commit 7c44f48

Browse files
chore: [#1947] Adds unit tests for decode ' / numeric character references in attr values (#1948)
- attribute values can contain named and numeric character references per https://html.spec.whatwg.org/multipage/syntax.html#syntax-attribute-value - add decoding for all numeric character references - add decoding for &apos;, this could probably appear in single-quoted attribute values - ignore other named character references, the list is huge Co-authored-by: David Ortner <david@ortner.se>
1 parent 560589c commit 7c44f48

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

packages/happy-dom/test/html-parser/HTMLParser.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2256,6 +2256,21 @@ describe('HTMLParser', () => {
22562256
`);
22572257
});
22582258

2259+
it('Handles numeric character references and &apos; in attribute values for #1947', () => {
2260+
const result = new HTMLParser(window).parse(`
2261+
<div>
2262+
<span data-foo="&#34;"></span>
2263+
<span data-foo="&#x22;"></span>
2264+
<span data-foo="&apos;"></span>
2265+
</div>`);
2266+
expect(new HTMLSerializer().serializeToString(result)).toBe(`
2267+
<div>
2268+
<span data-foo="&quot;"></span>
2269+
<span data-foo="&quot;"></span>
2270+
<span data-foo="'"></span>
2271+
</div>`);
2272+
});
2273+
22592274
it('Handles numeric character references in attribute values for #1947', () => {
22602275
// Decimal numeric character reference
22612276
const result1 = new HTMLParser(window).parse(`<div data-foo="&#34;"></div>`);

0 commit comments

Comments
 (0)