diff --git a/src/compile/render-dom/wrappers/InlineComponent/index.ts b/src/compile/render-dom/wrappers/InlineComponent/index.ts index 35c328fe03..7174715c21 100644 --- a/src/compile/render-dom/wrappers/InlineComponent/index.ts +++ b/src/compile/render-dom/wrappers/InlineComponent/index.ts @@ -112,6 +112,14 @@ export default class InlineComponentWrapper extends Wrapper { componentInitProperties.push(`props: ${name_initial_data}`); } + if (component.options.dev) { + // TODO this is a terrible hack, but without it the component + // will complain that options.target is missing. This would + // work better if components had separate public and private + // APIs + componentInitProperties.push(`$$inline: true`); + } + if (!usesSpread && (this.node.attributes.filter(a => a.isDynamic).length || this.node.bindings.length)) { updates.push(`var ${name_changes} = {};`); } diff --git a/src/internal/Component.js b/src/internal/Component.js index 9107276e16..cd7c8517ec 100644 --- a/src/internal/Component.js +++ b/src/internal/Component.js @@ -85,6 +85,7 @@ export class $$Component { // TODO null out other refs, including this.$$ (but need to // preserve final state?) this.$$onDestroy = this.$$fragment = null; + this.$$.get_state = () => ({}); } } @@ -137,7 +138,7 @@ export class $$Component { export class $$ComponentDev extends $$Component { constructor(options) { - if (!options || !options.target) { + if (!options || (!options.target && !options.$$inline)) { throw new Error(`'target' is a required option`); } diff --git a/test/runtime/samples/element-source-location/_config.js b/test/runtime/samples/element-source-location/_config.js index b5834d6d92..7733688f23 100644 --- a/test/runtime/samples/element-source-location/_config.js +++ b/test/runtime/samples/element-source-location/_config.js @@ -1,4 +1,4 @@ -import path from 'path'; +import * as path from 'path'; export default { compileOptions: { @@ -11,9 +11,9 @@ export default { assert.deepEqual(h1.__svelte_meta.loc, { file: path.relative(process.cwd(), path.resolve(__dirname, 'main.html')), - line: 0, + line: 4, column: 0, - char: 0 + char: 51 }); assert.deepEqual(p.__svelte_meta.loc, {