Skip to content

Commit

Permalink
Merge pull request #505 from Mas0nShi/504-Fixes-XmlParser-error-parse…
Browse files Browse the repository at this point in the history
…-with-tags

#504@patch: Fixes XmlParser error parse with tags.
  • Loading branch information
capricorn86 committed Jun 14, 2022
2 parents 8ece290 + c5052fb commit f9d55eb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/happy-dom/src/xml-parser/XMLParser.ts
Expand Up @@ -11,7 +11,7 @@ import INode from '../nodes/node/INode';
import IElement from '../nodes/element/IElement';
import HTMLLinkElement from '../nodes/html-link-element/HTMLLinkElement';

const MARKUP_REGEXP = /<(\/?)([a-z][-.0-9_a-z]*)\s*([^>]*?)(\/?)>/gi;
const MARKUP_REGEXP = /<(\/?)([a-z][-.0-9_a-z]*)\s*([^<>]*?)(\/?)>/gi;
const COMMENT_REGEXP = /<!--(.*?)-->|<([!?])([^>]*)>/gi;
const DOCUMENT_TYPE_ATTRIBUTE_REGEXP = /"([^"]+)"/gm;
const ATTRIBUTE_REGEXP = /([^\s=]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|(\S+)))/gms;
Expand Down
15 changes: 15 additions & 0 deletions packages/happy-dom/test/xml-parser/XMLParser.test.ts
Expand Up @@ -185,6 +185,21 @@ describe('XMLParser', () => {
<template></template>
</div>`.replace(/[\s]/gm, '')
);

const root2 = XMLParser.parse(
window.document,
`<html>
<head>
<title>Title</title>
</head>
<body>
<script type="text/javascript">var vars = []; for (var i=0;i<vars.length;i++) {}</script>
</body>
</html>`
);
expect((<IHTMLElement>root2.children[0].children[1].children[0]).innerText).toBe(
'var vars = []; for (var i=0;i<vars.length;i++) {}'
);
});

it('Handles unclosed regular elements.', () => {
Expand Down

0 comments on commit f9d55eb

Please sign in to comment.