Skip to content

Commit

Permalink
code style
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed May 26, 2019
1 parent 5e3ee4e commit 0891495
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
12 changes: 6 additions & 6 deletions src/compile/render-dom/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,12 +394,12 @@ export default function dom(
return $name;
});

let unknownPropsCheck;
let unknown_props_check;
if (component.compile_options.dev && writable_props.length) {
unknownPropsCheck = deindent`
const writableProps = [${writable_props.map(prop => `'${prop.export_name}'`).join(', ')}];
unknown_props_check = deindent`
const writable_props = [${writable_props.map(prop => `'${prop.export_name}'`).join(', ')}];
Object.keys($$props).forEach(key => {
if (!writableProps.includes(key)) console.warn(\`<${component.tag}> was created with unknown attribute '\${key}'\`);
if (!writable_props.includes(key)) console.warn(\`<${component.tag}> was created with unknown prop '\${key}'\`);
});
`;
}
Expand All @@ -413,8 +413,8 @@ export default function dom(
${resubscribable_reactive_store_unsubscribers}
${component.javascript}
${unknownPropsCheck}
${unknown_props_check}
${component.slots.size && `let { $$slots = {}, $$scope } = $$props;`}
Expand Down
2 changes: 1 addition & 1 deletion test/js/samples/bind-open/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ class Component extends SvelteComponent {
}
}

export default Component;
export default Component;
6 changes: 3 additions & 3 deletions test/js/samples/debug-empty/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ function create_fragment(ctx) {
function instance($$self, $$props, $$invalidate) {
let { name } = $$props;

const writableProps = ['name'];
const writable_props = ['name'];
Object.keys($$props).forEach(key => {
if (!writableProps.includes(key)) console.warn(`<Component> was created with unknown attribute '${key}'`);
if (!writable_props.includes(key)) console.warn(`<Component> was created with unknown prop '${key}'`);
});

$$self.$set = $$props => {
Expand Down Expand Up @@ -98,4 +98,4 @@ class Component extends SvelteComponentDev {
}
}

export default Component;
export default Component;
6 changes: 3 additions & 3 deletions test/js/samples/debug-foo-bar-baz-things/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ function create_fragment(ctx) {
function instance($$self, $$props, $$invalidate) {
let { things, foo, bar, baz } = $$props;

const writableProps = ['things', 'foo', 'bar', 'baz'];
const writable_props = ['things', 'foo', 'bar', 'baz'];
Object.keys($$props).forEach(key => {
if (!writableProps.includes(key)) console.warn(`<Component> was created with unknown attribute '${key}'`);
if (!writable_props.includes(key)) console.warn(`<Component> was created with unknown prop '${key}'`);
});

$$self.$set = $$props => {
Expand Down Expand Up @@ -220,4 +220,4 @@ class Component extends SvelteComponentDev {
}
}

export default Component;
export default Component;
6 changes: 3 additions & 3 deletions test/js/samples/debug-foo/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ function create_fragment(ctx) {
function instance($$self, $$props, $$invalidate) {
let { things, foo } = $$props;

const writableProps = ['things', 'foo'];
const writable_props = ['things', 'foo'];
Object.keys($$props).forEach(key => {
if (!writableProps.includes(key)) console.warn(`<Component> was created with unknown attribute '${key}'`);
if (!writable_props.includes(key)) console.warn(`<Component> was created with unknown prop '${key}'`);
});

$$self.$set = $$props => {
Expand Down Expand Up @@ -196,4 +196,4 @@ class Component extends SvelteComponentDev {
}
}

export default Component;
export default Component;
6 changes: 3 additions & 3 deletions test/js/samples/dev-warning-missing-data-computed/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ function instance($$self, $$props, $$invalidate) {

let bar;

const writableProps = ['foo'];
const writable_props = ['foo'];
Object.keys($$props).forEach(key => {
if (!writableProps.includes(key)) console.warn(`<Component> was created with unknown attribute '${key}'`);
if (!writable_props.includes(key)) console.warn(`<Component> was created with unknown prop '${key}'`);
});

$$self.$set = $$props => {
Expand Down Expand Up @@ -102,4 +102,4 @@ class Component extends SvelteComponentDev {
}
}

export default Component;
export default Component;
2 changes: 1 addition & 1 deletion test/runtime/samples/dev-warning-unknown-props/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ export default {
},

warnings: [
`<Foo> was created with unknown attribute 'fo'`
`<Foo> was created with unknown prop 'fo'`
]
};

0 comments on commit 0891495

Please sign in to comment.