-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Slotted elements missing in AST #6066
Comments
Hi! Is this somehow related to such compilation errors as below? Sometimes I get them on 6-7 components (mostly simple) that use slots. Couldn't reproduce it in REPL, unfortunately. ( Repeats unpredictably on 3.35.0 (only) during compilation.
|
@tanhauhau I'm looking at this now, and am a bit confused by what's going on. It looks like there's a
Is this intended? Did the AST change significantly with your changes for |
oh no 😦 I rearranged the children of the In this step, I mutated the AST node. (L114) svelte/src/compiler/compile/nodes/InlineComponent.ts Lines 109 to 150 in 1d6e20f
So, I have 2 options from here:
+ // assign back the children with updated children
+ info.children = children
this.children = map_children(component, this, this.scope, children);
svelte/src/compiler/compile/Component.ts Lines 117 to 124 in 2925a00
this.original_ast = {
html: JSON.parse(JSON.stringify(ast.html)),
css: ast.css,
instance: ast.instance && JSON.parse(JSON.stringify(ast.instance)),
module: ast.module
}; or rather this.original_ast = JSON.parse(JSON.stringify({
html: ast.html,
css: ast.css,
instance: ast.instance,
module: ast.module
})); |
Maybe it is better to involve community in testing this sort of changes in their production projects before pushing it to the master? Tell them what to look for or something. Current way of getting to know something has regressed involves reading PR diffs and trying to speculate on that. But that could be more transparently communicated from feature-pushers, saving time and making bug-squashing a more straightforward process. 🤔 FAQ assures that you shouldn't bother with testing svelte implementation details: https://svelte.dev/faq#how-do-i-test-svelte-apps I think it would be better to live up to that expectation. |
@Conduitry can you elaborate on what you found funny? |
This problem is entirely internal. The AST is no specced and we make no guarantees of its stability. This has zero implication on production applications as it does not change the output of the compiler. |
@pngwn I wouldn't write that if we didn't end up in a situation where 3.35 randomly throws compilation errors on components with slots. |
Open a new issue with a simple reproduction. |
@tanhauhau I probably wouldn't be against cloning the whole AST. I do think I would want to try something like lukeed's https://github.com/lukeed/klona though, rather than |
One issue with the above suggestion of cloning the whole AST at that point for use later is that we'd fail the https://github.com/sveltejs/svelte/tree/master/test/parser/samples/textarea-children test, because we'd now be returning the |
I want to point out that language tools (with svelte2tsx), the prettier plugin and the eslint plugin all rely on the AST to some extend, so while the API is technically private, it's still something we can't change it at will. |
Base on this issue message it's can be only SSR render but base on user's reports they don't use SSR. It's strange. |
Describe the bug
The AST for components using a slotted element is missing the slotted element.
Logs
n/a
To Reproduce
Compile
<Component><div slot='foo'></div></Component>
with Svelte 3.35.0 and look at the AST.Expected behavior
The AST should be as it was in 3.34.0 and include the
<div>
.Stacktraces
n/a
Information about your Svelte project:
Svelte 3.35.0
Severity
The right JS code looks like it's still being generated, so this isn't huge. But it will affect tooling. Medium-high I'd say.
Additional context
This was brought to light by sveltejs/eslint-plugin-svelte3#94
The text was updated successfully, but these errors were encountered: