From 8290cb3391bc16cfe719106407b1c69ae8d588c0 Mon Sep 17 00:00:00 2001 From: KazariEX <1364035137@qq.com> Date: Sun, 27 Oct 2024 02:47:32 +0800 Subject: [PATCH 1/3] fix(compiler): resolve inner content for incomplete SFC root tag --- packages/compiler-core/src/parser.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/compiler-core/src/parser.ts b/packages/compiler-core/src/parser.ts index 95c5e129f25..2d2ec8b74b0 100644 --- a/packages/compiler-core/src/parser.ts +++ b/packages/compiler-core/src/parser.ts @@ -419,6 +419,13 @@ const tokenizer = new Tokenizer(stack, { onend() { const end = currentInput.length + // resolve inner content for incomplete SFC root tag + if (currentRoot && currentRoot.children.length) { + const el = currentRoot.children[currentRoot.children.length - 1]; + if (el.type === 1 && !new RegExp(`<\/${el.tag}\s*>$`).test(el.loc.source)) { + el.innerLoc = getLoc(el.innerLoc!.start.offset, end); + } + } // EOF ERRORS if ((__DEV__ || !__BROWSER__) && tokenizer.state !== State.Text) { switch (tokenizer.state) { From ea38be36e3d376419b368f9a691859c66a46c27a Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Sat, 26 Oct 2024 18:53:49 +0000 Subject: [PATCH 2/3] [autofix.ci] apply automated fixes --- packages/compiler-core/src/parser.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/compiler-core/src/parser.ts b/packages/compiler-core/src/parser.ts index 2d2ec8b74b0..0871f95a2b1 100644 --- a/packages/compiler-core/src/parser.ts +++ b/packages/compiler-core/src/parser.ts @@ -421,9 +421,12 @@ const tokenizer = new Tokenizer(stack, { const end = currentInput.length // resolve inner content for incomplete SFC root tag if (currentRoot && currentRoot.children.length) { - const el = currentRoot.children[currentRoot.children.length - 1]; - if (el.type === 1 && !new RegExp(`<\/${el.tag}\s*>$`).test(el.loc.source)) { - el.innerLoc = getLoc(el.innerLoc!.start.offset, end); + const el = currentRoot.children[currentRoot.children.length - 1] + if ( + el.type === 1 && + !new RegExp(`<\/${el.tag}\s*>$`).test(el.loc.source) + ) { + el.innerLoc = getLoc(el.innerLoc!.start.offset, end) } } // EOF ERRORS From 32b7b1600d4c01e5f899aa514124c0885a7da2a6 Mon Sep 17 00:00:00 2001 From: KazariEX <1364035137@qq.com> Date: Sun, 27 Oct 2024 03:02:54 +0800 Subject: [PATCH 3/3] fix: determine `innerLoc` --- packages/compiler-core/src/parser.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/compiler-core/src/parser.ts b/packages/compiler-core/src/parser.ts index 0871f95a2b1..5394eef871c 100644 --- a/packages/compiler-core/src/parser.ts +++ b/packages/compiler-core/src/parser.ts @@ -424,9 +424,10 @@ const tokenizer = new Tokenizer(stack, { const el = currentRoot.children[currentRoot.children.length - 1] if ( el.type === 1 && + el.innerLoc && !new RegExp(`<\/${el.tag}\s*>$`).test(el.loc.source) ) { - el.innerLoc = getLoc(el.innerLoc!.start.offset, end) + el.innerLoc = getLoc(el.innerLoc.start.offset, end) } } // EOF ERRORS