diff --git a/src/compile/render-dom/index.ts b/src/compile/render-dom/index.ts
index ee5344869ac2..64a219ea6a82 100644
--- a/src/compile/render-dom/index.ts
+++ b/src/compile/render-dom/index.ts
@@ -131,10 +131,10 @@ export default function dom(
if (expected.length) {
dev_props_check = deindent`
const { ctx } = this.$$;
+ const props = ${options.customElement ? `this.attributes` : `options.props || {}`};
${expected.map(name => deindent`
-
- if (ctx.${name} === undefined${options.customElement && ` && !('${name}' in this.attributes)`}) {
- console.warn("<${component.tag}> was created without expected data property '${name}'");
+ if (ctx.${name} === undefined && !('${name}' in props)) {
+ console.warn("<${component.tag}> was created without expected prop '${name}'");
}`)}
`;
}
diff --git a/test/custom-elements/samples/no-missing-prop-warnings/test.js b/test/custom-elements/samples/no-missing-prop-warnings/test.js
index 675fa6648585..9430e97f3a4c 100644
--- a/test/custom-elements/samples/no-missing-prop-warnings/test.js
+++ b/test/custom-elements/samples/no-missing-prop-warnings/test.js
@@ -12,7 +12,7 @@ export default function (target) {
target.innerHTML = '';
assert.equal(warnings.length, 1);
- assert.equal(warnings[0], ` was created without expected data property 'bar'`);
+ assert.equal(warnings[0], ` was created without expected prop 'bar'`);
console.warn = warn;
}
\ No newline at end of file
diff --git a/test/js/samples/debug-empty/expected.js b/test/js/samples/debug-empty/expected.js
index 424221040ac5..9d7d110ca35c 100644
--- a/test/js/samples/debug-empty/expected.js
+++ b/test/js/samples/debug-empty/expected.js
@@ -70,8 +70,9 @@ class SvelteComponent extends SvelteComponentDev {
init(this, options, instance, create_fragment, safe_not_equal);
const { ctx } = this.$$;
- if (ctx.name === undefined) {
- console.warn(" was created without expected data property 'name'");
+ const props = options.props || {};
+ if (ctx.name === undefined && !('name' in props)) {
+ console.warn(" was created without expected prop 'name'");
}
}
diff --git a/test/js/samples/debug-foo-bar-baz-things/expected.js b/test/js/samples/debug-foo-bar-baz-things/expected.js
index c53273146e6d..3a1d6265e3f7 100644
--- a/test/js/samples/debug-foo-bar-baz-things/expected.js
+++ b/test/js/samples/debug-foo-bar-baz-things/expected.js
@@ -158,17 +158,18 @@ class SvelteComponent extends SvelteComponentDev {
init(this, options, instance, create_fragment, safe_not_equal);
const { ctx } = this.$$;
- if (ctx.things === undefined) {
- console.warn(" was created without expected data property 'things'");
+ const props = options.props || {};
+ if (ctx.things === undefined && !('things' in props)) {
+ console.warn(" was created without expected prop 'things'");
}
- if (ctx.foo === undefined) {
- console.warn(" was created without expected data property 'foo'");
+ if (ctx.foo === undefined && !('foo' in props)) {
+ console.warn(" was created without expected prop 'foo'");
}
- if (ctx.bar === undefined) {
- console.warn(" was created without expected data property 'bar'");
+ if (ctx.bar === undefined && !('bar' in props)) {
+ console.warn(" was created without expected prop 'bar'");
}
- if (ctx.baz === undefined) {
- console.warn(" was created without expected data property 'baz'");
+ if (ctx.baz === undefined && !('baz' in props)) {
+ console.warn(" was created without expected prop 'baz'");
}
}
diff --git a/test/js/samples/debug-foo/expected.js b/test/js/samples/debug-foo/expected.js
index 82df8283235e..92ca5ab9e167 100644
--- a/test/js/samples/debug-foo/expected.js
+++ b/test/js/samples/debug-foo/expected.js
@@ -156,11 +156,12 @@ class SvelteComponent extends SvelteComponentDev {
init(this, options, instance, create_fragment, safe_not_equal);
const { ctx } = this.$$;
- if (ctx.things === undefined) {
- console.warn(" was created without expected data property 'things'");
+ const props = options.props || {};
+ if (ctx.things === undefined && !('things' in props)) {
+ console.warn(" was created without expected prop 'things'");
}
- if (ctx.foo === undefined) {
- console.warn(" was created without expected data property 'foo'");
+ if (ctx.foo === undefined && !('foo' in props)) {
+ console.warn(" was created without expected prop 'foo'");
}
}
diff --git a/test/js/samples/dev-warning-missing-data-computed/expected.js b/test/js/samples/dev-warning-missing-data-computed/expected.js
index c77cac717459..95e85df1c1df 100644
--- a/test/js/samples/dev-warning-missing-data-computed/expected.js
+++ b/test/js/samples/dev-warning-missing-data-computed/expected.js
@@ -76,8 +76,9 @@ class SvelteComponent extends SvelteComponentDev {
init(this, options, instance, create_fragment, safe_not_equal);
const { ctx } = this.$$;
- if (ctx.foo === undefined) {
- console.warn(" was created without expected data property 'foo'");
+ const props = options.props || {};
+ if (ctx.foo === undefined && !('foo' in props)) {
+ console.warn(" was created without expected prop 'foo'");
}
}
diff --git a/test/runtime/samples/dev-warning-missing-data-binding/_config.js b/test/runtime/samples/dev-warning-missing-data-binding/_config.js
index e85ee3fbb6a0..ffe62384a1d1 100644
--- a/test/runtime/samples/dev-warning-missing-data-binding/_config.js
+++ b/test/runtime/samples/dev-warning-missing-data-binding/_config.js
@@ -4,6 +4,6 @@ export default {
},
warnings: [
- ` was created without expected data property 'value'`
+ ` was created without expected prop 'value'`
]
};
diff --git a/test/runtime/samples/dev-warning-missing-data-component/Foo.html b/test/runtime/samples/dev-warning-missing-data-component/Foo.html
new file mode 100644
index 000000000000..8f26d21baf86
--- /dev/null
+++ b/test/runtime/samples/dev-warning-missing-data-component/Foo.html
@@ -0,0 +1 @@
+{x} {y}
\ No newline at end of file
diff --git a/test/runtime/samples/dev-warning-missing-data-component/_config.js b/test/runtime/samples/dev-warning-missing-data-component/_config.js
new file mode 100644
index 000000000000..f3fc130528d0
--- /dev/null
+++ b/test/runtime/samples/dev-warning-missing-data-component/_config.js
@@ -0,0 +1,9 @@
+export default {
+ compileOptions: {
+ dev: true
+ },
+
+ warnings: [
+ ` was created without expected prop 'y'`
+ ]
+};
diff --git a/test/runtime/samples/dev-warning-missing-data-component/main.html b/test/runtime/samples/dev-warning-missing-data-component/main.html
new file mode 100644
index 000000000000..2bda6e293754
--- /dev/null
+++ b/test/runtime/samples/dev-warning-missing-data-component/main.html
@@ -0,0 +1,5 @@
+
+
+
\ No newline at end of file
diff --git a/test/runtime/samples/dev-warning-missing-data/_config.js b/test/runtime/samples/dev-warning-missing-data/_config.js
index aef14fd5727c..5bc6c8be1f9d 100644
--- a/test/runtime/samples/dev-warning-missing-data/_config.js
+++ b/test/runtime/samples/dev-warning-missing-data/_config.js
@@ -4,7 +4,7 @@ export default {
},
warnings: [
- ` was created without expected data property 'foo'`,
- ` was created without expected data property 'bar'`
+ ` was created without expected prop 'foo'`,
+ ` was created without expected prop 'bar'`
]
};