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

Error compiling component when <option> without value attribute contains <slot /> #2723

Closed
trbrc opened this issue May 8, 2019 · 5 comments

Comments

@trbrc
Copy link
Contributor

trbrc commented May 8, 2019

A component with an <option> tag that has no value attribute and contains another tag, such as <slot />, will refuse to compile with a vague error:

/* Error compiling component

undefined is not an object (evaluating 'this.node.start')

*/

Reproduction: https://svelte.dev/repl/676c6c2d7a8a4684a261935c488b763a?version=3.20.1

Changing it to <option value><slot/></option> is enough to make it work.

@EmilTholin
Copy link
Member

EmilTholin commented May 8, 2019

You are on a roll @trbrc. Thank you so much! It's very much appreciated!

It seems that an Expression is created with info set to undefined, so when start is accessed on this.node the error is thrown. Very interesting.

@EmilTholin
Copy link
Member

Svelte can't currently handle anything other than pure text as option content if no value attribute is given. E.g. a p element instead of a slot throws the same error.

I'm not sure how far we want to go with this. Possibly walk the option content and concatenate all the text (like the browser does), and take the slot content if it's a slot?

@Conduitry Conduitry added feature request awaiting submitter needs a reproduction, or clarification labels Sep 21, 2019
@trbrc
Copy link
Contributor Author

trbrc commented Oct 26, 2019

@Conduitry I just saw the request for clarification. What kind of clarification are you looking for?

I realize this is not a high priority bug, as it's a corner case with low real world impact, but I would suggest it's a bug rather than request for enhancement. Getting a vague compiler error in this scenario can't be the correct behavior, and it's not obvious that adding the value attribute would fix it.

@antony antony added bug and removed awaiting submitter needs a reproduction, or clarification labels Apr 9, 2020
@antony
Copy link
Member

antony commented Apr 9, 2020

Changing to bug as I can see that this isn't the correct behaviour given the REPL. What the correct behaviour (gracefully just render, or add a dev warning) is though, I don't know.

@Rich-Harris
Copy link
Member

This works in Svelte 5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants