fix(runtime-core): support object syntax for class (#215)

This commit is contained in:
Illya Klymov
2019-10-11 22:09:37 +03:00
committed by Evan You
parent 5f28708cb9
commit e32da9169b
2 changed files with 18 additions and 5 deletions

View File

@@ -13,3 +13,19 @@ it('should support on-the-fly template compilation', () => {
createApp().mount(App, container)
expect(container.innerHTML).toBe(`0`)
})
it('should correctly normalize class with on-the-fly template compilation', () => {
const container = document.createElement('div')
const App = {
template: `<div :class="{ test: demoValue, test2: !demoValue }"></div>`,
data() {
return {
demoValue: true
}
}
}
createApp().mount(App, container)
const classes = container.firstElementChild!.classList
expect(classes.contains('test')).toBe(true)
expect(classes.contains('test2')).toBe(false)
})