-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
style module: remove when no prop transition happens #712
Comments
@whitecolor perhaps a re-thinking of the mechanism. Could you please make a PR that adds a failing test for this? |
Check, please, this one without PR: it.only('handles remove style if no transition happens', function (done) {
var btn = h('button', {
style: {
transition: 'transform 0.1s',
remove: { transform: 'translateY(100%)' } as any
}
}, ['A button'])
var vnode1 = h('div.parent', {}, [btn])
var vnode2 = h('div.parent', {}, [null])
document.body.appendChild(vnode0)
patch(vnode0, vnode1)
var button = document.querySelector('button')!
button.style.transform = 'translateY(100%)'
let transitionEndCalled = 0
button.addEventListener('transitionend', function () {
transitionEndCalled++
})
patch(vnode1, vnode2)
assert.strictEqual(document.querySelector('button'), null)
setTimeout(() => {
assert.strictEqual(transitionEndCalled, 0, 'transitionEndCalled')
done()
}, 500)
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So the current version applies
remove
styles to the element, and wait alltransitionEnd
events. There is the edge case when the element (before removal) already got to the state where its style is the same withremove
's value. And in this case, there will be no transition happen and the element will not be removed from DOM eventually.It is not theoretical case I actually run into it.
I tried to solve this problem by comparing current (before removal) element actual style with remove props values. This would work in most of the cases, but there are cases where it will not, for example, if you want to set a value on
transform: translateX(100px)
, in dom in computed styles is value will bematrix(...)
, so you can not directly compare string style values, the same thing for calculated css values likecalc(...)
.@paldepind I wonder what do you think about the issue, is it needed/worth to handle this case?
The text was updated successfully, but these errors were encountered: