-
Notifications
You must be signed in to change notification settings - Fork 124
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
validates whole partial #350
base: main
Are you sure you want to change the base?
Conversation
… to error message
I have added this validation to my transform, running it against my full docs site found two things to handle (now fixed):
|
Improvement:
Testing the code from the linked issue: Document.parseHTMLUnsafe(`
<table><thead><tr>#text</tr></thead></table>
`).body.innerHTML yields
This is now handled by the previous commit |
The following thread has a weird use case of trying to do something ilegal. They are trying to stop the event from bubbling to the other form. <form>
<Portal>
<form>
<button type="submit" /> submit events
</form>
</Portal>
</form> Nesting forms is disallowed, you can get nested forms by using the Anyway, what caught my attention about this, is that it will create 2 partials, and skip our validation. A possible solution, is to traverse the component ahead of time and accumulate the supposed JSX tags, to do something similar to uh, thinking a bit more, this example that came to mind will raise a validation error. But maybe.... on this case we can skip tables/tr/td validation, as these elements are the exception. Something to think <div>
<TableSomething>
<td>
<button type="submit" /> submit events
</td>
</TableSomething>
</div> |
This is a working proof of concept on validating the whole partial, that would need a few tweaks and real world testing.
Some context, tried to run a headless chrome instance to actually validate the partials with a real browser. The differences between es6/require and idk what else made me give up. Also, Im not so convinced that headless chrome will run on all the enviroments this is actually used, and could cause some problems. So been thinking the behaviour of
innerHTML
must be specified, and possiblyjsdom
(an already know dependency) could maybe do the work. After some tests, I suspect thats the case.Looking at an actual issue solidjs/solid#2279
running the following in chrome
yields
running the same through
jsdom
So I think it's safe to assume that
jsdom
may be used for validating complete partials, however, I'm not confident about how this will behave in the wild, it will need real world testing.Considerations:
main idea is to validate the nesting of markup, for this reason, html comments(possible to try to include them in the future if the approach works, because these are relevant to some rendering stuff), and text content is removed from the validation.throw path.buildCodeFrameError
it's showing an unrelated path, Im not sure if thats because of the test environment. I tried to show the relevant path but Im not that confident of the best location, so left it there for people that are more familiar.had to remove all the closing tags for the comparation, it would be better probably if we can have the string of the template with the closing tags, maybe astemplate.templateWithClosingTags
, so the comparation would be more faithful, and also at the same time we could be checking that omitting closing tags won't bring unknown problems.would be nice to provide a diff with the error messageRemaining validation related stuff that I could remember:
textnode cannot be child of TR [JSX Validation]: A <tr/> which has a direct child text should produce a validation error solidjs/solid#2183