fix: don't use console.trace inside dev warnings (#11744)

Chrome does include a trace for warnings, Firefox does not, but the vast majority of devs uses Chromium-based browsers for dev, so this reduces noise
pull/11755/head
Rich Harris 1 year ago committed by GitHub
parent e73b133b66
commit ba429fd2f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: don't use console.trace inside dev warnings

@ -5,13 +5,11 @@ var normal = 'font-weight: normal';
/** /**
* MESSAGE * MESSAGE
* @param {boolean} trace
* @param {string} PARAMETER * @param {string} PARAMETER
*/ */
export function CODE(trace, PARAMETER) { export function CODE(PARAMETER) {
if (DEV) { if (DEV) {
console.warn(`%c[svelte] ${'CODE'}\n%c${MESSAGE}`, bold, normal); console.warn(`%c[svelte] ${'CODE'}\n%c${MESSAGE}`, bold, normal);
if (trace) console.trace('stack trace');
} else { } else {
// TODO print a link to the documentation // TODO print a link to the documentation
console.warn('CODE'); console.warn('CODE');

@ -21,9 +21,6 @@ export function init_array_prototype_warnings() {
if (test !== -1) { if (test !== -1) {
w.state_proxy_equality_mismatch('array.indexOf(...)'); w.state_proxy_equality_mismatch('array.indexOf(...)');
// eslint-disable-next-line no-console
console.trace();
} }
} }
@ -38,9 +35,6 @@ export function init_array_prototype_warnings() {
if (test !== -1) { if (test !== -1) {
w.state_proxy_equality_mismatch('array.lastIndexOf(...)'); w.state_proxy_equality_mismatch('array.lastIndexOf(...)');
// eslint-disable-next-line no-console
console.trace();
} }
} }
@ -55,9 +49,6 @@ export function init_array_prototype_warnings() {
if (test) { if (test) {
w.state_proxy_equality_mismatch('array.includes(...)'); w.state_proxy_equality_mismatch('array.includes(...)');
// eslint-disable-next-line no-console
console.trace();
} }
} }
@ -81,9 +72,6 @@ export function init_array_prototype_warnings() {
export function strict_equals(a, b, equal = true) { export function strict_equals(a, b, equal = true) {
if ((a === b) !== (get_proxied_value(a) === get_proxied_value(b))) { if ((a === b) !== (get_proxied_value(a) === get_proxied_value(b))) {
w.state_proxy_equality_mismatch(equal ? '===' : '!=='); w.state_proxy_equality_mismatch(equal ? '===' : '!==');
// eslint-disable-next-line no-console
console.trace();
} }
return (a === b) === equal; return (a === b) === equal;
@ -98,9 +86,6 @@ export function strict_equals(a, b, equal = true) {
export function equals(a, b, equal = true) { export function equals(a, b, equal = true) {
if ((a == b) !== (get_proxied_value(a) == get_proxied_value(b))) { if ((a == b) !== (get_proxied_value(a) == get_proxied_value(b))) {
w.state_proxy_equality_mismatch(equal ? '==' : '!='); w.state_proxy_equality_mismatch(equal ? '==' : '!=');
// eslint-disable-next-line no-console
console.trace();
} }
return (a == b) === equal; return (a == b) === equal;

@ -241,8 +241,5 @@ export function check_ownership(metadata) {
} else { } else {
w.ownership_invalid_mutation(); w.ownership_invalid_mutation();
} }
// eslint-disable-next-line no-console
console.trace();
} }
} }

@ -43,7 +43,7 @@ export function validate_component(component_fn) {
export function validate_void_dynamic_element(tag_fn) { export function validate_void_dynamic_element(tag_fn) {
const tag = tag_fn(); const tag = tag_fn();
if (tag && is_void(tag)) { if (tag && is_void(tag)) {
w.dynamic_void_element_content(false, tag); w.dynamic_void_element_content(tag);
} }
} }

@ -7,13 +7,11 @@ var normal = 'font-weight: normal';
/** /**
* `<svelte:element this="%tag%">` is a void element it cannot have content * `<svelte:element this="%tag%">` is a void element it cannot have content
* @param {boolean} trace
* @param {string} tag * @param {string} tag
*/ */
export function dynamic_void_element_content(trace, tag) { export function dynamic_void_element_content(tag) {
if (DEV) { if (DEV) {
console.warn(`%c[svelte] ${"dynamic_void_element_content"}\n%c${`\`<svelte:element this="${tag}">\` is a void element — it cannot have content`}`, bold, normal); console.warn(`%c[svelte] ${"dynamic_void_element_content"}\n%c${`\`<svelte:element this="${tag}">\` is a void element — it cannot have content`}`, bold, normal);
if (trace) console.trace('stack trace');
} else { } else {
// TODO print a link to the documentation // TODO print a link to the documentation
console.warn("dynamic_void_element_content"); console.warn("dynamic_void_element_content");

Loading…
Cancel
Save