feat(core): validate directives names (#326)

This commit is contained in:
Dmitry Sharshakov
2019-10-18 19:34:45 +03:00
committed by Evan You
parent 60961ef5b6
commit 2238925fbe
4 changed files with 55 additions and 4 deletions

View File

@@ -12,7 +12,7 @@ return applyDirectives(h(comp), [
*/
import { VNode, cloneVNode } from './vnode'
import { extend, isArray, isFunction, EMPTY_OBJ } from '@vue/shared'
import { extend, isArray, isFunction, EMPTY_OBJ, makeMap } from '@vue/shared'
import { warn } from './warning'
import { ComponentInternalInstance } from './component'
import { currentRenderingInstance } from './componentRenderUtils'
@@ -51,6 +51,16 @@ type DirectiveModifiers = Record<string, boolean>
const valueCache = new WeakMap<Directive, WeakMap<any, any>>()
const isBuiltInDirective = /*#__PURE__*/ makeMap(
'bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text'
)
export function validateDirectiveName(name: string) {
if (isBuiltInDirective(name)) {
warn('Do not use built-in directive ids as custom directive id: ' + name)
}
}
function applyDirective(
props: Record<any, any>,
instance: ComponentInternalInstance,