-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Closed as duplicate of#15617
Closed as duplicate of#15617
Copy link
Description
Describe the bug
According to MDN documentation for styling <select> elements (link), a first-child <button> is allowed in modern browsers as a means to style the element, and is progressively enhanced / ignored when unsupported.
However, putting HTML akin to the example in the MDN, where a <select> has a single <button> as the first child, triggers node_invalid_placement compiler error.
Reproduction
Put the following HTML in any Svelte file:
<select>
<!-- Select button -->
<button>
<selectedcontent></selectedcontent>
</button>
<option value="hello">Hello</option>
</select>
Logs
[Error [CompileError]: src/lib/Dashboard/sharedComponents/Dropdown.svelte:14:1 `<button>` cannot be a child of `<select>`. `<select>` only allows these children: `<option>`, `<optgroup>`, `<#text>`, `<hr>`, `<script>`, `<template>`. The browser will 'repair' the HTML (by moving, removing, or inserting elements) which breaks Svelte's assumptions about the structure of your components.
https://svelte.dev/e/node_invalid_placement]System Info
System:
OS: macOS 15.5
CPU: (10) arm64 Apple M1 Pro
Memory: 10.62 GB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.10.0 - /usr/local/bin/node
Yarn: 1.22.22 - /usr/local/bin/yarn
npm: 10.9.2 - /usr/local/bin/npm
pnpm: 10.4.1 - /usr/local/bin/pnpm
Browsers:
Safari: 18.5
npmPackages:
svelte: ^5.35.2 => 5.35.6Severity
annoyance
Metadata
Metadata
Assignees
Labels
No labels