[fix] emit deprecation warning only once

Fixes #8009
pull/8012/head
Simon Holthausen 4 years ago
parent b2d36075ae
commit 189d9c825c

@ -1,5 +1,9 @@
# Svelte changelog # Svelte changelog
## Unreleased
* Emit deprecation warning only once
## 3.53.0 ## 3.53.0
* Check whether `parentNode` exists before removing child ([#6037](https://github.com/sveltejs/svelte/issues/6037)) * Check whether `parentNode` exists before removing child ([#6037](https://github.com/sveltejs/svelte/issues/6037))

@ -46,6 +46,8 @@ const valid_css_values = [
const regex_valid_identifier = /^[a-zA-Z_$][a-zA-Z_$0-9]*$/; const regex_valid_identifier = /^[a-zA-Z_$][a-zA-Z_$0-9]*$/;
const regex_starts_with_lowercase_character = /^[a-z]/; const regex_starts_with_lowercase_character = /^[a-z]/;
let has_shown_deprecation = false;
function validate_options(options: CompileOptions, warnings: Warning[]) { function validate_options(options: CompileOptions, warnings: Warning[]) {
const { name, filename, loopGuardTimeout, dev, namespace, css } = options; const { name, filename, loopGuardTimeout, dev, namespace, css } = options;
@ -89,6 +91,8 @@ function validate_options(options: CompileOptions, warnings: Warning[]) {
if (css === true || css === false) { if (css === true || css === false) {
options.css = css === true ? 'injected' : 'external'; options.css = css === true ? 'injected' : 'external';
if (!has_shown_deprecation) {
has_shown_deprecation=true;
const message = `options.css as a boolean is deprecated. Use '${options.css}' instead of ${css}.`; const message = `options.css as a boolean is deprecated. Use '${options.css}' instead of ${css}.`;
warnings.push({ warnings.push({
code: 'options-css-boolean-deprecated', code: 'options-css-boolean-deprecated',
@ -97,6 +101,7 @@ function validate_options(options: CompileOptions, warnings: Warning[]) {
toString: () => message toString: () => message
}); });
} }
}
if (namespace && valid_namespaces.indexOf(namespace) === -1) { if (namespace && valid_namespaces.indexOf(namespace) === -1) {
const match = fuzzymatch(namespace, valid_namespaces); const match = fuzzymatch(namespace, valid_namespaces);

Loading…
Cancel
Save