Skip to content

Commit bed015b

Browse files
committed
don't allow children in svelte:options
1 parent f632b2a commit bed015b

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

.changeset/smooth-kids-protect.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"svelte": patch
3+
---
4+
5+
breaking: don't allow children in svelte:options

packages/svelte/src/compiler/phases/1-parse/state/element.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export default function tag(parser) {
101101
if (root_only_meta_tags.has(name)) {
102102
if (is_closing_tag) {
103103
if (
104-
(name === 'svelte:window' || name === 'svelte:body' || name === 'svelte:document') &&
104+
['svelte:options', 'svelte:window', 'svelte:body', 'svelte:document'].includes(name) &&
105105
/** @type {import('#compiler').ElementLike} */ (parent).fragment.nodes.length
106106
) {
107107
error(
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { test } from '../../test';
2+
3+
export default test({
4+
error: {
5+
code: 'invalid-element-content',
6+
message: '<svelte:options> cannot have children',
7+
position: [16, 16]
8+
}
9+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<svelte:options>contents</svelte:options>

0 commit comments

Comments
 (0)