Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 2 commits
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
12 changes: 11 additions & 1 deletion packages/compiler-dom/src/htmlNesting.ts
LittleSound marked this conversation as resolved.
Show resolved Hide resolved
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
1 change: 1 addition & 0 deletions packages/compiler-dom/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,5 @@ export {
DOMErrorMessages,
} from './errors'
export { resolveModifiers } from './transforms/vOn'
export { isValidHTMLNesting } from './htmlNesting'
export * from '@vue/compiler-core'
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
Loading