Skip to content

Commit

Permalink
capricorn86#519@patch: Patch switch case.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mas0nShi committed Feb 23, 2023
1 parent 1e95e0a commit aabf229
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions packages/happy-dom/src/xml-parser/XMLParser.ts
Expand Up @@ -61,24 +61,18 @@ export default class XMLParser {
} else {
let condCommMatch;
let condCommEndMatch;
let needRewrite = false;
const condCommRegexp = new RegExp(CONDITION_COMMENT_REGEXP, 'gi');
const condCommEndRegexp = new RegExp(CONDITION_COMMENT_END_REGEXP, 'gi');
// @Refer: https://learn.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/?redirectedfrom=MSDN
if (isStartTag && (condCommMatch = condCommRegexp.exec(text)) && condCommMatch[0]) {
// Compatible with IE
while ((condCommEndMatch = condCommEndRegexp.exec(data))) {
if (condCommEndMatch[0]) {
needRewrite = true;
break;
} else {
throw new Error('conditional comments unclosed.');
}
}
if (needRewrite) {
markupRegexp.lastIndex = condCommEndRegexp.lastIndex;
continue; // Re parse.
}
if (
isStartTag &&
(condCommMatch = condCommRegexp.exec(text)) &&
condCommMatch[0] &&
(condCommEndMatch = condCommEndRegexp.exec(data)) &&
condCommEndMatch[0]
) {
markupRegexp.lastIndex = condCommEndRegexp.lastIndex;
continue;
} else {
this.appendTextAndCommentNodes(document, parent, text);
}
Expand Down

0 comments on commit aabf229

Please sign in to comment.