Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly disable a transition by setting it to false (fix #9320) #9366

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/platforms/web/runtime/components/transition.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ function getRealChild (vnode: ?VNode): ?VNode {
}
}

function isAttrDisabled (k: string): boolean {
var data: Object = this;
const attr = data[camelize(k)]
return typeof attr == "undefined" ||
typeof attr !== "undefined" &&
(typeof attr === "boolean" && attr ||
Itisfilipe marked this conversation as resolved.
Show resolved Hide resolved
typeof attr === "string" && attr == "false")
}

export function extractTransitionData (comp: Component): Object {
const data = {}
const options: ComponentOptions = comp.$options
Expand All @@ -49,9 +58,11 @@ export function extractTransitionData (comp: Component): Object {
}
// events.
// extract listeners and pass them directly to the transition methods
const listeners: ?Object = options._parentListeners
for (const key in listeners) {
data[camelize(key)] = listeners[key]
const listeners: Object = options._parentListeners || {}
// remove the listeners that are explicitily disabled
const listenerKeys: Array<string> = Object.keys(listeners).filter(isAttrDisabled, data)
for (let i = 0; i < listenerKeys.length; i++) {
data[camelize(listenerKeys[i])] = listeners[listenerKeys[i]]
}
return data
}
Expand Down
24 changes: 24 additions & 0 deletions test/unit/features/transition/transition.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,30 @@ if (!isIE9) {
}).then(done)
})

it('appear: false', done => {
let next
const vm = new Vue({
template: `
<div>
<transition name="test" :appear="false" @appear="appear" >
posva marked this conversation as resolved.
Show resolved Hide resolved
<div v-if="ok" class="test">foo</div>
</transition>
</div>
`,
data: { ok: true },
methods: {
appear: (el, cb) => {
next = cb
}
}
}).$mount(el)

waitForUpdate(() => {
expect(vm.$el.children[0].className).toBe('test')
expect(next).toBeUndefined()
}).then(done)
})

it('transition on SVG elements', done => {
const vm = new Vue({
template: `
Expand Down