Skip to content

vanX reactive crash TypeError: keyToChild[k]?.remove is not a function with DocumentFragment #431

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

Open
ttyridal opened this issue Apr 6, 2025 · 2 comments

Comments

@ttyridal
Copy link

ttyridal commented Apr 6, 2025

Example fidle: https://jsfiddle.net/nudhLf6x/3/

a vanX.list items are dictionary (Object) itemFunc is returning DocumentFragment

calling vanX.replace to update the items of the list. Adding is fine, changing value is fine, but it fails when a key from the items object is removed.

Fails the same way if (vanX.list) items is an array and trying to vanX.replace with fewer items than current state.

main.js:21 triggered
van-x.nomodule.js:75 Uncaught (in promise) TypeError: keyToChild[k]?.remove is not a function
    at onDelete (van-x.nomodule.js:75:22)
    at Object.deleteProperty (van-x.nomodule.js:49:35)
    at replaceInternal (van-x.nomodule.js:97:61)
    at Object.replace (van-x.nomodule.js:118:14)
    at fetchstuff (main.js:22:10)

If I remove the DocumentFragment (ie letting GridRow return a div instead) it works fine, but my grid doesn't (no parent node in a css grid row)

Love VanJS by the way :)

@Tao-VanJS
Copy link
Member

VanJS doesn't support binding function to return a DocumentFragment. This is due to the limit of DOM. DocumentFragment is not a real element in the DOM true, its children will be fused into its parent element during the DOM tree construction.

@sirenkovladd
Copy link
Contributor

Unfortunately you can't you DocumentFragment like that
See more details here #422 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants