Skip to content

Commit

Permalink
feat(compiler-core/vapor): reuse html nesting from compiler-dom
Browse files Browse the repository at this point in the history
related #293
  • Loading branch information
Doctor-wu committed Dec 1, 2024
1 parent f0361ba commit 16eed23
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 198 deletions.
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

0 comments on commit 16eed23

Please sign in to comment.