hacky fix for missing target warning

pull/1864/head
Rich Harris 7 years ago
parent 701af7f7fb
commit 37fd164d36

@ -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} = {};`);
}

@ -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`);
}

@ -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, {

Loading…
Cancel
Save