From 075edae89054d784ad926cbfd2e05c0fb39f9e27 Mon Sep 17 00:00:00 2001 From: Konv Suu <2583695112@qq.com> Date: Fri, 11 Jul 2025 11:30:53 +0800 Subject: [PATCH] feat(compiler-dom): support customizable select --- .../__tests__/transforms/validateHtmlNesting.spec.ts | 7 +++++++ packages/compiler-dom/src/htmlNesting.ts | 3 --- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/compiler-dom/__tests__/transforms/validateHtmlNesting.spec.ts b/packages/compiler-dom/__tests__/transforms/validateHtmlNesting.spec.ts index 46d69846bae..af98eafd704 100644 --- a/packages/compiler-dom/__tests__/transforms/validateHtmlNesting.spec.ts +++ b/packages/compiler-dom/__tests__/transforms/validateHtmlNesting.spec.ts @@ -11,6 +11,13 @@ describe('validate html nesting', () => { expect(err!.message).toMatch(`
cannot be child of

`) }) + it("Don't warn with customize select and option", () => { + let err: CompilerError | undefined + compile(``, { onWarn: e => (err = e) }) + compile(`

`, { onWarn: e => (err = e) }) + expect(err).toBeUndefined() + }) + it('should not warn with select > hr', () => { let err: CompilerError | undefined compile(``, { diff --git a/packages/compiler-dom/src/htmlNesting.ts b/packages/compiler-dom/src/htmlNesting.ts index 5f924880bd0..8f361f84c37 100644 --- a/packages/compiler-dom/src/htmlNesting.ts +++ b/packages/compiler-dom/src/htmlNesting.ts @@ -62,8 +62,6 @@ const onlyValidChildren: Record> = { 'script', 'template', ]), - optgroup: new Set(['option']), - select: new Set(['optgroup', 'option', 'hr']), // table table: new Set(['caption', 'colgroup', 'tbody', 'tfoot', 'thead']), tr: new Set(['td', 'th']), @@ -74,7 +72,6 @@ const onlyValidChildren: Record> = { // these elements can not have any children elements script: emptySet, iframe: emptySet, - option: emptySet, textarea: emptySet, style: emptySet, title: emptySet,