-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Svelte 5: Placeholder in select not displayed #12152
Comments
Apparently something in the No rest props to rest props diff import * as $ from "svelte/internal/client";
-var root = $.template(`<select name="pets" id="pet-select1"><!></select>`);
+var root = $.template(`<select><!></select>`);
export default function Select($$anchor, $$props) {
+ const $$sanitized_props = $.legacy_rest_props($$props, [
+ "children",
+ "$$slots",
+ "$$events",
+ "$$legacy"
+ ]);
+
+ const $$restProps = $.legacy_rest_props($$sanitized_props, []);
var select = root();
+ let attributes;
+
+ $.init_select(select, () => attributes.value);
+
var node = $.child(select);
$.slot(node, $.default_slot($$props), {}, null);
+
+ $.template_effect(() => {
+ attributes = $.set_attributes(
+ select,
+ attributes,
+ {
+ name: "pets",
+ id: "pet-select1",
+ ...$$restProps
+ },
+ true,
+ ""
+ );
+
+ if ("value" in attributes) {
+ $.select_option(select, attributes.value);
+ }
+ });
+
$.append($$anchor, select);
} Migrating the code to the runes equivalent does not affect the result. Explicit declaration and setting of <script>
export let value = '';
</script>
<select name="pets" id="pet-select1" {value} {...$$restProps}> |
use chidren and props |
^ correct solution above. Svelte 5 == children snippets instead of slots. They're also not placeholders. Those are actual options in the |
Whether it's legacy or runes does not matter, it's broken either way. |
For a legacy project, I can't use |
Ah, this seems to be an issue with the internal |
Describe the bug
demo
As you can see in the above image, a placeholder, "--Please choose an option--" is not displayed when I use a component.
Both selects are identical but using component doesn't show the placeholder.
Select.svelte
App.svelte
Reproduction
demo
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: