From d266fb999a0d5c4db5526e4f796e547c3fc04b0a Mon Sep 17 00:00:00 2001 From: taoqf Date: Thu, 9 Apr 2020 10:41:42 +0800 Subject: [PATCH] speed up --- src/nodes/html.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/nodes/html.ts b/src/nodes/html.ts index 1c128e8..dff0364 100644 --- a/src/nodes/html.ts +++ b/src/nodes/html.ts @@ -623,6 +623,9 @@ export function parse(data: string, options = {} as Options) { } } lastTextPos = kMarkupPattern.lastIndex; + if (match[2] === frameflag) { + continue; + } if (match[0][1] === '!') { // this is a comment if (options.comment) { @@ -649,12 +652,10 @@ export function parse(data: string, options = {} as Options) { currentParent = arr_back(stack); } } - if (match[2] !== frameflag) { - // ignore container tag we add above - // https://github.com/taoqf/node-html-parser/issues/38 - currentParent = currentParent.appendChild(new HTMLElement(match[2], attrs, match[3])); - stack.push(currentParent); - } + // ignore container tag we add above + // https://github.com/taoqf/node-html-parser/issues/38 + currentParent = currentParent.appendChild(new HTMLElement(match[2], attrs, match[3])); + stack.push(currentParent); if (kBlockTextElements[match[2]]) { // a little test to find next or ... const closeMarkup = '';