You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentation/docs/02-template-syntax/01-component-fundamentals.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -161,16 +161,16 @@ If you'd like to react to changes to a prop, use the `$derived` or `$effect` run
161
161
162
162
For more information on reactivity, read the documentation around runes.
163
163
164
-
## <script context="module">
164
+
## <script module>
165
165
166
-
A `<script>` tag with a `context="module"` attribute runs once when the module first evaluates, rather than for each component instance. Values declared in this block are accessible from a regular `<script>` (and the component markup) but not vice versa.
166
+
A `<script>` tag with a `module` attribute runs once when the module first evaluates, rather than for each component instance. Values declared in this block are accessible from a regular `<script>` (and the component markup) but not vice versa.
167
167
168
168
You can `export` bindings from this block, and they will become exports of the compiled module.
169
169
170
170
You cannot `export default`, since the default export is the component itself.
171
171
172
172
```svelte
173
-
<script context="module">
173
+
<script module>
174
174
let totalComponents = 0;
175
175
176
176
// the export keyword allows this function to imported with e.g.
Copy file name to clipboardExpand all lines: packages/svelte/messages/compile-warnings/template.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,6 +50,10 @@ HTML restricts where certain elements can appear. In case of a violation the bro
50
50
51
51
This code will work when the component is rendered on the client (which is why this is a warning rather than an error), but if you use server rendering it will cause hydration to fail.
52
52
53
+
## script_context_deprecated
54
+
55
+
> `context="module"` is deprecated, use the `module` attribute instead
56
+
53
57
## slot_element_deprecated
54
58
55
59
> Using `<slot>` to render parent content is deprecated. Use `{@render ...}` tags instead
e(node,"declaration_duplicate_module_import","Cannot declare same variable name which is imported inside `<script context=\"module\">`");
107
+
e(node,"declaration_duplicate_module_import","Cannot declare same variable name which is imported inside `<script module>`");
108
108
}
109
109
110
110
/**
@@ -417,12 +417,12 @@ export function store_invalid_scoped_subscription(node) {
417
417
}
418
418
419
419
/**
420
-
* Cannot reference store value inside `<script context="module">`
420
+
* Cannot reference store value inside `<script module>`
421
421
* @param {null | number | NodeLike} node
422
422
* @returns {never}
423
423
*/
424
424
exportfunctionstore_invalid_subscription(node){
425
-
e(node,"store_invalid_subscription","Cannot reference store value inside `<script context=\"module\">`");
425
+
e(node,"store_invalid_subscription","Cannot reference store value inside `<script module>`");
426
426
}
427
427
428
428
/**
@@ -1044,12 +1044,22 @@ export function render_tag_invalid_spread_argument(node) {
1044
1044
}
1045
1045
1046
1046
/**
1047
-
* A component can have a single top-level `<script>` element and/or a single top-level `<script context="module">` element
1047
+
* A component can have a single top-level `<script>` element and/or a single top-level `<script module>` element
1048
1048
* @param {null | number | NodeLike} node
1049
1049
* @returns {never}
1050
1050
*/
1051
1051
exportfunctionscript_duplicate(node){
1052
-
e(node,"script_duplicate","A component can have a single top-level `<script>` element and/or a single top-level `<script context=\"module\">` element");
1052
+
e(node,"script_duplicate","A component can have a single top-level `<script>` element and/or a single top-level `<script module>` element");
1053
+
}
1054
+
1055
+
/**
1056
+
* If the %name% attribute is supplied, it must be a boolean attribute
0 commit comments