-
-
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
Illegal invocation with snippet & action #14767
Comments
That's so weird...it only happens when the code is formatted exactly like this...if you add a tab before |
Ok i think i roughly nailed down the problem: since inside function flush_node(is_text, name) {
const expression = get_node(is_text);
let id = expression;
if (id.type !== 'Identifier') {
id = b.id(state.scope.generate(name));
state.init.push(b.var(id, expression));
}
prev = () => id;
skipped = 1; // the next node is `$.sibling(id)`
return id;
}
function flush_sequence(sequence) {
if (sequence.every((node) => node.type === 'Text')) {
skipped += 1;
state.template.push(sequence.map((node) => node.raw).join(''));
return;
}
state.template.push(' ');
const { has_state, has_call, value } = build_template_chunk(sequence, visit, state);
// if this is a standalone `{expression}`, make sure we handle the case where
// no text node was created because the expression was empty during SSR
const is_text = sequence.length === 1;
const id = flush_node(is_text, 'text');
const update = b.stmt(b.call('$.set_text', id, value));
if (has_call && !within_bound_contenteditable) {
state.init.push(build_update(update));
} else if (has_state && !within_bound_contenteditable) {
state.update.push(update);
} else {
state.init.push(b.stmt(b.assignment('=', b.member(id, 'nodeValue'), value)));
}
} so the output is var pre = root_1();
var code = $.sibling($.child(pre));
var span = $.sibling($.child(code));
var span_1 = $.child(span); the problem is that apparent when calling I tried to prevent the skipping if the sequence only contains one node which is a |
Uh actually update...this is literally only happening with |
We have custom logic for |
Nope it's literally the browser that does that (i also did it in codepen)...but we do need to add logic specifically for |
Describe the bug
Faced
TypeError: Illegal invocation
when trying to implement use:action, i don't know if it is a bug or an intended behaviorReproduction
managed to create repl: https://svelte.dev/playground/de25c600fb804678bc8915e33166a82c?version=5.14.4
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: