Skip to content

Commit

Permalink
capricorn86#916@patch: Handle comments with dash in text.
Browse files Browse the repository at this point in the history
  • Loading branch information
gtm-nayan committed May 13, 2023
1 parent 0744805 commit b1acb33
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/happy-dom/src/xml-parser/XMLParser.ts
Expand Up @@ -24,7 +24,7 @@ import * as Entities from 'entities';
* Group 8: End of start tag (e.g. ">" in "<div>").
*/
const MARKUP_REGEXP =
/<([a-zA-Z0-9-]+)|<\/([a-zA-Z0-9-]+)>|<!--([^-]+)-->|<!--([^>]+)>|<!([^>]+)>|<\?([^>]+)>|(\/>)|(>)/gm;
/<([a-zA-Z0-9-]+)|<\/([a-zA-Z0-9-]+)>|<!--([^-]+(?:-[^-]+)*)-->|<!--([^>]+)>|<!([^>]+)>|<\?([^>]+)>|(\/>)|(>)/gm;

/**
* Attribute RegExp.
Expand Down
7 changes: 7 additions & 0 deletions packages/happy-dom/test/xml-parser/XMLParser.test.ts
Expand Up @@ -506,6 +506,13 @@ describe('XMLParser', () => {
}
});

it('Parses comments with dash in them', () => {
const root = XMLParser.parse(document, '<!-- comment with - in it -->');
expect(root.childNodes.length).toBe(1);
expect(root.childNodes[0].nodeType).toBe(Node.COMMENT_NODE);
expect(root.childNodes[0].nodeValue).toBe(' comment with - in it ');
});

it('Parses <template> elements, including its content.', () => {
const root = XMLParser.parse(document, '<div><template><tr><td></td></tr></template></div>');
expect(root.childNodes.length).toBe(1);
Expand Down

0 comments on commit b1acb33

Please sign in to comment.