feat(types): deny unknown attributes on component by default (#1614)

close #1519
This commit is contained in:
HcySunYang
2020-07-17 23:43:28 +08:00
committed by GitHub
parent 77659fa037
commit 5d8a64d53a
11 changed files with 100 additions and 58 deletions

View File

@@ -197,7 +197,7 @@ function patchSuspense(
}
export interface SuspenseBoundary {
vnode: VNode
vnode: VNode<RendererNode, RendererElement, SuspenseProps>
parent: SuspenseBoundary | null
parentComponent: ComponentInternalInstance | null
isSVG: boolean

View File

@@ -11,6 +11,8 @@ import { VNode, VNodeArrayChildren, VNodeProps } from '../vnode'
import { isString, ShapeFlags } from '@vue/shared'
import { warn } from '../warning'
export type TeleportVNode = VNode<RendererNode, RendererElement, TeleportProps>
export interface TeleportProps {
to: string | RendererElement
disabled?: boolean
@@ -55,8 +57,8 @@ const resolveTarget = <T = RendererElement>(
export const TeleportImpl = {
__isTeleport: true,
process(
n1: VNode | null,
n2: VNode,
n1: TeleportVNode | null,
n2: TeleportVNode,
container: RendererElement,
anchor: RendererNode | null,
parentComponent: ComponentInternalInstance | null,
@@ -85,10 +87,7 @@ export const TeleportImpl = {
insert(placeholder, container, anchor)
insert(mainAnchor, container, anchor)
const target = (n2.target = resolveTarget(
n2.props as TeleportProps,
querySelector
))
const target = (n2.target = resolveTarget(n2.props, querySelector))
const targetAnchor = (n2.targetAnchor = createText(''))
if (target) {
insert(targetAnchor, target)
@@ -165,7 +164,7 @@ export const TeleportImpl = {
// target changed
if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
const nextTarget = (n2.target = resolveTarget(
n2.props as TeleportProps,
n2.props,
querySelector
))
if (nextTarget) {
@@ -267,7 +266,7 @@ interface TeleportTargetElement extends Element {
function hydrateTeleport(
node: Node,
vnode: VNode,
vnode: TeleportVNode,
parentComponent: ComponentInternalInstance | null,
parentSuspense: SuspenseBoundary | null,
optimized: boolean,
@@ -284,7 +283,7 @@ function hydrateTeleport(
) => Node | null
): Node | null {
const target = (vnode.target = resolveTarget<Element>(
vnode.props as TeleportProps,
vnode.props,
querySelector
))
if (target) {