Comments (5)
I see what's happening here although I'm not stoked about it. Basically the generated HTML is different than the template. Chrome and I imagine many browsers automatically add <tbody>
elements when the innerHTML is set which messes with the parsers ability to walk the tree at compile time since it's not there. You can fix this issue by adding the <tbody>
tag but it is definitely going to catch people.
It seems possible to to detect this in the template and always add tbody if it is missing, but I'm unsure of what other gotchas we are going to hit like this which browser is a lot more forgiving of differently formed html (fixing it as it sees fit) differing from the template actually provided.
Either bug location is fine. People generally provide a nice example that is reproduceable with Solid code so here works. Even if it often doesn't lead to a Solid fix so I don't get to leverage tying my git commits to the issue, I feel that a lot more minor of a thing.
EDIT:
It looks like Chrome only adds the tbody if it is part of a template clone or innerHTML which means that I don't have to worry about about the Component wrapping a tr
issue (making it unable to be detected). Essentially if in a given template if I encounter table
I should check for tr direct descendants. If there are any I should wrap all children in a tbody
and continue parsing.
from solid.
👍 thanks for the clarification! I wasn't aware of such behavior and thought using tbody
is optional for tables without a header because it always worked fine in other frameworks. Even if I knew it, I would have expected to just render the malformed HTML.
I'm wondering if there are more of these cases of magically added nodes? I found at least one other: If you omit the table
tag altogether, but have a tbody
it also crashes.
from solid.
Yeah it is going to be difficult to impossible for me to handle all the cases. I'm not sure how many I should chase after. Maybe I could do some detection of html structure at compile time and throw errors so at least there is no runtime issue. However, it would be difficult to guarantee jsdom etc would have the same output. I could also do a check at runtime on template creation. Maybe that's enough for now.
Basically there is code that looks like:
const template = document.createElement('template');
template.innerHTML = templateString;
I could do a check at that point to ensure template.innerHTML === templateString
. It puts the onus on the developer to make well formed JSX. Opinion?
from solid.
Yes, a clear error message seems to be the best option, either at compile time or run time.
from solid.
Fixed with a runtime check in v0.9.0.
from solid.
Related Issues (20)
- Typo found in signal.ts? HOT 3
- Circular references in Stores trigger loss of proxying if non-trackable objects are referenced HOT 5
- Changing the "data-type" of a `createStore` attribute causes referenced data to be modified HOT 1
- `value` parameter of `createEffect` is not passed to `on` as `prevValue` when `defer` is `true`. HOT 1
- using createStore setter function to update array results in argument is not iterable error HOT 3
- Solidjs is not working with bun.
- Laggy Performance HOT 4
- Unable to pass signal to child components HOT 1
- ReferenceError: XXX is not defined when using createResource HOT 3
- 2-way binding for computationally expensive effects
- `createResource` seems to fail to trigger fetcher when source signal changes HOT 1
- Why can't my code use context? HOT 9
- Setting properties to the unwrapped value of a store doesn't always propagate into the store HOT 14
- If a function wrapped in `action` throws some error it should be possible to `catch` it. HOT 1
- Isomorphic export with `solid-js/web` HOT 3
- Feature request: package entry point for reactive core HOT 1
- Trying to access fields of data from `createResource` throws error HOT 2
- Why the element between Shows is removed? HOT 4
- useTransition pending states should be isolated in different Suspense boundaries HOT 2
- 'reconcile' mutates array items HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from solid.