Skip to content

Commit b45d272

Browse files
committed
add warnings for deprecated <svelte:options> attributes
1 parent 2837a1b commit b45d272

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

packages/svelte/src/compiler/phases/2-analyze/index.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,20 @@ export function analyze_component(root, source, options) {
406406
source
407407
};
408408

409-
if (!options.customElement && root.options?.customElement) {
410-
warn(analysis.warnings, root.options, [], 'missing-custom-element-compile-option');
409+
if (root.options) {
410+
for (const attribute of root.options.attributes) {
411+
if (attribute.name === 'accessors') {
412+
warn(analysis.warnings, attribute, [], 'deprecated-accessors');
413+
}
414+
415+
if (attribute.name === 'customElement' && !options.customElement) {
416+
warn(analysis.warnings, attribute, [], 'missing-custom-element-compile-option');
417+
}
418+
419+
if (attribute.name === 'immutable') {
420+
warn(analysis.warnings, attribute, [], 'deprecated-immutable');
421+
}
422+
}
411423
}
412424

413425
if (analysis.runes) {

packages/svelte/src/compiler/warnings.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,11 @@ const legacy = {
238238
`Using <slot> to render parent content is deprecated. Use {@render ...} tags instead.`,
239239
/** @param {string} name */
240240
'deprecated-event-handler': (name) =>
241-
`Using on:${name} to listen to the ${name} event is is deprecated. Use the event attribute on${name} instead.`
241+
`Using on:${name} to listen to the ${name} event is is deprecated. Use the event attribute on${name} instead.`,
242+
'deprecated-accessors': () =>
243+
`The accessors option has been deprecated. It will have no effect in runes mode.`,
244+
'deprecated-immutable': () =>
245+
`The immutable option has been deprecated. It will have no effect in runes mode.`
242246
};
243247

244248
const block = {

packages/svelte/tests/validator/samples/tag-custom-element-options-missing/warnings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"message": "The 'customElement' option is used when generating a custom element. Did you forget the 'customElement: true' compile option?",
55
"start": {
66
"line": 1,
7-
"column": 0
7+
"column": 16
88
},
99
"end": {
1010
"line": 1,
11-
"column": 49
11+
"column": 46
1212
}
1313
}
1414
]

0 commit comments

Comments
 (0)