Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: "interface" for exported properties #3917

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/compiler/compile/render_dom/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,10 @@ export default function dom(
constructor(options) {
super();

this.exportProps = ${prop_names};
${css.code && b`this.shadowRoot.innerHTML = \`<style>${css.code.replace(/\\/g, '\\\\')}${options.dev ? `\n/*# sourceMappingURL=${css.map.toUrl()} */` : ''}</style>\`;`}

@init(this, { target: this.shadowRoot }, ${definition}, ${has_create_fragment ? 'create_fragment': 'null'}, ${not_equal}, ${prop_names});
@init(this, { target: this.shadowRoot }, ${definition}, ${has_create_fragment ? 'create_fragment': 'null'}, ${not_equal}, this.exportProps);

${dev_props_check}

Expand Down Expand Up @@ -493,8 +494,9 @@ export default function dom(
class ${name} extends ${superclass} {
constructor(options) {
super(${options.dev && `options`});
this.exportProps = ${prop_names};
${should_add_css && b`if (!@_document.getElementById("${component.stylesheet.id}-style")) ${add_css}();`}
@init(this, options, ${definition}, ${has_create_fragment ? 'create_fragment': 'null'}, ${not_equal}, ${prop_names});
@init(this, options, ${definition}, ${has_create_fragment ? 'create_fragment': 'null'}, ${not_equal}, this.exportProps);
${options.dev && b`@dispatch_dev("SvelteRegisterComponent", { component: this, tagName: "${name.name}", options, id: create_fragment.name });`}

${dev_props_check}
Expand Down
3 changes: 2 additions & 1 deletion test/js/samples/action-custom-event-handler/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ function instance($$self, $$props, $$invalidate) {
class Component extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance, create_fragment, safe_not_equal, { bar: 0 });
this.exportProps = { bar: 0 };
init(this, options, instance, create_fragment, safe_not_equal, this.exportProps);
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/js/samples/action/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ function link(node) {
class Component extends SvelteComponent {
constructor(options) {
super();
init(this, options, null, create_fragment, safe_not_equal, {});
this.exportProps = {};
init(this, options, null, create_fragment, safe_not_equal, this.exportProps);
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/js/samples/bind-online/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ function instance($$self, $$props, $$invalidate) {
class Component extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance, create_fragment, safe_not_equal, {});
this.exportProps = {};
init(this, options, instance, create_fragment, safe_not_equal, this.exportProps);
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/js/samples/bind-open/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ function instance($$self, $$props, $$invalidate) {
class Component extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance, create_fragment, safe_not_equal, { open: 0 });
this.exportProps = { open: 0 };
init(this, options, instance, create_fragment, safe_not_equal, this.exportProps);
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/js/samples/bind-width-height/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ function instance($$self, $$props, $$invalidate) {
class Component extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance, create_fragment, safe_not_equal, { w: 0, h: 0 });
this.exportProps = { w: 0, h: 0 };
init(this, options, instance, create_fragment, safe_not_equal, this.exportProps);
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/js/samples/bindings-readonly-order/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ function instance($$self, $$props, $$invalidate) {
class Component extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance, create_fragment, safe_not_equal, { files: 0 });
this.exportProps = { files: 0 };
init(this, options, instance, create_fragment, safe_not_equal, this.exportProps);
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/js/samples/capture-inject-dev-only/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ function instance($$self, $$props, $$invalidate) {
class Component extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance, create_fragment, safe_not_equal, {});
this.exportProps = {};
init(this, options, instance, create_fragment, safe_not_equal, this.exportProps);
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/js/samples/collapses-text-around-comments/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ function instance($$self, $$props, $$invalidate) {
class Component extends SvelteComponent {
constructor(options) {
super();
this.exportProps = { foo: 0 };
if (!document.getElementById("svelte-1a7i8ec-style")) add_css();
init(this, options, instance, create_fragment, safe_not_equal, { foo: 0 });
init(this, options, instance, create_fragment, safe_not_equal, this.exportProps);
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/js/samples/component-static-array/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ function instance($$self) {
class Component extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance, create_fragment, safe_not_equal, {});
this.exportProps = {};
init(this, options, instance, create_fragment, safe_not_equal, this.exportProps);
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/js/samples/component-static-immutable/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ function instance($$self) {
class Component extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance, create_fragment, not_equal, {});
this.exportProps = {};
init(this, options, instance, create_fragment, not_equal, this.exportProps);
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/js/samples/component-static-immutable2/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ function instance($$self) {
class Component extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance, create_fragment, not_equal, {});
this.exportProps = {};
init(this, options, instance, create_fragment, not_equal, this.exportProps);
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/js/samples/component-static-var/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ function instance($$self, $$props, $$invalidate) {
class Component extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance, create_fragment, safe_not_equal, {});
this.exportProps = {};
init(this, options, instance, create_fragment, safe_not_equal, this.exportProps);
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/js/samples/component-static/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ function instance($$self) {
class Component extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance, create_fragment, safe_not_equal, {});
this.exportProps = {};
init(this, options, instance, create_fragment, safe_not_equal, this.exportProps);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ function instance($$self, $$props, $$invalidate) {
class Component extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance, create_fragment, safe_not_equal, {});
this.exportProps = {};
init(this, options, instance, create_fragment, safe_not_equal, this.exportProps);
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/js/samples/component-store-file-invalidate/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ function instance($$self, $$props, $$invalidate) {
class Component extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance, null, safe_not_equal, { increment: 0 });
this.exportProps = { increment: 0 };
init(this, options, instance, null, safe_not_equal, this.exportProps);
}

get increment() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ function instance($$self, $$props, $$invalidate) {
class Component extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance, create_fragment, safe_not_equal, {});
this.exportProps = {};
init(this, options, instance, create_fragment, safe_not_equal, this.exportProps);
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/js/samples/computed-collapsed-if/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ function instance($$self, $$props, $$invalidate) {
class Component extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance, null, safe_not_equal, { x: 0, a: 0, b: 0 });
this.exportProps = { x: 0, a: 0, b: 0 };
init(this, options, instance, null, safe_not_equal, this.exportProps);
}

get a() {
Expand Down
3 changes: 2 additions & 1 deletion test/js/samples/css-media-query/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ function create_fragment(ctx) {
class Component extends SvelteComponent {
constructor(options) {
super();
this.exportProps = {};
if (!document.getElementById("svelte-1slhpfn-style")) add_css();
init(this, options, null, create_fragment, safe_not_equal, {});
init(this, options, null, create_fragment, safe_not_equal, this.exportProps);
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/js/samples/css-shadow-dom-keyframes/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ function create_fragment(ctx) {
class Component extends SvelteElement {
constructor(options) {
super();
this.exportProps = {};
this.shadowRoot.innerHTML = `<style>div{animation:foo 1s}@keyframes foo{0%{opacity:0}100%{opacity:1}}</style>`;
init(this, { target: this.shadowRoot }, null, create_fragment, safe_not_equal, {});
init(this, { target: this.shadowRoot }, null, create_fragment, safe_not_equal, this.exportProps);

if (options) {
if (options.target) {
Expand Down
3 changes: 2 additions & 1 deletion test/js/samples/data-attribute/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ function instance($$self, $$props, $$invalidate) {
class Component extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance, create_fragment, safe_not_equal, { bar: 0 });
this.exportProps = { bar: 0 };
init(this, options, instance, create_fragment, safe_not_equal, this.exportProps);
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/js/samples/debug-empty/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ function instance($$self, $$props, $$invalidate) {
class Component extends SvelteComponentDev {
constructor(options) {
super(options);
init(this, options, instance, create_fragment, safe_not_equal, { name: 0 });
this.exportProps = { name: 0 };
init(this, options, instance, create_fragment, safe_not_equal, this.exportProps);

dispatch_dev("SvelteRegisterComponent", {
component: this,
Expand Down
3 changes: 2 additions & 1 deletion test/js/samples/debug-foo-bar-baz-things/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ function instance($$self, $$props, $$invalidate) {
class Component extends SvelteComponentDev {
constructor(options) {
super(options);
init(this, options, instance, create_fragment, safe_not_equal, { things: 0, foo: 0, bar: 0, baz: 0 });
this.exportProps = { things: 0, foo: 0, bar: 0, baz: 0 };
init(this, options, instance, create_fragment, safe_not_equal, this.exportProps);

dispatch_dev("SvelteRegisterComponent", {
component: this,
Expand Down
3 changes: 2 additions & 1 deletion test/js/samples/debug-foo/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ function instance($$self, $$props, $$invalidate) {
class Component extends SvelteComponentDev {
constructor(options) {
super(options);
init(this, options, instance, create_fragment, safe_not_equal, { things: 0, foo: 0 });
this.exportProps = { things: 0, foo: 0 };
init(this, options, instance, create_fragment, safe_not_equal, this.exportProps);

dispatch_dev("SvelteRegisterComponent", {
component: this,
Expand Down
3 changes: 2 additions & 1 deletion test/js/samples/debug-hoisted/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ function instance($$self) {
class Component extends SvelteComponentDev {
constructor(options) {
super(options);
init(this, options, instance, create_fragment, safe_not_equal, {});
this.exportProps = {};
init(this, options, instance, create_fragment, safe_not_equal, this.exportProps);

dispatch_dev("SvelteRegisterComponent", {
component: this,
Expand Down
3 changes: 2 additions & 1 deletion test/js/samples/debug-no-dependencies/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ function create_fragment(ctx) {
class Component extends SvelteComponentDev {
constructor(options) {
super(options);
init(this, options, null, create_fragment, safe_not_equal, {});
this.exportProps = {};
init(this, options, null, create_fragment, safe_not_equal, this.exportProps);

dispatch_dev("SvelteRegisterComponent", {
component: this,
Expand Down
3 changes: 2 additions & 1 deletion test/js/samples/deconflict-builtins/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ function instance($$self, $$props, $$invalidate) {
class Component extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance, create_fragment, safe_not_equal, { createElement: 0 });
this.exportProps = { createElement: 0 };
init(this, options, instance, create_fragment, safe_not_equal, this.exportProps);
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/js/samples/deconflict-globals/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ function instance($$self, $$props, $$invalidate) {
class Component extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance, null, safe_not_equal, { foo: 0 });
this.exportProps = { foo: 0 };
init(this, options, instance, null, safe_not_equal, this.exportProps);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ function instance($$self, $$props, $$invalidate) {
class Component extends SvelteComponentDev {
constructor(options) {
super(options);
init(this, options, instance, create_fragment, safe_not_equal, { foo: 0 });
this.exportProps = { foo: 0 };
init(this, options, instance, create_fragment, safe_not_equal, this.exportProps);

dispatch_dev("SvelteRegisterComponent", {
component: this,
Expand Down
3 changes: 2 additions & 1 deletion test/js/samples/dont-invalidate-this/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ function make_uppercase() {
class Component extends SvelteComponent {
constructor(options) {
super();
init(this, options, null, create_fragment, safe_not_equal, {});
this.exportProps = {};
init(this, options, null, create_fragment, safe_not_equal, this.exportProps);
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/js/samples/dynamic-import/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ const func = () => import("./Foo.svelte");
class Component extends SvelteComponent {
constructor(options) {
super();
init(this, options, null, create_fragment, safe_not_equal, {});
this.exportProps = {};
init(this, options, null, create_fragment, safe_not_equal, this.exportProps);
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/js/samples/each-block-array-literal/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ function instance($$self, $$props, $$invalidate) {
class Component extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance, create_fragment, safe_not_equal, { a: 0, b: 0, c: 0, d: 0, e: 0 });
this.exportProps = { a: 0, b: 0, c: 0, d: 0, e: 0 };
init(this, options, instance, create_fragment, safe_not_equal, this.exportProps);
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/js/samples/each-block-changed-check/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ function instance($$self, $$props, $$invalidate) {
class Component extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance, create_fragment, safe_not_equal, { comments: 0, elapsed: 0, time: 0, foo: 0 });
this.exportProps = { comments: 0, elapsed: 0, time: 0, foo: 0 };
init(this, options, instance, create_fragment, safe_not_equal, this.exportProps);
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/js/samples/each-block-keyed-animated/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ function instance($$self, $$props, $$invalidate) {
class Component extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance, create_fragment, safe_not_equal, { things: 0 });
this.exportProps = { things: 0 };
init(this, options, instance, create_fragment, safe_not_equal, this.exportProps);
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/js/samples/each-block-keyed/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ function instance($$self, $$props, $$invalidate) {
class Component extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance, create_fragment, safe_not_equal, { things: 0 });
this.exportProps = { things: 0 };
init(this, options, instance, create_fragment, safe_not_equal, this.exportProps);
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/js/samples/empty-dom/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ function instance($$self) {
class Component extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance, null, safe_not_equal, {});
this.exportProps = {};
init(this, options, instance, null, safe_not_equal, this.exportProps);
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/js/samples/event-handler-dynamic/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ function instance($$self, $$props, $$invalidate) {
class Component extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance, create_fragment, safe_not_equal, {});
this.exportProps = {};
init(this, options, instance, create_fragment, safe_not_equal, this.exportProps);
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/js/samples/event-handler-no-passive/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ const touchstart_handler = e => e.preventDefault();
class Component extends SvelteComponent {
constructor(options) {
super();
init(this, options, null, create_fragment, safe_not_equal, {});
this.exportProps = {};
init(this, options, null, create_fragment, safe_not_equal, this.exportProps);
}
}

Expand Down
Loading