Skip to content

Commit 8bf5af8

Browse files
hashplusyyx990803
authored andcommitted
fix addClass utlil bug (#4863)
* fix addClass util bug `<transition-group move-class=“ value with leading or trailing whitespace ” />` * fix addClass util bug `<transition-group move-class=“ value with leading or trailing whitespace ” />` * fix addClass util bug `<transition-group move-class=“ value with leading or trailing whitespace ” />` * update test case for `addClass / removeClass` util
1 parent e853d19 commit 8bf5af8

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/platforms/web/runtime/class-util.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
export function addClass (el: Element, cls: ?string) {
88
/* istanbul ignore if */
9-
if (!cls || !cls.trim()) {
9+
if (!cls || !(cls = cls.trim())) {
1010
return
1111
}
1212

@@ -31,7 +31,7 @@ export function addClass (el: Element, cls: ?string) {
3131
*/
3232
export function removeClass (el: Element, cls: ?string) {
3333
/* istanbul ignore if */
34-
if (!cls || !cls.trim()) {
34+
if (!cls || !(cls = cls.trim())) {
3535
return
3636
}
3737

test/unit/features/transition/transition.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ if (!isIE9) {
7373
enter-to-class="hello-to"
7474
leave-class="bye"
7575
leave-to-class="bye-to"
76-
leave-active-class="byebye active">
76+
leave-active-class="byebye active more ">
7777
<div v-if="ok" class="test">foo</div>
7878
</transition>
7979
</div>
@@ -85,9 +85,9 @@ if (!isIE9) {
8585
expect(vm.$el.innerHTML).toBe('<div class="test">foo</div>')
8686
vm.ok = false
8787
waitForUpdate(() => {
88-
expect(vm.$el.children[0].className).toBe('test bye byebye active')
88+
expect(vm.$el.children[0].className).toBe('test bye byebye active more')
8989
}).thenWaitFor(nextFrame).then(() => {
90-
expect(vm.$el.children[0].className).toBe('test byebye active bye-to')
90+
expect(vm.$el.children[0].className).toBe('test byebye active more bye-to')
9191
}).thenWaitFor(duration + buffer).then(() => {
9292
expect(vm.$el.children.length).toBe(0)
9393
vm.ok = true

0 commit comments

Comments
 (0)