Skip to content
This repository was archived by the owner on Jul 19, 2025. It is now read-only.

refactor(compiler-dom/vapor): reuse html nesting from compiler-dom #298

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat(compiler-core/vapor): reuse html nesting from compiler-dom
related #293
  • Loading branch information
Doctor-wu committed Dec 1, 2024
commit 16eed23084534d4ee0872c56eba4a2413aacc7d1
12 changes: 11 additions & 1 deletion packages/compiler-dom/src/htmlNesting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,18 @@ const onlyValidChildren: Record<string, Set<string>> = {
'template',
]),
optgroup: new Set(['option']),
/**
* Though validate-html-nesting declared hr is not a valid child of select
* Keep hr as valid select children, Referring https://html.spec.whatwg.org/multipage/grouping-content.html#the-hr-element
*/
select: new Set(['optgroup', 'option', 'hr']),
/**
* Though validate-html-nesting declared math should only have mrow as it's children
* Referring mathml-core spec, it's not fact
* https://w3c.github.io/mathml-core/#dfn-mrow
*/
// math: new Set(['mrow']),
script: new Set(),
// table
table: new Set(['caption', 'colgroup', 'tbody', 'tfoot', 'thead']),
tr: new Set(['td', 'th']),
Expand All @@ -67,7 +78,6 @@ const onlyValidChildren: Record<string, Set<string>> = {
thead: new Set(['tr']),
tfoot: new Set(['tr']),
// these elements can not have any children elements
script: emptySet,
iframe: emptySet,
option: emptySet,
textarea: emptySet,
Expand Down
2 changes: 2 additions & 0 deletions packages/compiler-dom/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
noopDirectiveTransform,
} from '@vue/compiler-core'
import { parserOptions } from './parserOptions'
import { isValidHTMLNesting } from './htmlNesting'
import { transformStyle } from './transforms/transformStyle'
import { transformVHtml } from './transforms/vHtml'
import { transformVText } from './transforms/vText'
Expand All @@ -23,6 +24,7 @@ import { validateHtmlNesting } from './transforms/validateHtmlNesting'
import { extend } from '@vue/shared'

export { parserOptions }
export { isValidHTMLNesting }

export const DOMNodeTransforms: NodeTransform[] = [
transformStyle,
Expand Down
196 changes: 0 additions & 196 deletions packages/compiler-vapor/src/html-nesting.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/compiler-vapor/src/transforms/transformElement.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { isValidHTMLNesting } from '../html-nesting'
import {
type AttributeNode,
type ComponentNode,
Expand Down Expand Up @@ -37,6 +36,7 @@ import {
} from '../ir'
import { EMPTY_EXPRESSION } from './utils'
import { findProp } from '../utils'
import { isValidHTMLNesting } from '@vue/compiler-dom'

export const isReservedProp: (key: string) => boolean = /*#__PURE__*/ makeMap(
// the leading comma is intentional so empty string "" is also included
Expand Down