-
-
Notifications
You must be signed in to change notification settings - Fork 33.6k
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
Patched elements keep inline styles from old vnodes #4227
Comments
This might be related to #4205. But I'm not sure. Can you try adding a key property to section? Online repro: |
@HerringtonDarkholme it's definitely related. Still a little annoying to have to deal with this... Adding the |
@Igdexter
We're on it vuejs/v2.vuejs.org#587 |
@LinusBorg cool, thanks for the quick response. had quite a shock in my staging environment today with 2.0.7 |
This is not an intended breaking change, mind you. It's generally expected behaviour in many situations, but as already mentioned, documentation about this is still lacking. I assume that this worked "accidentally" before, and recent fixes of bugs which, amongst other things, related to handling of style and class bindings, might have changed that. |
@LinusBorg I wonder whether this is a correct behavior. The example above can be diffed solely by v-dom. The style attribute should be considered as a v-dom construct. By comparison, consider this example. https://jsfiddle.net/gw8g8cos/4/ Note, this issue is different from #4205 , since lifecycle is not managed by virtual dom. cc @defcc |
@LinusBorg I'm guessing the improvement to preserve static inline styles with dynamic inline styles as per #4138 is what made this issue apparent now. I'm just wondering if this is the correct behavior. Here it's comparing the old node with the new node and then applying the necessary style changes, but the code seems to be merging them. Reusing the same node is fine; I just think it should keep only the styles for the active node that needs to be represented on the DOM. Edited the OP in light of the new info |
Hm you might be right. |
Seems to be something wrong with static style and style binding merge. I am looking into it. |
https://github.com/vuejs/vue/blob/dev/src/platforms/web/runtime/modules/style.js#L48 const style = normalizeStyleBinding(vnode.data.style) || {}
vnode.data.style = style.__ob__ ? extend({}, style) : style
const newStyle = getStyle(vnode, true) The style now only holds the style binding, which will be removed in the next render. The static style and style binding should be removed both when reusing the same node. |
I'll make a PR to fix it |
Vue.js version
2.0.6+
Reproduction Link
https://jsfiddle.net/gw8g8cos/
Steps to reproduce
What is Expected?
Patched elements should not keep inline styles from old vnodes.
What is actually happening?
During the update operation, patched elements will retain styles from vnodes that will no longer exist in the DOM.
Temporarily solution for end-users: changing inline styles to classes, choosing different tag names or adding a
key
directive will fix the issue. Thanks to @LinusBorg for the latter.It looks like this PR has introduced this regression #4138. I've opened a pull request with a failing test that confirms this issue.
The text was updated successfully, but these errors were encountered: