-
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
Props are not reseted properly #415
Comments
I don't use the |
@mightyiam hummm oki but is there an explanation for this behaviour? Should I expect the same thing for other props? This is a scary and look like a bug no? |
I have been answered, any prop will behave like this: https://codesandbox.io/s/2x7nrlk23j How is it possible to have this behaviour being the norm and not have massive bugs all over the place? Maybe I misunderstand something about props? |
@batiste it seems that the props module does not remove props when they are not specified. This is probably expected behavior. To "remove" a prop, set it to the empty string or whatever is correct to do. |
I thought it was the job of snabbdom diff algorithm to do that for me. I cannot "remove a prop" by setting an empty string because I have no idea which node is what and frankly in my app they are completely different VNodes that have nothing in common with each other. But snabbdom seems to have decided to recycle those VNode because they are similar or have more or less the same position in the tree... But then it doesn't reset the props? I am just very surprised I am the first to run into those issues as it seems such a basic need... |
Also if I read this code right: https://github.com/snabbdom/snabbdom/blob/master/src/modules/props.ts#L16-L20 It seems that the old props should be deleted from the element itself? But it doesn't quite work? |
Humm I think I should be using the attribute module instead. The prop is something quite different. |
This will work: className is a special property, it cant be deleted |
@blikblum oki but look at id for example here: https://codesandbox.io/s/2x7nrlk23j This is the same thing. Id is not deleted. |
id is also special |
Regarding recycling of VNodes, perhaps the |
I mean the key does help but it is a ridiculous requirement. I will not add a Math.random() on each elements so the props are properly reseted... I got the behaviour I wanted using the attributes module though. Props seems more about storing data onto the VNodes? I am not quite sure what is the fundamental difference between the 2 modules as they seems to cover more or less the same needs but in a different way. @blikblum what about href? Every-time I try a different prop, the behaviour is the same. Is there really a prop that is properly reseted on the Native DOM? If there is a prop that behave "properly" I would be glad to be pointed to one. |
These native dom properties probably are defined as accessors so could not be deleted Maybe this should work:
I suggest doing a PR with a test if it fix your problem |
With something like |
So you should use attrs module not props |
@blikblum I agree but then why is the prop module is advertised in the README? Who is using it and for what purpose? |
Here is a PR #416 |
BREAKING CHANGE: props module does not attempt to delete node properties. This may affect you if you are using the props module to add non-native (custom) properties to DOM nodes. Instead, it is recommended to use _data-* attributes_. https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes Fixes #623. Fixes #283. Closes #415. Closes #307.
BREAKING CHANGE: props module does not attempt to delete node properties. This may affect you if you are using the props module to add non-native (custom) properties to DOM nodes. Instead, it is recommended to use _data-* attributes_. https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes Fixes #623. Fixes #283. Closes #415. Closes #307.
BREAKING CHANGE: props module does not attempt to delete node properties. This may affect you if you are using the props module to add non-native (custom) properties to DOM nodes. Instead, it is recommended to use _data-* attributes_. https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes Fixes #623. Fixes #283. Closes #415. Closes #307.
BREAKING CHANGE: props module does not attempt to delete node properties. This may affect you if you are using the props module to add non-native (custom) properties to DOM nodes. Instead, it is recommended to use _data-* attributes_. https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes Fixes #623. Fixes #283. Closes #415. Closes #307.
BREAKING CHANGE: props module does not attempt to delete node properties. This may affect you if you are using the props module to add non-native (custom) properties to DOM nodes. Instead, it is recommended to use _data-* attributes_. https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes Fixes #623. Fixes #283. Closes #415. Closes #307.
BREAKING CHANGE: props module does not attempt to delete node properties. This may affect you if you are using the props module to add non-native (custom) properties to DOM nodes. Instead, it is recommended to use _data-* attributes_. https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes Fixes #623. Fixes #283. Closes #415. Closes #307.
BREAKING CHANGE: props module does not attempt to delete node properties. This may affect you if you are using the props module to add non-native (custom) properties to DOM nodes. Instead, it is recommended to use _data-* attributes_. https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes Fixes #623. Fixes #283. Closes #415. Closes #307.
BREAKING CHANGE: props module does not attempt to delete node properties. This may affect you if you are using the props module to add non-native (custom) properties to DOM nodes. Instead, it is recommended to use _data-* attributes_. https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes Fixes #623. Fixes #283. Closes #415. Closes #307.
BREAKING CHANGE: props module does not attempt to delete node properties. This may affect you if you are using the props module to add non-native (custom) properties to DOM nodes. Instead, it is recommended to use _data-* attributes_. https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes Fixes #623. Fixes #283. Closes #415. Closes #307. Closes #151. Closes #307. Closes #416.
BREAKING CHANGE: props module does not attempt to delete node properties. This may affect you if you are using the props module to add non-native (custom) properties to DOM nodes. Instead, it is recommended to use _data-* attributes_. https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes Fixes #623. Fixes #283. Closes #415. Closes #307. Closes #151. Closes #416.
BREAKING CHANGE: props module does not attempt to delete node properties. This may affect you if you are using the props module to add non-native (custom) properties to DOM nodes. Instead, it is recommended to use _data-* attributes_. https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes Fixes #623. Fixes #283. Closes #415. Closes #307. Closes #151. Closes #416.
BREAKING CHANGE: props module does not attempt to delete node properties. This may affect you if you are using the props module to add non-native (custom) properties to DOM nodes. Instead, it is recommended to use _data-* attributes_. https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes Fixes #623. Fixes #283. Closes #415. Closes #307. Closes #151. Closes #416.
BREAKING CHANGE: props module does not attempt to delete node properties. This may affect you if you are using the props module to add non-native (custom) properties to DOM nodes. Instead, it is recommended to use _data-* attributes_. https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes Fixes #623. Fixes #283. Closes #415. Closes #307. Closes #151. Closes #416.
I would like to know if this is a bug or is it the intended behaviour:
https://codesandbox.io/s/ppn1y5okjq
Please enlighten me about how to use snabbdom. I use it for little toy language here https://github.com/batiste/blop-language and I am running into funny bugs
The text was updated successfully, but these errors were encountered: