From f84faa1e986dfe2836d691e683e231e8fd3b4400 Mon Sep 17 00:00:00 2001 From: Dan Bentley Date: Wed, 13 Mar 2024 17:17:37 +0000 Subject: [PATCH] fix: [#1039] Allow nested list items Update tests to reflect the change and also ensure that nesting is removed from all non-nestable elements. --- .../src/config/HTMLElementUnnestable.ts | 1 - .../test/xml-parser/XMLParser.test.ts | 44 ++++++++++++++----- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/packages/happy-dom/src/config/HTMLElementUnnestable.ts b/packages/happy-dom/src/config/HTMLElementUnnestable.ts index 1d2820a10..829a641a6 100644 --- a/packages/happy-dom/src/config/HTMLElementUnnestable.ts +++ b/packages/happy-dom/src/config/HTMLElementUnnestable.ts @@ -10,7 +10,6 @@ export default { H4: true, H5: true, H6: true, - LI: true, OPTION: true, P: true, SELECT: true, diff --git a/packages/happy-dom/test/xml-parser/XMLParser.test.ts b/packages/happy-dom/test/xml-parser/XMLParser.test.ts index 7c4d17152..d68373fb6 100644 --- a/packages/happy-dom/test/xml-parser/XMLParser.test.ts +++ b/packages/happy-dom/test/xml-parser/XMLParser.test.ts @@ -205,30 +205,50 @@ describe('XMLParser', () => { expect(new XMLSerializer().serializeToString(root)).toBe(GET_EXPECTED_HTML(pageHTML)); }); - it('Handles unclosed tags of unnestable elements (e.g. ,
  • ).', () => { + it('Removes nesting from unnestable elements (e.g. , +
    Description Term
    +
    Description Details
    +
    +

    Heading One

    +

    Heading Two

    +

    Heading Three

    +

    Heading Four

    +
    Heading Five
    +
    Heading Six
    + +

    Paragraph

    + Select +
    Table
    ` ); expect(new XMLSerializer().serializeToString(root).replace(/\s/gm, '')).toBe( ` -
    -
      -
    • Test
    • -
    • Test 2
    • -
    • Test 3
    • -
    + Test + +
    DescriptionTerm
    +
    DescriptionDetails
    +
    +

    HeadingOne

    +

    HeadingTwo

    +

    HeadingThree

    +

    HeadingFour

    +
    HeadingFive
    +
    HeadingSix
    + +

    Paragraph

    + +
    + Table
    +
    `.replace(/\s/gm, '') );