feat: v-once

Note: only compiler transform is tested - integration with runtime
still needs to be tested.
This commit is contained in:
Evan You
2019-10-09 17:32:58 -04:00
parent 5dfb271551
commit 93c6aa4c90
7 changed files with 63 additions and 13 deletions

View File

@@ -1,26 +1,24 @@
import {
parse,
transform,
CompilerOptions,
ElementNode
ElementNode,
CallExpression
} from '@vue/compiler-core'
import { transformCloak } from '../../src/transforms/vCloak'
import { transformElement } from '../../../compiler-core/src/transforms/transformElement'
import { CallExpression } from '../../src'
function transformWithCloak(template: string, options: CompilerOptions = {}) {
function transformWithCloak(template: string) {
const ast = parse(template)
transform(ast, {
nodeTransforms: [transformElement],
directiveTransforms: {
cloak: transformCloak
},
...options
}
})
return ast.children[0] as ElementNode
}
describe('compiler: `v-cloak` transform', () => {
describe('compiler: v-cloak transform', () => {
test('should add no props to DOM', () => {
const node = transformWithCloak(`<div v-cloak/>`)
const codegenArgs = (node.codegenNode as CallExpression).arguments