From a5619187c24a2b4aa4ca2701ca2dc00c77b7e7be Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 21 Nov 2018 21:37:22 -0500 Subject: [PATCH] warn when trying to set read-only data --- src/compile/render-dom/index.ts | 6 +++--- test/runtime/samples/dev-warning-missing-data/_config.js | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/compile/render-dom/index.ts b/src/compile/render-dom/index.ts index 84f879cd8c..d3edbbd55d 100644 --- a/src/compile/render-dom/index.ts +++ b/src/compile/render-dom/index.ts @@ -149,6 +149,8 @@ export default function dom( ` ]; + const debug_name = `<${component.customElement ? component.tag : name}>`; + if (component.options.dev) { // TODO check no uunexpected props were passed, as well as // checking that expected ones were passed @@ -157,8 +159,6 @@ export default function dom( .filter(name => !component.initialised_declarations.has(name)); if (expected.length) { - const debug_name = `<${component.customElement ? component.tag : name}>`; - body.push(deindent` $$checkProps() { const state = this.$$.get_state(); @@ -190,7 +190,7 @@ export default function dom( } else if (component.options.dev) { body.push(deindent` set ${x.as}(value) { - throw new Error("${x.as} is read-only"); + throw new Error("${debug_name}: Cannot set read-only property '${x.as}'"); } `); } diff --git a/test/runtime/samples/dev-warning-missing-data/_config.js b/test/runtime/samples/dev-warning-missing-data/_config.js index e45980bc1b..aef14fd572 100644 --- a/test/runtime/samples/dev-warning-missing-data/_config.js +++ b/test/runtime/samples/dev-warning-missing-data/_config.js @@ -1,6 +1,4 @@ export default { - solo: 1, - compileOptions: { dev: true },