mirror of https://github.com/vuejs/core.git
test: v-once as root node (#2)
This commit is contained in:
parent
bdbd524d59
commit
9b2a6ffe70
|
|
@ -75,7 +75,21 @@ export function render() {
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`comile > directives > v-once 1`] = `
|
exports[`comile > directives > v-once > as root node 1`] = `
|
||||||
|
"import { watchEffect } from 'vue';
|
||||||
|
import { template, setAttr } from 'vue/vapor';
|
||||||
|
const t0 = template(\`<div></div>\`);
|
||||||
|
export function render() {
|
||||||
|
const n0 = t0();
|
||||||
|
watchEffect(() => {
|
||||||
|
setAttr(n0, 'id', undefined, foo);
|
||||||
|
});
|
||||||
|
return n0;
|
||||||
|
}
|
||||||
|
"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`comile > directives > v-once > basic 1`] = `
|
||||||
"import { template, children, insert, setText, setAttr } from 'vue/vapor';
|
"import { template, children, insert, setText, setAttr } from 'vue/vapor';
|
||||||
const t0 = template(\`<div> <span></span></div>\`);
|
const t0 = template(\`<div> <span></span></div>\`);
|
||||||
export function render() {
|
export function render() {
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,8 @@ describe('comile', () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
test('v-once', async () => {
|
describe('v-once', () => {
|
||||||
|
test('basic', async () => {
|
||||||
const code = await compile(
|
const code = await compile(
|
||||||
`<div v-once>
|
`<div v-once>
|
||||||
{{ msg }}
|
{{ msg }}
|
||||||
|
|
@ -107,5 +108,12 @@ describe('comile', () => {
|
||||||
)
|
)
|
||||||
expect(code).matchSnapshot()
|
expect(code).matchSnapshot()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test.fails('as root node', async () => {
|
||||||
|
const code = await compile(`<div :id="foo" v-once />`)
|
||||||
|
expect(code).toMatchSnapshot()
|
||||||
|
expect(code).not.contains('watchEffect')
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue