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

Supporting iterable collections #294

Open
pyrmont opened this issue Nov 20, 2023 · 4 comments
Open

Supporting iterable collections #294

pyrmont opened this issue Nov 20, 2023 · 4 comments

Comments

@pyrmont
Copy link

pyrmont commented Nov 20, 2023

My understanding is that Solid.js uses this library to convert JSX to JavaScript that manipulates the DOM.

In experimenting with the Squint library, I've noticed that if a JSX value contains a custom collection of JSX nodes that are not in an array, these nodes are not inserted in the DOM. Instead, a warning message is printed to the console stating Unrecognized value. Skipped inserting. I assume this message is generated by the following code:

cleanChildren(parent, current, null, value);
} else if (current == null || current === "" || !parent.firstChild) {
parent.appendChild(value);
} else parent.replaceChild(value, parent.firstChild);
current = value;
} else if ("_DX_DEV_") console.warn(`Unrecognized value. Skipped inserting`, value);
return current;
}
function normalizeIncomingArray(normalized, array, current, unwrap) {

If the collection is iterable (i.e. it has Symbol.iterator set), is there a reason not to iterate over it and extract its elements that way? A number of Squint's functions return a LazyIterable object rather than an array, and it would be helpful if those were supported.

@borkdude
Copy link

Note that React supports anything that has [Symbol.iterator]().

@lxsmnsyc
Copy link
Collaborator

React has only recently started supporting iterables, but yes, there is some things to be discussed whether or not this is worth adding.

@borkdude
Copy link

I've been using it in React for over a year, FWIW

@ryansolid
Copy link
Owner

I wonder would we need to expand support for things like For. Because it isn't only the JSX insertion but anything that maps it I imagine.

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

4 participants