diff --git a/src/compile/Component.ts b/src/compile/Component.ts
index 86b43c1b64..a429db41f6 100644
--- a/src/compile/Component.ts
+++ b/src/compile/Component.ts
@@ -153,7 +153,7 @@ export default class Component {
if (compile_options.customElement) {
if (this.component_options.tag === undefined && compile_options.tag === undefined) {
- const svelteOptions = ast.html.children.find(child => child.name === 'svelte:options');
+ const svelteOptions = ast.html.children.find(child => child.name === 'svelte:options') || { start: 0, end: 0 };
this.warn(svelteOptions, {
code: 'custom-element-no-tag',
message: `No custom element 'tag' option was specified. To automatically register a custom element, specify a name with a hyphen in it, e.g. . To hide this warning, use `
diff --git a/test/custom-elements/samples/no-svelte-options/_config.js b/test/custom-elements/samples/no-svelte-options/_config.js
new file mode 100644
index 0000000000..e45582a127
--- /dev/null
+++ b/test/custom-elements/samples/no-svelte-options/_config.js
@@ -0,0 +1,17 @@
+export default {
+ warnings: [{
+ code: "custom-element-no-tag",
+ message: "No custom element 'tag' option was specified. To automatically register a custom element, specify a name with a hyphen in it, e.g. . To hide this warning, use ",
+ pos: 0,
+ start: {
+ character: 0,
+ column: 0,
+ line: 1
+ },
+ end: {
+ character: 0,
+ column: 0,
+ line: 1
+ }
+ }]
+};
diff --git a/test/custom-elements/samples/no-svelte-options/main.svelte b/test/custom-elements/samples/no-svelte-options/main.svelte
new file mode 100644
index 0000000000..538dc970e9
--- /dev/null
+++ b/test/custom-elements/samples/no-svelte-options/main.svelte
@@ -0,0 +1,5 @@
+
+
+Hello {name}!
diff --git a/test/custom-elements/samples/no-svelte-options/test.js b/test/custom-elements/samples/no-svelte-options/test.js
new file mode 100644
index 0000000000..c77f035088
--- /dev/null
+++ b/test/custom-elements/samples/no-svelte-options/test.js
@@ -0,0 +1,12 @@
+import * as assert from 'assert';
+import CustomElement from './main.svelte';
+
+export default function (target) {
+ customElements.define('no-tag', CustomElement);
+ target.innerHTML = ``;
+
+ const el = target.querySelector('no-tag');
+ const h1 = el.shadowRoot.querySelector('h1');
+
+ assert.equal(h1.textContent, 'Hello world!');
+}