mirror of https://github.com/vuejs/core.git
perf(compiler-vapor): use array instead of regex
This commit is contained in:
parent
d3baff92b1
commit
86ed0eddae
|
@ -388,12 +388,11 @@ function processDynamicChildren(ctx: TransformContext<RootNode | ElementNode>) {
|
|||
}
|
||||
|
||||
export function createStructuralDirectiveTransform(
|
||||
name: string | RegExp,
|
||||
name: string | string[],
|
||||
fn: StructuralDirectiveTransform,
|
||||
): NodeTransform {
|
||||
const matches = isString(name)
|
||||
? (n: string) => n === name
|
||||
: (n: string) => name.test(n)
|
||||
const matches = (n: string) =>
|
||||
isString(name) ? n === name : name.includes(n)
|
||||
|
||||
return (node, context) => {
|
||||
if (node.type === NodeTypes.ELEMENT) {
|
||||
|
|
|
@ -20,7 +20,7 @@ import {
|
|||
import { extend } from '@vue/shared'
|
||||
|
||||
export const transformVIf = createStructuralDirectiveTransform(
|
||||
/^(if|else|else-if)$/,
|
||||
['if', 'else', 'else-if'],
|
||||
processIf,
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue