fix(runtime-core): avoid mutating EMPTY_ARR when setting dev root (#2419)

also freeze EMPTY_ARR in dev

fix #2413
This commit is contained in:
被雨水过滤的空气
2020-10-20 06:08:54 +08:00
committed by GitHub
parent e894caf731
commit edd49dcab4
5 changed files with 21 additions and 8 deletions

View File

@@ -1,3 +1,4 @@
import { EMPTY_ARR } from '@vue/shared'
import { createApp, ref, nextTick, reactive } from '../src'
describe('compiler + runtime integration', () => {
@@ -281,4 +282,14 @@ describe('compiler + runtime integration', () => {
await nextTick()
expect(container.innerHTML).toBe(`<div>2<div>1</div></div>`)
})
// #2413
it('EMPTY_ARR should not change', () => {
const App = {
template: `<div v-for="v of ['a']">{{ v }}</div>`
}
const container = document.createElement('div')
createApp(App).mount(container)
expect(EMPTY_ARR.length).toBe(0)
})
})