From ba5ee7ae9037f7e7f3579931e814949f6b042d29 Mon Sep 17 00:00:00 2001 From: Ivan Hofer Date: Tue, 3 Nov 2020 08:39:11 +0100 Subject: [PATCH 01/31] #3940 add option to append styles on an element other than document.head --- src/compiler/compile/render_dom/index.ts | 14 ++++++++------ src/runtime/internal/Component.ts | 7 ++++++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/compiler/compile/render_dom/index.ts b/src/compiler/compile/render_dom/index.ts index 6380843b8712..334b3c484077 100644 --- a/src/compiler/compile/render_dom/index.ts +++ b/src/compiler/compile/render_dom/index.ts @@ -44,11 +44,14 @@ export default function dom( if (should_add_css) { body.push(b` - function ${add_css}() { + function ${add_css}(customStyleTag) { + const styleId = "${component.stylesheet.id}-style" + const appendTo = customStyleTag || @_document.head + if (appendTo.querySelector(styleId)) return var style = @element("style"); - style.id = "${component.stylesheet.id}-style"; + style.id = styleId; style.textContent = "${styles}"; - @append(@_document.head, style); + @append(appendTo, style); } `); } @@ -474,7 +477,7 @@ export default function dom( ${css.code && b`this.shadowRoot.innerHTML = \`\`;`} - @init(this, { target: this.shadowRoot }, ${definition}, ${has_create_fragment ? 'create_fragment': 'null'}, ${not_equal}, ${prop_indexes}, ${dirty}); + @init(this, { target: this.shadowRoot }, ${definition}, ${has_create_fragment ? 'create_fragment' : 'null'}, ${not_equal}, ${prop_indexes}, null, ${dirty}); ${dev_props_check} @@ -525,8 +528,7 @@ export default function dom( class ${name} extends ${superclass} { constructor(options) { super(${options.dev && 'options'}); - ${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_indexes}, ${dirty}); + @init(this, options, ${definition}, ${has_create_fragment ? 'create_fragment' : 'null'}, ${not_equal}, ${prop_indexes}, ${should_add_css ? add_css : null}, ${dirty}); ${options.dev && b`@dispatch_dev("SvelteRegisterComponent", { component: this, tagName: "${name.name}", options, id: create_fragment.name });`} ${dev_props_check} diff --git a/src/runtime/internal/Component.ts b/src/runtime/internal/Component.ts index 459a78031a04..ef3aa293186b 100644 --- a/src/runtime/internal/Component.ts +++ b/src/runtime/internal/Component.ts @@ -34,6 +34,7 @@ interface T$$ { on_mount: any[]; on_destroy: any[]; skip_bound: boolean; + customStyleTag: HTMLElement; } export function bind(component, name, callback) { @@ -96,7 +97,7 @@ function make_dirty(component, i) { component.$$.dirty[(i / 31) | 0] |= (1 << (i % 31)); } -export function init(component, options, instance, create_fragment, not_equal, props, dirty = [-1]) { +export function init(component, options, instance, create_fragment, not_equal, props, add_css, dirty = [-1]) { const parent_component = current_component; set_current_component(component); @@ -106,6 +107,8 @@ export function init(component, options, instance, create_fragment, not_equal, p fragment: null, ctx: null, + customStyleTag: options.customStyleTag || parent_component && parent_component.$$.customStyleTag, + // state props, update: noop, @@ -127,6 +130,8 @@ export function init(component, options, instance, create_fragment, not_equal, p let ready = false; + add_css && add_css($$.customStyleTag); + $$.ctx = instance ? instance(component, prop_values, (i, ret, ...rest) => { const value = rest.length ? rest[0] : ret; From 28a29bbd0ea2de49d22c3334cb62593fdbcbb32c Mon Sep 17 00:00:00 2001 From: Ivan Hofer Date: Tue, 3 Nov 2020 08:43:09 +0100 Subject: [PATCH 02/31] #3940 append styles on an element other than document.head --- src/compiler/compile/render_dom/index.ts | 14 ++++++++------ src/runtime/internal/Component.ts | 7 ++++++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/compiler/compile/render_dom/index.ts b/src/compiler/compile/render_dom/index.ts index 6380843b8712..334b3c484077 100644 --- a/src/compiler/compile/render_dom/index.ts +++ b/src/compiler/compile/render_dom/index.ts @@ -44,11 +44,14 @@ export default function dom( if (should_add_css) { body.push(b` - function ${add_css}() { + function ${add_css}(customStyleTag) { + const styleId = "${component.stylesheet.id}-style" + const appendTo = customStyleTag || @_document.head + if (appendTo.querySelector(styleId)) return var style = @element("style"); - style.id = "${component.stylesheet.id}-style"; + style.id = styleId; style.textContent = "${styles}"; - @append(@_document.head, style); + @append(appendTo, style); } `); } @@ -474,7 +477,7 @@ export default function dom( ${css.code && b`this.shadowRoot.innerHTML = \`\`;`} - @init(this, { target: this.shadowRoot }, ${definition}, ${has_create_fragment ? 'create_fragment': 'null'}, ${not_equal}, ${prop_indexes}, ${dirty}); + @init(this, { target: this.shadowRoot }, ${definition}, ${has_create_fragment ? 'create_fragment' : 'null'}, ${not_equal}, ${prop_indexes}, null, ${dirty}); ${dev_props_check} @@ -525,8 +528,7 @@ export default function dom( class ${name} extends ${superclass} { constructor(options) { super(${options.dev && 'options'}); - ${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_indexes}, ${dirty}); + @init(this, options, ${definition}, ${has_create_fragment ? 'create_fragment' : 'null'}, ${not_equal}, ${prop_indexes}, ${should_add_css ? add_css : null}, ${dirty}); ${options.dev && b`@dispatch_dev("SvelteRegisterComponent", { component: this, tagName: "${name.name}", options, id: create_fragment.name });`} ${dev_props_check} diff --git a/src/runtime/internal/Component.ts b/src/runtime/internal/Component.ts index 459a78031a04..ef3aa293186b 100644 --- a/src/runtime/internal/Component.ts +++ b/src/runtime/internal/Component.ts @@ -34,6 +34,7 @@ interface T$$ { on_mount: any[]; on_destroy: any[]; skip_bound: boolean; + customStyleTag: HTMLElement; } export function bind(component, name, callback) { @@ -96,7 +97,7 @@ function make_dirty(component, i) { component.$$.dirty[(i / 31) | 0] |= (1 << (i % 31)); } -export function init(component, options, instance, create_fragment, not_equal, props, dirty = [-1]) { +export function init(component, options, instance, create_fragment, not_equal, props, add_css, dirty = [-1]) { const parent_component = current_component; set_current_component(component); @@ -106,6 +107,8 @@ export function init(component, options, instance, create_fragment, not_equal, p fragment: null, ctx: null, + customStyleTag: options.customStyleTag || parent_component && parent_component.$$.customStyleTag, + // state props, update: noop, @@ -127,6 +130,8 @@ export function init(component, options, instance, create_fragment, not_equal, p let ready = false; + add_css && add_css($$.customStyleTag); + $$.ctx = instance ? instance(component, prop_values, (i, ret, ...rest) => { const value = rest.length ? rest[0] : ret; From f2221fc873044b8523b858cffae16d17180183ed Mon Sep 17 00:00:00 2001 From: Ivan Hofer Date: Wed, 4 Nov 2020 07:41:05 +0100 Subject: [PATCH 03/31] #3940 use @noop instead of null --- src/compiler/compile/render_dom/index.ts | 8 +++++--- src/runtime/internal/Component.ts | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/compiler/compile/render_dom/index.ts b/src/compiler/compile/render_dom/index.ts index 756bf7e0f5b3..c08123b8c355 100644 --- a/src/compiler/compile/render_dom/index.ts +++ b/src/compiler/compile/render_dom/index.ts @@ -475,9 +475,11 @@ export default function dom( constructor(options) { super(); - ${css.code && b`this.shadowRoot.innerHTML = \`\`;`} + const add_css = ${css.code + ? (b`() => this.shadowRoot.innerHTML = \`\`;`) + : x`@noop`} - @init(this, { target: this.shadowRoot, props: @attribute_to_object(this.attributes) }, ${definition}, ${has_create_fragment ? 'create_fragment': 'null'}, ${not_equal}, ${prop_indexes}, null, ${dirty}); + @init(this, { target: this.shadowRoot, props: @attribute_to_object(this.attributes) }, ${definition}, ${has_create_fragment ? 'create_fragment' : 'null'}, ${not_equal}, ${prop_indexes}, ${add_css}, ${dirty}); ${dev_props_check} @@ -528,7 +530,7 @@ export default function dom( class ${name} extends ${superclass} { constructor(options) { super(${options.dev && 'options'}); - @init(this, options, ${definition}, ${has_create_fragment ? 'create_fragment' : 'null'}, ${not_equal}, ${prop_indexes}, ${should_add_css ? add_css : null}, ${dirty}); + @init(this, options, ${definition}, ${has_create_fragment ? 'create_fragment' : 'null'}, ${not_equal}, ${prop_indexes}, ${should_add_css ? add_css : x`@noop`}, ${dirty}); ${options.dev && b`@dispatch_dev("SvelteRegisterComponent", { component: this, tagName: "${name.name}", options, id: create_fragment.name });`} ${dev_props_check} diff --git a/src/runtime/internal/Component.ts b/src/runtime/internal/Component.ts index ef3aa293186b..4524a5dba96e 100644 --- a/src/runtime/internal/Component.ts +++ b/src/runtime/internal/Component.ts @@ -130,7 +130,7 @@ export function init(component, options, instance, create_fragment, not_equal, p let ready = false; - add_css && add_css($$.customStyleTag); + add_css($$.customStyleTag); $$.ctx = instance ? instance(component, prop_values, (i, ret, ...rest) => { From 9ad664e1d2c059663b50d1189077d7205748e6ba Mon Sep 17 00:00:00 2001 From: Ivan Hofer Date: Wed, 4 Nov 2020 08:00:34 +0100 Subject: [PATCH 04/31] #3940 refactor check if style is already present --- src/compiler/compile/render_dom/index.ts | 8 +------- src/runtime/internal/dom.ts | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/compiler/compile/render_dom/index.ts b/src/compiler/compile/render_dom/index.ts index c08123b8c355..25da49d72a6a 100644 --- a/src/compiler/compile/render_dom/index.ts +++ b/src/compiler/compile/render_dom/index.ts @@ -45,13 +45,7 @@ export default function dom( if (should_add_css) { body.push(b` function ${add_css}(customStyleTag) { - const styleId = "${component.stylesheet.id}-style" - const appendTo = customStyleTag || @_document.head - if (appendTo.querySelector(styleId)) return - var style = @element("style"); - style.id = styleId; - style.textContent = "${styles}"; - @append(appendTo, style); + @appendStyleIfNotPresent(customStyleTag || @_document.head, "${component.stylesheet.id}-style", "${styles}"); } `); } diff --git a/src/runtime/internal/dom.ts b/src/runtime/internal/dom.ts index ad06d6ff0829..76226ab8521d 100644 --- a/src/runtime/internal/dom.ts +++ b/src/runtime/internal/dom.ts @@ -1,5 +1,14 @@ import { has_prop } from './utils'; +export function appendStyleIfNotPresent(target: Element, styleId: string, styles: string) { + if (!target.querySelector('#' + styleId)) { + const style = element('style'); + style.id = styleId; + style.textContent = styles; + append(target, style); + } +} + export function append(target: Node, node: Node) { target.appendChild(node); } @@ -63,7 +72,7 @@ export function listen(node: EventTarget, event: string, handler: EventListenerO } export function prevent_default(fn) { - return function(event) { + return function (event) { event.preventDefault(); // @ts-ignore return fn.call(this, event); @@ -71,7 +80,7 @@ export function prevent_default(fn) { } export function stop_propagation(fn) { - return function(event) { + return function (event) { event.stopPropagation(); // @ts-ignore return fn.call(this, event); @@ -79,7 +88,7 @@ export function stop_propagation(fn) { } export function self(fn) { - return function(event) { + return function (event) { // @ts-ignore if (event.target === this) fn.call(this, event); }; @@ -308,7 +317,7 @@ export function toggle_class(element, name, toggle) { element.classList[toggle ? 'add' : 'remove'](name); } -export function custom_event(type: string, detail?: T) { +export function custom_event(type: string, detail?: T) { const e: CustomEvent = document.createEvent('CustomEvent'); e.initCustomEvent(type, false, false, detail); return e; From 0968e5500d69bbeed8c3cd90e798afbe9da81ad6 Mon Sep 17 00:00:00 2001 From: Ivan Hofer Date: Fri, 6 Nov 2020 07:24:05 +0100 Subject: [PATCH 05/31] #3940 revert auto-formatting changes --- src/runtime/internal/dom.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/runtime/internal/dom.ts b/src/runtime/internal/dom.ts index 76226ab8521d..ad40e5fbb9f4 100644 --- a/src/runtime/internal/dom.ts +++ b/src/runtime/internal/dom.ts @@ -72,7 +72,7 @@ export function listen(node: EventTarget, event: string, handler: EventListenerO } export function prevent_default(fn) { - return function (event) { + return function(event) { event.preventDefault(); // @ts-ignore return fn.call(this, event); @@ -80,7 +80,7 @@ export function prevent_default(fn) { } export function stop_propagation(fn) { - return function (event) { + return function(event) { event.stopPropagation(); // @ts-ignore return fn.call(this, event); @@ -88,7 +88,7 @@ export function stop_propagation(fn) { } export function self(fn) { - return function (event) { + return function(event) { // @ts-ignore if (event.target === this) fn.call(this, event); }; @@ -317,7 +317,7 @@ export function toggle_class(element, name, toggle) { element.classList[toggle ? 'add' : 'remove'](name); } -export function custom_event(type: string, detail?: T) { +export function custom_event(type: string, detail?: T) { const e: CustomEvent = document.createEvent('CustomEvent'); e.initCustomEvent(type, false, false, detail); return e; From c0ac80fbda752d5f399dfec4ff714c3ce7565882 Mon Sep 17 00:00:00 2001 From: Ivan Hofer Date: Tue, 10 Nov 2020 07:44:18 +0100 Subject: [PATCH 06/31] add 'noop' param to all tests --- .../samples/action-custom-event-handler/expected.js | 4 ++-- test/js/samples/bind-online/expected.js | 2 +- test/js/samples/bind-open/expected.js | 2 +- test/js/samples/bind-width-height/expected.js | 2 +- test/js/samples/bindings-readonly-order/expected.js | 2 +- test/js/samples/capture-inject-dev-only/expected.js | 2 +- test/js/samples/capture-inject-state/expected.js | 2 +- .../collapses-text-around-comments/expected.js | 2 +- test/js/samples/component-static-array/expected.js | 2 +- test/js/samples/component-static-var/expected.js | 3 ++- test/js/samples/component-static/expected.js | 2 +- .../component-store-access-invalidate/expected.js | 2 +- .../component-store-reassign-invalidate/expected.js | 2 +- test/js/samples/data-attribute/expected.js | 2 +- test/js/samples/debug-empty/expected.js | 2 +- test/js/samples/debug-foo-bar-baz-things/expected.js | 2 +- test/js/samples/debug-foo/expected.js | 2 +- test/js/samples/debug-hoisted/expected.js | 2 +- test/js/samples/debug-no-dependencies/expected.js | 2 +- test/js/samples/deconflict-builtins/expected.js | 2 +- .../dev-warning-missing-data-computed/expected.js | 2 +- test/js/samples/each-block-array-literal/expected.js | 2 +- test/js/samples/each-block-changed-check/expected.js | 2 +- .../js/samples/each-block-keyed-animated/expected.js | 2 +- test/js/samples/each-block-keyed/expected.js | 2 +- test/js/samples/event-handler-dynamic/expected.js | 2 +- test/js/samples/if-block-complex/expected.js | 2 +- test/js/samples/if-block-no-update/expected.js | 2 +- test/js/samples/if-block-simple/expected.js | 4 ++-- test/js/samples/import-meta/expected.js | 2 +- test/js/samples/initial-context/expected.js | 2 +- .../inline-style-optimized-multiple/expected.js | 2 +- .../samples/inline-style-optimized-url/expected.js | 2 +- test/js/samples/inline-style-optimized/expected.js | 2 +- test/js/samples/input-files/expected.js | 2 +- test/js/samples/input-range/expected.js | 2 +- test/js/samples/input-value/expected.js | 2 +- .../samples/input-without-blowback-guard/expected.js | 2 +- .../instrumentation-script-if-no-block/expected.js | 2 +- .../instrumentation-script-main-block/expected.js | 2 +- .../instrumentation-script-x-equals-x/expected.js | 2 +- .../instrumentation-template-if-no-block/expected.js | 2 +- .../instrumentation-template-x-equals-x/expected.js | 2 +- test/js/samples/loop-protect/expected.js | 2 +- test/js/samples/media-bindings/expected.js | 2 +- test/js/samples/optional-chaining/expected.js | 3 ++- test/js/samples/select-dynamic-value/expected.js | 2 +- test/js/samples/src-attribute-check/expected.js | 2 +- test/js/samples/title/expected.js | 2 +- test/js/samples/transition-local/expected.js | 4 ++-- .../js/samples/transition-repeated-outro/expected.js | 3 ++- test/js/samples/unchanged-expression/expected.js | 2 +- .../unreferenced-state-not-invalidated/expected.js | 2 +- test/js/samples/use-elements-as-anchors/expected.js | 12 ++++++------ test/js/samples/video-bindings/expected.js | 2 +- test/js/samples/window-binding-online/expected.js | 2 +- test/js/samples/window-binding-scroll/expected.js | 2 +- 57 files changed, 68 insertions(+), 65 deletions(-) diff --git a/test/js/samples/action-custom-event-handler/expected.js b/test/js/samples/action-custom-event-handler/expected.js index 51656290d668..c5c2ea454de3 100644 --- a/test/js/samples/action-custom-event-handler/expected.js +++ b/test/js/samples/action-custom-event-handler/expected.js @@ -48,7 +48,7 @@ function handleFoo(bar) { } function foo(node, callback) { - + } // code goes here function instance($$self, $$props, $$invalidate) { @@ -65,7 +65,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { bar: 0 }); + init(this, options, instance, create_fragment, safe_not_equal, { bar: 0 }, noop); } } diff --git a/test/js/samples/bind-online/expected.js b/test/js/samples/bind-online/expected.js index 887195bce1b3..1b9fd41bc627 100644 --- a/test/js/samples/bind-online/expected.js +++ b/test/js/samples/bind-online/expected.js @@ -49,7 +49,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}); + init(this, options, instance, create_fragment, safe_not_equal, {}, noop); } } diff --git a/test/js/samples/bind-open/expected.js b/test/js/samples/bind-open/expected.js index 56ff30284572..5ff4dc1ad133 100644 --- a/test/js/samples/bind-open/expected.js +++ b/test/js/samples/bind-open/expected.js @@ -62,7 +62,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { open: 0 }); + init(this, options, instance, create_fragment, safe_not_equal, { open: 0 }, noop); } } diff --git a/test/js/samples/bind-width-height/expected.js b/test/js/samples/bind-width-height/expected.js index f23c20b68316..c583acf64158 100644 --- a/test/js/samples/bind-width-height/expected.js +++ b/test/js/samples/bind-width-height/expected.js @@ -57,7 +57,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { w: 0, h: 1 }); + init(this, options, instance, create_fragment, safe_not_equal, { w: 0, h: 1 }, noop); } } diff --git a/test/js/samples/bindings-readonly-order/expected.js b/test/js/samples/bindings-readonly-order/expected.js index 78a71dcd8414..063f2b28d4a3 100644 --- a/test/js/samples/bindings-readonly-order/expected.js +++ b/test/js/samples/bindings-readonly-order/expected.js @@ -78,7 +78,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { files: 0 }); + init(this, options, instance, create_fragment, safe_not_equal, { files: 0 }, noop); } } diff --git a/test/js/samples/capture-inject-dev-only/expected.js b/test/js/samples/capture-inject-dev-only/expected.js index a87693dd9e8e..e3fc6f9b7c23 100644 --- a/test/js/samples/capture-inject-dev-only/expected.js +++ b/test/js/samples/capture-inject-dev-only/expected.js @@ -75,7 +75,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}); + init(this, options, instance, create_fragment, safe_not_equal, {}, noop); } } diff --git a/test/js/samples/capture-inject-state/expected.js b/test/js/samples/capture-inject-state/expected.js index 6a0351ae449e..b5ce98de7050 100644 --- a/test/js/samples/capture-inject-state/expected.js +++ b/test/js/samples/capture-inject-state/expected.js @@ -158,7 +158,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponentDev { constructor(options) { super(options); - init(this, options, instance, create_fragment, safe_not_equal, { prop: 0, alias: 1 }); + init(this, options, instance, create_fragment, safe_not_equal, { prop: 0, alias: 1 }, noop); dispatch_dev("SvelteRegisterComponent", { component: this, diff --git a/test/js/samples/collapses-text-around-comments/expected.js b/test/js/samples/collapses-text-around-comments/expected.js index 67335ce2469e..41a574eba5e5 100644 --- a/test/js/samples/collapses-text-around-comments/expected.js +++ b/test/js/samples/collapses-text-around-comments/expected.js @@ -59,7 +59,7 @@ class Component extends SvelteComponent { constructor(options) { super(); 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, { foo: 0 }, noop); } } diff --git a/test/js/samples/component-static-array/expected.js b/test/js/samples/component-static-array/expected.js index 0ecb0f32ba08..d3a28d36b36e 100644 --- a/test/js/samples/component-static-array/expected.js +++ b/test/js/samples/component-static-array/expected.js @@ -48,7 +48,7 @@ function instance($$self) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}); + init(this, options, instance, create_fragment, safe_not_equal, {}, noop); } } diff --git a/test/js/samples/component-static-var/expected.js b/test/js/samples/component-static-var/expected.js index 2cd5ed386f07..c129f252caa7 100644 --- a/test/js/samples/component-static-var/expected.js +++ b/test/js/samples/component-static-var/expected.js @@ -9,6 +9,7 @@ import { insert, listen, mount_component, + noop, safe_not_equal, set_input_value, space, @@ -101,7 +102,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}); + init(this, options, instance, create_fragment, safe_not_equal, {}, noop); } } diff --git a/test/js/samples/component-static/expected.js b/test/js/samples/component-static/expected.js index 186f6350e6bd..dd0a1da29462 100644 --- a/test/js/samples/component-static/expected.js +++ b/test/js/samples/component-static/expected.js @@ -48,7 +48,7 @@ function instance($$self) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}); + init(this, options, instance, create_fragment, safe_not_equal, {}, noop); } } diff --git a/test/js/samples/component-store-access-invalidate/expected.js b/test/js/samples/component-store-access-invalidate/expected.js index 4c7bfd7009c3..790b8b1a5e7d 100644 --- a/test/js/samples/component-store-access-invalidate/expected.js +++ b/test/js/samples/component-store-access-invalidate/expected.js @@ -49,7 +49,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}); + init(this, options, instance, create_fragment, safe_not_equal, {}, noop); } } diff --git a/test/js/samples/component-store-reassign-invalidate/expected.js b/test/js/samples/component-store-reassign-invalidate/expected.js index 0cf555bf0d96..31c92c66f7bc 100644 --- a/test/js/samples/component-store-reassign-invalidate/expected.js +++ b/test/js/samples/component-store-reassign-invalidate/expected.js @@ -74,7 +74,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}); + init(this, options, instance, create_fragment, safe_not_equal, {}, noop); } } diff --git a/test/js/samples/data-attribute/expected.js b/test/js/samples/data-attribute/expected.js index 8c30e6f6dbb5..5f80efc52f33 100644 --- a/test/js/samples/data-attribute/expected.js +++ b/test/js/samples/data-attribute/expected.js @@ -57,7 +57,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { bar: 0 }); + init(this, options, instance, create_fragment, safe_not_equal, { bar: 0 }, noop); } } diff --git a/test/js/samples/debug-empty/expected.js b/test/js/samples/debug-empty/expected.js index f427f1bf4581..1142b90e4409 100644 --- a/test/js/samples/debug-empty/expected.js +++ b/test/js/samples/debug-empty/expected.js @@ -98,7 +98,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponentDev { constructor(options) { super(options); - init(this, options, instance, create_fragment, safe_not_equal, { name: 0 }); + init(this, options, instance, create_fragment, safe_not_equal, { name: 0 }, noop); dispatch_dev("SvelteRegisterComponent", { component: this, diff --git a/test/js/samples/debug-foo-bar-baz-things/expected.js b/test/js/samples/debug-foo-bar-baz-things/expected.js index 7439b3310b3a..e0c87cc33f1f 100644 --- a/test/js/samples/debug-foo-bar-baz-things/expected.js +++ b/test/js/samples/debug-foo-bar-baz-things/expected.js @@ -208,7 +208,7 @@ 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: 1, bar: 2, baz: 3 }); + init(this, options, instance, create_fragment, safe_not_equal, { things: 0, foo: 1, bar: 2, baz: 3 }, noop); dispatch_dev("SvelteRegisterComponent", { component: this, diff --git a/test/js/samples/debug-foo/expected.js b/test/js/samples/debug-foo/expected.js index d869a5cf9e84..540c423a5d68 100644 --- a/test/js/samples/debug-foo/expected.js +++ b/test/js/samples/debug-foo/expected.js @@ -196,7 +196,7 @@ 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: 1 }); + init(this, options, instance, create_fragment, safe_not_equal, { things: 0, foo: 1 }, noop); dispatch_dev("SvelteRegisterComponent", { component: this, diff --git a/test/js/samples/debug-hoisted/expected.js b/test/js/samples/debug-hoisted/expected.js index c6257ac90d5a..ba575f49aa8d 100644 --- a/test/js/samples/debug-hoisted/expected.js +++ b/test/js/samples/debug-hoisted/expected.js @@ -76,7 +76,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponentDev { constructor(options) { super(options); - init(this, options, instance, create_fragment, safe_not_equal, {}); + init(this, options, instance, create_fragment, safe_not_equal, {}, noop); dispatch_dev("SvelteRegisterComponent", { component: this, diff --git a/test/js/samples/debug-no-dependencies/expected.js b/test/js/samples/debug-no-dependencies/expected.js index 4d8d05d3aa6e..d74c540948a6 100644 --- a/test/js/samples/debug-no-dependencies/expected.js +++ b/test/js/samples/debug-no-dependencies/expected.js @@ -150,7 +150,7 @@ function instance($$self, $$props) { class Component extends SvelteComponentDev { constructor(options) { super(options); - init(this, options, instance, create_fragment, safe_not_equal, {}); + init(this, options, instance, create_fragment, safe_not_equal, {}, noop); dispatch_dev("SvelteRegisterComponent", { component: this, diff --git a/test/js/samples/deconflict-builtins/expected.js b/test/js/samples/deconflict-builtins/expected.js index 6bc60194aaa5..f4180b971229 100644 --- a/test/js/samples/deconflict-builtins/expected.js +++ b/test/js/samples/deconflict-builtins/expected.js @@ -114,7 +114,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { createElement: 0 }); + init(this, options, instance, create_fragment, safe_not_equal, { createElement: 0 }, noop); } } diff --git a/test/js/samples/dev-warning-missing-data-computed/expected.js b/test/js/samples/dev-warning-missing-data-computed/expected.js index 8c7f8bb1cff8..b5419d19bde2 100644 --- a/test/js/samples/dev-warning-missing-data-computed/expected.js +++ b/test/js/samples/dev-warning-missing-data-computed/expected.js @@ -102,7 +102,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponentDev { constructor(options) { super(options); - init(this, options, instance, create_fragment, safe_not_equal, { foo: 0 }); + init(this, options, instance, create_fragment, safe_not_equal, { foo: 0 }, noop); dispatch_dev("SvelteRegisterComponent", { component: this, diff --git a/test/js/samples/each-block-array-literal/expected.js b/test/js/samples/each-block-array-literal/expected.js index fe51ac5bc3aa..b497887f7862 100644 --- a/test/js/samples/each-block-array-literal/expected.js +++ b/test/js/samples/each-block-array-literal/expected.js @@ -120,7 +120,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { a: 0, b: 1, c: 2, d: 3, e: 4 }); + init(this, options, instance, create_fragment, safe_not_equal, { a: 0, b: 1, c: 2, d: 3, e: 4 }, noop); } } diff --git a/test/js/samples/each-block-changed-check/expected.js b/test/js/samples/each-block-changed-check/expected.js index 63bc1d8607b8..40f6cdfe32b8 100644 --- a/test/js/samples/each-block-changed-check/expected.js +++ b/test/js/samples/each-block-changed-check/expected.js @@ -165,7 +165,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { comments: 0, elapsed: 1, time: 2, foo: 3 }); + init(this, options, instance, create_fragment, safe_not_equal, { comments: 0, elapsed: 1, time: 2, foo: 3 }, noop); } } diff --git a/test/js/samples/each-block-keyed-animated/expected.js b/test/js/samples/each-block-keyed-animated/expected.js index 46ef63ee7f17..5cc2b196e928 100644 --- a/test/js/samples/each-block-keyed-animated/expected.js +++ b/test/js/samples/each-block-keyed-animated/expected.js @@ -138,7 +138,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { things: 0 }); + init(this, options, instance, create_fragment, safe_not_equal, { things: 0 }, noop); } } diff --git a/test/js/samples/each-block-keyed/expected.js b/test/js/samples/each-block-keyed/expected.js index 71853cf295ef..f6897a1cd6fb 100644 --- a/test/js/samples/each-block-keyed/expected.js +++ b/test/js/samples/each-block-keyed/expected.js @@ -107,7 +107,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { things: 0 }); + init(this, options, instance, create_fragment, safe_not_equal, { things: 0 }, noop); } } diff --git a/test/js/samples/event-handler-dynamic/expected.js b/test/js/samples/event-handler-dynamic/expected.js index dacdfe15ac37..9e4e78cca007 100644 --- a/test/js/samples/event-handler-dynamic/expected.js +++ b/test/js/samples/event-handler-dynamic/expected.js @@ -103,7 +103,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}); + init(this, options, instance, create_fragment, safe_not_equal, {}, noop); } } diff --git a/test/js/samples/if-block-complex/expected.js b/test/js/samples/if-block-complex/expected.js index a8244de8b02d..2cc568f1ddca 100644 --- a/test/js/samples/if-block-complex/expected.js +++ b/test/js/samples/if-block-complex/expected.js @@ -60,7 +60,7 @@ function instance($$self) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}); + init(this, options, instance, create_fragment, safe_not_equal, {}, noop); } } diff --git a/test/js/samples/if-block-no-update/expected.js b/test/js/samples/if-block-no-update/expected.js index c67b33fa8557..b35a805f6a54 100644 --- a/test/js/samples/if-block-no-update/expected.js +++ b/test/js/samples/if-block-no-update/expected.js @@ -98,7 +98,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { foo: 0 }); + init(this, options, instance, create_fragment, safe_not_equal, { foo: 0 }, noop); } } diff --git a/test/js/samples/if-block-simple/expected.js b/test/js/samples/if-block-simple/expected.js index 4cdd73cddbc1..abc3a31a959a 100644 --- a/test/js/samples/if-block-simple/expected.js +++ b/test/js/samples/if-block-simple/expected.js @@ -43,7 +43,7 @@ function create_fragment(ctx) { p(ctx, [dirty]) { if (/*foo*/ ctx[0]) { if (if_block) { - + } else { if_block = create_if_block(ctx); if_block.c(); @@ -76,7 +76,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { foo: 0 }); + init(this, options, instance, create_fragment, safe_not_equal, { foo: 0 }, noop); } } diff --git a/test/js/samples/import-meta/expected.js b/test/js/samples/import-meta/expected.js index ba77398321cf..f3b90c0b2d6c 100644 --- a/test/js/samples/import-meta/expected.js +++ b/test/js/samples/import-meta/expected.js @@ -46,7 +46,7 @@ function instance($$self) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}); + init(this, options, instance, create_fragment, safe_not_equal, {}, noop); } } diff --git a/test/js/samples/initial-context/expected.js b/test/js/samples/initial-context/expected.js index 592e2a709e9c..e9b5892ef64c 100644 --- a/test/js/samples/initial-context/expected.js +++ b/test/js/samples/initial-context/expected.js @@ -52,7 +52,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}); + init(this, options, instance, create_fragment, safe_not_equal, {}, noop); } } diff --git a/test/js/samples/inline-style-optimized-multiple/expected.js b/test/js/samples/inline-style-optimized-multiple/expected.js index 0a9d0a1e8eba..29818b3dccd0 100644 --- a/test/js/samples/inline-style-optimized-multiple/expected.js +++ b/test/js/samples/inline-style-optimized-multiple/expected.js @@ -56,7 +56,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { color: 0, x: 1, y: 2 }); + init(this, options, instance, create_fragment, safe_not_equal, { color: 0, x: 1, y: 2 }, noop); } } diff --git a/test/js/samples/inline-style-optimized-url/expected.js b/test/js/samples/inline-style-optimized-url/expected.js index 0debb035854f..7ac128ed3b61 100644 --- a/test/js/samples/inline-style-optimized-url/expected.js +++ b/test/js/samples/inline-style-optimized-url/expected.js @@ -47,7 +47,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { data: 0 }); + init(this, options, instance, create_fragment, safe_not_equal, { data: 0 }, noop); } } diff --git a/test/js/samples/inline-style-optimized/expected.js b/test/js/samples/inline-style-optimized/expected.js index b7db0f1cf30b..79fb9f1f875a 100644 --- a/test/js/samples/inline-style-optimized/expected.js +++ b/test/js/samples/inline-style-optimized/expected.js @@ -47,7 +47,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { color: 0 }); + init(this, options, instance, create_fragment, safe_not_equal, { color: 0 }, noop); } } diff --git a/test/js/samples/input-files/expected.js b/test/js/samples/input-files/expected.js index 8adc7443f5c1..d35feefa943d 100644 --- a/test/js/samples/input-files/expected.js +++ b/test/js/samples/input-files/expected.js @@ -59,7 +59,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { files: 0 }); + init(this, options, instance, create_fragment, safe_not_equal, { files: 0 }, noop); } } diff --git a/test/js/samples/input-range/expected.js b/test/js/samples/input-range/expected.js index a855ca3653fe..7e985d77e3db 100644 --- a/test/js/samples/input-range/expected.js +++ b/test/js/samples/input-range/expected.js @@ -70,7 +70,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { value: 0 }); + init(this, options, instance, create_fragment, safe_not_equal, { value: 0 }, noop); } } diff --git a/test/js/samples/input-value/expected.js b/test/js/samples/input-value/expected.js index 781a2ae60358..6de379e63114 100644 --- a/test/js/samples/input-value/expected.js +++ b/test/js/samples/input-value/expected.js @@ -76,7 +76,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}); + init(this, options, instance, create_fragment, safe_not_equal, {}, noop); } } diff --git a/test/js/samples/input-without-blowback-guard/expected.js b/test/js/samples/input-without-blowback-guard/expected.js index 6c5b2156232f..98f3bf79498d 100644 --- a/test/js/samples/input-without-blowback-guard/expected.js +++ b/test/js/samples/input-without-blowback-guard/expected.js @@ -63,7 +63,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { foo: 0 }); + init(this, options, instance, create_fragment, safe_not_equal, { foo: 0 }, noop); } } diff --git a/test/js/samples/instrumentation-script-if-no-block/expected.js b/test/js/samples/instrumentation-script-if-no-block/expected.js index 7f51c6455007..11dde75a7937 100644 --- a/test/js/samples/instrumentation-script-if-no-block/expected.js +++ b/test/js/samples/instrumentation-script-if-no-block/expected.js @@ -72,7 +72,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}); + init(this, options, instance, create_fragment, safe_not_equal, {}, noop); } } diff --git a/test/js/samples/instrumentation-script-main-block/expected.js b/test/js/samples/instrumentation-script-main-block/expected.js index bc809246028b..19bf4f0f0bd4 100644 --- a/test/js/samples/instrumentation-script-main-block/expected.js +++ b/test/js/samples/instrumentation-script-main-block/expected.js @@ -68,7 +68,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}); + init(this, options, instance, create_fragment, safe_not_equal, {}, noop); } } diff --git a/test/js/samples/instrumentation-script-x-equals-x/expected.js b/test/js/samples/instrumentation-script-x-equals-x/expected.js index ea0d65acb906..a6db9a42f523 100644 --- a/test/js/samples/instrumentation-script-x-equals-x/expected.js +++ b/test/js/samples/instrumentation-script-x-equals-x/expected.js @@ -74,7 +74,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}); + init(this, options, instance, create_fragment, safe_not_equal, {}, noop); } } diff --git a/test/js/samples/instrumentation-template-if-no-block/expected.js b/test/js/samples/instrumentation-template-if-no-block/expected.js index 0c2713a9cc64..acc277f41992 100644 --- a/test/js/samples/instrumentation-template-if-no-block/expected.js +++ b/test/js/samples/instrumentation-template-if-no-block/expected.js @@ -72,7 +72,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}); + init(this, options, instance, create_fragment, safe_not_equal, {}, noop); } } diff --git a/test/js/samples/instrumentation-template-x-equals-x/expected.js b/test/js/samples/instrumentation-template-x-equals-x/expected.js index 55cd310661e7..5a1b436ddeba 100644 --- a/test/js/samples/instrumentation-template-x-equals-x/expected.js +++ b/test/js/samples/instrumentation-template-x-equals-x/expected.js @@ -74,7 +74,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}); + init(this, options, instance, create_fragment, safe_not_equal, {}, noop); } } diff --git a/test/js/samples/loop-protect/expected.js b/test/js/samples/loop-protect/expected.js index 1042b20823b8..df6bcd25f93e 100644 --- a/test/js/samples/loop-protect/expected.js +++ b/test/js/samples/loop-protect/expected.js @@ -154,7 +154,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponentDev { constructor(options) { super(options); - init(this, options, instance, create_fragment, safe_not_equal, {}); + init(this, options, instance, create_fragment, safe_not_equal, {}, noop); dispatch_dev("SvelteRegisterComponent", { component: this, diff --git a/test/js/samples/media-bindings/expected.js b/test/js/samples/media-bindings/expected.js index 867d4a7dadfb..9ee63938fa08 100644 --- a/test/js/samples/media-bindings/expected.js +++ b/test/js/samples/media-bindings/expected.js @@ -227,7 +227,7 @@ class Component extends SvelteComponent { playbackRate: 8, seeking: 9, ended: 10 - }); + }, noop); } } diff --git a/test/js/samples/optional-chaining/expected.js b/test/js/samples/optional-chaining/expected.js index 8aa94796c1b0..e39ad17a7daa 100644 --- a/test/js/samples/optional-chaining/expected.js +++ b/test/js/samples/optional-chaining/expected.js @@ -9,6 +9,7 @@ import { init, insert, mount_component, + noop, safe_not_equal, set_data, space, @@ -182,7 +183,7 @@ function instance($$self, $$props, $$invalidate) { class Component_1 extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { a: 0, b: 1, c: 2, d: 3, e: 4, f: 5 }); + init(this, options, instance, create_fragment, safe_not_equal, { a: 0, b: 1, c: 2, d: 3, e: 4, f: 5 }, noop); } } diff --git a/test/js/samples/select-dynamic-value/expected.js b/test/js/samples/select-dynamic-value/expected.js index 8777cd260072..ddc5c63d7781 100644 --- a/test/js/samples/select-dynamic-value/expected.js +++ b/test/js/samples/select-dynamic-value/expected.js @@ -60,7 +60,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { current: 0 }); + init(this, options, instance, create_fragment, safe_not_equal, { current: 0 }, noop); } } diff --git a/test/js/samples/src-attribute-check/expected.js b/test/js/samples/src-attribute-check/expected.js index 93638edfb43b..f478b53124d8 100644 --- a/test/js/samples/src-attribute-check/expected.js +++ b/test/js/samples/src-attribute-check/expected.js @@ -78,7 +78,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { url: 0, slug: 1 }); + init(this, options, instance, create_fragment, safe_not_equal, { url: 0, slug: 1 }, noop); } } diff --git a/test/js/samples/title/expected.js b/test/js/samples/title/expected.js index b10f569759d4..834ee9eb040e 100644 --- a/test/js/samples/title/expected.js +++ b/test/js/samples/title/expected.js @@ -32,7 +32,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { custom: 0 }); + init(this, options, instance, create_fragment, safe_not_equal, { custom: 0 }, noop); } } diff --git a/test/js/samples/transition-local/expected.js b/test/js/samples/transition-local/expected.js index ea3d9db3d7e6..83623be737f6 100644 --- a/test/js/samples/transition-local/expected.js +++ b/test/js/samples/transition-local/expected.js @@ -117,7 +117,7 @@ function create_fragment(ctx) { } function foo() { - + } function instance($$self, $$props, $$invalidate) { @@ -135,7 +135,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { x: 0, y: 1 }); + init(this, options, instance, create_fragment, safe_not_equal, { x: 0, y: 1 }, noop); } } diff --git a/test/js/samples/transition-repeated-outro/expected.js b/test/js/samples/transition-repeated-outro/expected.js index 12483ab91af7..6e4126d2db50 100644 --- a/test/js/samples/transition-repeated-outro/expected.js +++ b/test/js/samples/transition-repeated-outro/expected.js @@ -9,6 +9,7 @@ import { group_outros, init, insert, + noop, safe_not_equal, transition_in, transition_out @@ -112,7 +113,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { num: 0 }); + init(this, options, instance, create_fragment, safe_not_equal, { num: 0 }, noop); } } diff --git a/test/js/samples/unchanged-expression/expected.js b/test/js/samples/unchanged-expression/expected.js index 673d5b6abc8d..d50c7172787a 100644 --- a/test/js/samples/unchanged-expression/expected.js +++ b/test/js/samples/unchanged-expression/expected.js @@ -85,7 +85,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}); + init(this, options, instance, create_fragment, safe_not_equal, {}, noop); } } diff --git a/test/js/samples/unreferenced-state-not-invalidated/expected.js b/test/js/samples/unreferenced-state-not-invalidated/expected.js index b10ea815b966..15182df8c3dc 100644 --- a/test/js/samples/unreferenced-state-not-invalidated/expected.js +++ b/test/js/samples/unreferenced-state-not-invalidated/expected.js @@ -70,7 +70,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}); + init(this, options, instance, create_fragment, safe_not_equal, {}, noop); } } diff --git a/test/js/samples/use-elements-as-anchors/expected.js b/test/js/samples/use-elements-as-anchors/expected.js index d07411518e91..3ac9717a9160 100644 --- a/test/js/samples/use-elements-as-anchors/expected.js +++ b/test/js/samples/use-elements-as-anchors/expected.js @@ -158,7 +158,7 @@ function create_fragment(ctx) { p(ctx, [dirty]) { if (/*a*/ ctx[0]) { if (if_block0) { - + } else { if_block0 = create_if_block_4(ctx); if_block0.c(); @@ -171,7 +171,7 @@ function create_fragment(ctx) { if (/*b*/ ctx[1]) { if (if_block1) { - + } else { if_block1 = create_if_block_3(ctx); if_block1.c(); @@ -184,7 +184,7 @@ function create_fragment(ctx) { if (/*c*/ ctx[2]) { if (if_block2) { - + } else { if_block2 = create_if_block_2(ctx); if_block2.c(); @@ -197,7 +197,7 @@ function create_fragment(ctx) { if (/*d*/ ctx[3]) { if (if_block3) { - + } else { if_block3 = create_if_block_1(ctx); if_block3.c(); @@ -210,7 +210,7 @@ function create_fragment(ctx) { if (/*e*/ ctx[4]) { if (if_block4) { - + } else { if_block4 = create_if_block(ctx); if_block4.c(); @@ -257,7 +257,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { a: 0, b: 1, c: 2, d: 3, e: 4 }); + init(this, options, instance, create_fragment, safe_not_equal, { a: 0, b: 1, c: 2, d: 3, e: 4 }, noop); } } diff --git a/test/js/samples/video-bindings/expected.js b/test/js/samples/video-bindings/expected.js index 8afa670bbb52..09f3b4a75fe4 100644 --- a/test/js/samples/video-bindings/expected.js +++ b/test/js/samples/video-bindings/expected.js @@ -120,7 +120,7 @@ class Component extends SvelteComponent { videoHeight: 1, videoWidth: 2, offsetWidth: 3 - }); + }, noop); } } diff --git a/test/js/samples/window-binding-online/expected.js b/test/js/samples/window-binding-online/expected.js index 887195bce1b3..1b9fd41bc627 100644 --- a/test/js/samples/window-binding-online/expected.js +++ b/test/js/samples/window-binding-online/expected.js @@ -49,7 +49,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}); + init(this, options, instance, create_fragment, safe_not_equal, {}, noop); } } diff --git a/test/js/samples/window-binding-scroll/expected.js b/test/js/samples/window-binding-scroll/expected.js index 09a4d3737d29..c170d67102bc 100644 --- a/test/js/samples/window-binding-scroll/expected.js +++ b/test/js/samples/window-binding-scroll/expected.js @@ -88,7 +88,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { y: 0 }); + init(this, options, instance, create_fragment, safe_not_equal, { y: 0 }, noop); } } From 7bd2ed6096e51167ae094611f5287584075d62a4 Mon Sep 17 00:00:00 2001 From: Ivan Hofer Date: Tue, 10 Nov 2020 08:04:44 +0100 Subject: [PATCH 07/31] add 'noop' param to some more tests --- test/js/samples/action/expected.js | 2 +- .../expected.js | 11 +++--- .../component-static-immutable/expected.js | 2 +- .../component-static-immutable2/expected.js | 2 +- .../expected.js | 3 +- .../samples/computed-collapsed-if/expected.js | 4 +-- test/js/samples/css-media-query/expected.js | 12 +++---- .../css-shadow-dom-keyframes/expected.js | 3 +- .../js/samples/deconflict-globals/expected.js | 4 +-- .../samples/dont-invalidate-this/expected.js | 2 +- test/js/samples/dynamic-import/expected.js | 2 +- test/js/samples/empty-dom/expected.js | 4 +-- .../event-handler-no-passive/expected.js | 2 +- test/js/samples/event-modifiers/expected.js | 6 ++-- .../js/samples/head-no-whitespace/expected.js | 2 +- test/js/samples/hoisted-const/expected.js | 2 +- test/js/samples/hoisted-let/expected.js | 2 +- .../samples/hydrated-void-element/expected.js | 2 +- .../inline-style-unoptimized/expected.js | 2 +- .../inline-style-without-updates/expected.js | 2 +- .../input-no-initial-value/expected.js | 2 +- test/js/samples/legacy-input-type/expected.js | 2 +- test/js/samples/media-bindings/expected.js | 34 ++++++++++++------- .../non-imported-component/expected.js | 2 +- .../samples/non-mutable-reference/expected.js | 2 +- .../expected.js | 4 +-- .../expected.js | 4 +-- test/js/samples/setup-method/expected.js | 4 +-- test/js/samples/svg-title/expected.js | 2 +- .../expected.js | 2 +- test/js/samples/video-bindings/expected.js | 20 +++++++---- 31 files changed, 80 insertions(+), 69 deletions(-) diff --git a/test/js/samples/action/expected.js b/test/js/samples/action/expected.js index d52960bddd30..767a4574b81f 100644 --- a/test/js/samples/action/expected.js +++ b/test/js/samples/action/expected.js @@ -60,7 +60,7 @@ function link(node) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, null, create_fragment, safe_not_equal, {}); + init(this, options, null, create_fragment, safe_not_equal, {}, noop); } } diff --git a/test/js/samples/collapses-text-around-comments/expected.js b/test/js/samples/collapses-text-around-comments/expected.js index 41a574eba5e5..b32c38dd02f7 100644 --- a/test/js/samples/collapses-text-around-comments/expected.js +++ b/test/js/samples/collapses-text-around-comments/expected.js @@ -2,6 +2,7 @@ import { SvelteComponent, append, + appendStyleIfNotPresent, attr, detach, element, @@ -13,11 +14,8 @@ import { text } from "svelte/internal"; -function add_css() { - var style = element("style"); - style.id = "svelte-1a7i8ec-style"; - style.textContent = "p.svelte-1a7i8ec{color:red}"; - append(document.head, style); +function add_css(customStyleTag) { + appendStyleIfNotPresent(customStyleTag || document.head, "svelte-1a7i8ec-style", "p.svelte-1a7i8ec{color:red}"); } function create_fragment(ctx) { @@ -58,8 +56,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - if (!document.getElementById("svelte-1a7i8ec-style")) add_css(); - init(this, options, instance, create_fragment, safe_not_equal, { foo: 0 }, noop); + init(this, options, instance, create_fragment, safe_not_equal, { foo: 0 }, add_css); } } diff --git a/test/js/samples/component-static-immutable/expected.js b/test/js/samples/component-static-immutable/expected.js index b0c416541334..7de4e04bb9b8 100644 --- a/test/js/samples/component-static-immutable/expected.js +++ b/test/js/samples/component-static-immutable/expected.js @@ -48,7 +48,7 @@ function instance($$self) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, not_equal, {}); + init(this, options, instance, create_fragment, not_equal, {}, noop); } } diff --git a/test/js/samples/component-static-immutable2/expected.js b/test/js/samples/component-static-immutable2/expected.js index b0c416541334..7de4e04bb9b8 100644 --- a/test/js/samples/component-static-immutable2/expected.js +++ b/test/js/samples/component-static-immutable2/expected.js @@ -48,7 +48,7 @@ function instance($$self) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, not_equal, {}); + init(this, options, instance, create_fragment, not_equal, {}, noop); } } diff --git a/test/js/samples/component-store-file-invalidate/expected.js b/test/js/samples/component-store-file-invalidate/expected.js index d2fb3d0be467..27cfd9a56a2f 100644 --- a/test/js/samples/component-store-file-invalidate/expected.js +++ b/test/js/samples/component-store-file-invalidate/expected.js @@ -3,6 +3,7 @@ import { SvelteComponent, component_subscribe, init, + noop, safe_not_equal, set_store_value } from "svelte/internal"; @@ -23,7 +24,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, null, safe_not_equal, { increment: 0 }); + init(this, options, instance, null, safe_not_equal, { increment: 0 }, noop); } get increment() { diff --git a/test/js/samples/computed-collapsed-if/expected.js b/test/js/samples/computed-collapsed-if/expected.js index 3e70d6a7ae18..aea957865250 100644 --- a/test/js/samples/computed-collapsed-if/expected.js +++ b/test/js/samples/computed-collapsed-if/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { SvelteComponent, init, safe_not_equal } from "svelte/internal"; +import { SvelteComponent, init, noop, safe_not_equal } from "svelte/internal"; function instance($$self, $$props, $$invalidate) { let { x } = $$props; @@ -22,7 +22,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, null, safe_not_equal, { x: 0, a: 1, b: 2 }); + init(this, options, instance, null, safe_not_equal, { x: 0, a: 1, b: 2 }, noop); } get a() { diff --git a/test/js/samples/css-media-query/expected.js b/test/js/samples/css-media-query/expected.js index f4776700599d..007636ce09ad 100644 --- a/test/js/samples/css-media-query/expected.js +++ b/test/js/samples/css-media-query/expected.js @@ -1,7 +1,7 @@ /* generated by Svelte vX.Y.Z */ import { SvelteComponent, - append, + appendStyleIfNotPresent, attr, detach, element, @@ -11,11 +11,8 @@ import { safe_not_equal } from "svelte/internal"; -function add_css() { - var style = element("style"); - style.id = "svelte-1slhpfn-style"; - style.textContent = "@media(min-width: 1px){div.svelte-1slhpfn{color:red}}"; - append(document.head, style); +function add_css(customStyleTag) { + appendStyleIfNotPresent(customStyleTag || document.head, "svelte-1slhpfn-style", "@media(min-width: 1px){div.svelte-1slhpfn{color:red}}"); } function create_fragment(ctx) { @@ -41,8 +38,7 @@ function create_fragment(ctx) { class Component extends SvelteComponent { constructor(options) { super(); - 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, {}, add_css); } } diff --git a/test/js/samples/css-shadow-dom-keyframes/expected.js b/test/js/samples/css-shadow-dom-keyframes/expected.js index 82a39e5924ff..5f87f4a0a8a5 100644 --- a/test/js/samples/css-shadow-dom-keyframes/expected.js +++ b/test/js/samples/css-shadow-dom-keyframes/expected.js @@ -45,7 +45,8 @@ class Component extends SvelteElement { null, create_fragment, safe_not_equal, - {} + {}, + noop ); if (options) { diff --git a/test/js/samples/deconflict-globals/expected.js b/test/js/samples/deconflict-globals/expected.js index 7168eba6a5d9..290f8e65093c 100644 --- a/test/js/samples/deconflict-globals/expected.js +++ b/test/js/samples/deconflict-globals/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { SvelteComponent, init, safe_not_equal } from "svelte/internal"; +import { SvelteComponent, init, noop, safe_not_equal } from "svelte/internal"; import { onMount } from "svelte"; @@ -20,7 +20,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, null, safe_not_equal, { foo: 0 }); + init(this, options, instance, null, safe_not_equal, { foo: 0 }, noop); } } diff --git a/test/js/samples/dont-invalidate-this/expected.js b/test/js/samples/dont-invalidate-this/expected.js index 0b155373a14f..33d86f414801 100644 --- a/test/js/samples/dont-invalidate-this/expected.js +++ b/test/js/samples/dont-invalidate-this/expected.js @@ -45,7 +45,7 @@ function make_uppercase() { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, null, create_fragment, safe_not_equal, {}); + init(this, options, null, create_fragment, safe_not_equal, {}, noop); } } diff --git a/test/js/samples/dynamic-import/expected.js b/test/js/samples/dynamic-import/expected.js index d1085f431b7c..559ad9217cb0 100644 --- a/test/js/samples/dynamic-import/expected.js +++ b/test/js/samples/dynamic-import/expected.js @@ -47,7 +47,7 @@ const func = () => import("./Foo.svelte"); class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, null, create_fragment, safe_not_equal, {}); + init(this, options, null, create_fragment, safe_not_equal, {}, noop); } } diff --git a/test/js/samples/empty-dom/expected.js b/test/js/samples/empty-dom/expected.js index d5c80be696b5..b3e57758c150 100644 --- a/test/js/samples/empty-dom/expected.js +++ b/test/js/samples/empty-dom/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { SvelteComponent, init, safe_not_equal } from "svelte/internal"; +import { SvelteComponent, init, noop, safe_not_equal } from "svelte/internal"; function instance($$self) { const a = 1 + 2; @@ -9,7 +9,7 @@ function instance($$self) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, null, safe_not_equal, {}); + init(this, options, instance, null, safe_not_equal, {}, noop); } } diff --git a/test/js/samples/event-handler-no-passive/expected.js b/test/js/samples/event-handler-no-passive/expected.js index 4d4b910d4eae..de4b3225a234 100644 --- a/test/js/samples/event-handler-no-passive/expected.js +++ b/test/js/samples/event-handler-no-passive/expected.js @@ -46,7 +46,7 @@ const touchstart_handler = e => e.preventDefault(); class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, null, create_fragment, safe_not_equal, {}); + init(this, options, null, create_fragment, safe_not_equal, {}, noop); } } diff --git a/test/js/samples/event-modifiers/expected.js b/test/js/samples/event-modifiers/expected.js index 3901753661d2..b444d4cba187 100644 --- a/test/js/samples/event-modifiers/expected.js +++ b/test/js/samples/event-modifiers/expected.js @@ -76,17 +76,17 @@ function create_fragment(ctx) { } function handleTouchstart() { - + } // ... function handleClick() { - + } // ... class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, null, create_fragment, safe_not_equal, {}); + init(this, options, null, create_fragment, safe_not_equal, {}, noop); } } diff --git a/test/js/samples/head-no-whitespace/expected.js b/test/js/samples/head-no-whitespace/expected.js index 444bad3fd48a..cf7104c744d9 100644 --- a/test/js/samples/head-no-whitespace/expected.js +++ b/test/js/samples/head-no-whitespace/expected.js @@ -40,7 +40,7 @@ function create_fragment(ctx) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, null, create_fragment, safe_not_equal, {}); + init(this, options, null, create_fragment, safe_not_equal, {}, noop); } } diff --git a/test/js/samples/hoisted-const/expected.js b/test/js/samples/hoisted-const/expected.js index 2842b547516e..af72500ea95a 100644 --- a/test/js/samples/hoisted-const/expected.js +++ b/test/js/samples/hoisted-const/expected.js @@ -38,7 +38,7 @@ function get_answer() { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, null, create_fragment, safe_not_equal, {}); + init(this, options, null, create_fragment, safe_not_equal, {}, noop); } } diff --git a/test/js/samples/hoisted-let/expected.js b/test/js/samples/hoisted-let/expected.js index 285b12411835..d5401f2f21d7 100644 --- a/test/js/samples/hoisted-let/expected.js +++ b/test/js/samples/hoisted-let/expected.js @@ -38,7 +38,7 @@ function get_answer() { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, null, create_fragment, safe_not_equal, {}); + init(this, options, null, create_fragment, safe_not_equal, {}, noop); } } diff --git a/test/js/samples/hydrated-void-element/expected.js b/test/js/samples/hydrated-void-element/expected.js index e53d16d9250e..b7e9990d1e17 100644 --- a/test/js/samples/hydrated-void-element/expected.js +++ b/test/js/samples/hydrated-void-element/expected.js @@ -57,7 +57,7 @@ function create_fragment(ctx) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, null, create_fragment, safe_not_equal, {}); + init(this, options, null, create_fragment, safe_not_equal, {}, noop); } } diff --git a/test/js/samples/inline-style-unoptimized/expected.js b/test/js/samples/inline-style-unoptimized/expected.js index 0688f14b9b24..fac15c691a90 100644 --- a/test/js/samples/inline-style-unoptimized/expected.js +++ b/test/js/samples/inline-style-unoptimized/expected.js @@ -66,7 +66,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { style: 0, key: 1, value: 2 }); + init(this, options, instance, create_fragment, safe_not_equal, { style: 0, key: 1, value: 2 }, noop); } } diff --git a/test/js/samples/inline-style-without-updates/expected.js b/test/js/samples/inline-style-without-updates/expected.js index 375896f259ea..8a3768a04869 100644 --- a/test/js/samples/inline-style-without-updates/expected.js +++ b/test/js/samples/inline-style-without-updates/expected.js @@ -35,7 +35,7 @@ let color = "red"; class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, null, create_fragment, safe_not_equal, {}); + init(this, options, null, create_fragment, safe_not_equal, {}, noop); } } diff --git a/test/js/samples/input-no-initial-value/expected.js b/test/js/samples/input-no-initial-value/expected.js index 3354aa31117e..8ece8f5ce2a4 100644 --- a/test/js/samples/input-no-initial-value/expected.js +++ b/test/js/samples/input-no-initial-value/expected.js @@ -83,7 +83,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}); + init(this, options, instance, create_fragment, safe_not_equal, {}, noop); } } diff --git a/test/js/samples/legacy-input-type/expected.js b/test/js/samples/legacy-input-type/expected.js index 2b76a485225a..6f07bbc8d5c2 100644 --- a/test/js/samples/legacy-input-type/expected.js +++ b/test/js/samples/legacy-input-type/expected.js @@ -33,7 +33,7 @@ function create_fragment(ctx) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, null, create_fragment, safe_not_equal, {}); + init(this, options, null, create_fragment, safe_not_equal, {}, noop); } } diff --git a/test/js/samples/media-bindings/expected.js b/test/js/samples/media-bindings/expected.js index 9ee63938fa08..78f248588c2d 100644 --- a/test/js/samples/media-bindings/expected.js +++ b/test/js/samples/media-bindings/expected.js @@ -215,19 +215,27 @@ class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { - buffered: 0, - seekable: 1, - played: 2, - currentTime: 3, - duration: 4, - paused: 5, - volume: 6, - muted: 7, - playbackRate: 8, - seeking: 9, - ended: 10 - }, noop); + init( + this, + options, + instance, + create_fragment, + safe_not_equal, + { + buffered: 0, + seekable: 1, + played: 2, + currentTime: 3, + duration: 4, + paused: 5, + volume: 6, + muted: 7, + playbackRate: 8, + seeking: 9, + ended: 10 + }, + noop + ); } } diff --git a/test/js/samples/non-imported-component/expected.js b/test/js/samples/non-imported-component/expected.js index 5a6b8e8bb730..5c77f9d9f478 100644 --- a/test/js/samples/non-imported-component/expected.js +++ b/test/js/samples/non-imported-component/expected.js @@ -59,7 +59,7 @@ function create_fragment(ctx) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, null, create_fragment, safe_not_equal, {}); + init(this, options, null, create_fragment, safe_not_equal, {}, noop); } } diff --git a/test/js/samples/non-mutable-reference/expected.js b/test/js/samples/non-mutable-reference/expected.js index 93f2145a2e65..46b175dcb007 100644 --- a/test/js/samples/non-mutable-reference/expected.js +++ b/test/js/samples/non-mutable-reference/expected.js @@ -34,7 +34,7 @@ let name = "world"; class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, null, create_fragment, safe_not_equal, {}); + init(this, options, null, create_fragment, safe_not_equal, {}, noop); } } diff --git a/test/js/samples/reactive-values-non-topologically-ordered/expected.js b/test/js/samples/reactive-values-non-topologically-ordered/expected.js index 15290496d527..29ca096fddd1 100644 --- a/test/js/samples/reactive-values-non-topologically-ordered/expected.js +++ b/test/js/samples/reactive-values-non-topologically-ordered/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { SvelteComponent, init, safe_not_equal } from "svelte/internal"; +import { SvelteComponent, init, noop, safe_not_equal } from "svelte/internal"; function instance($$self, $$props, $$invalidate) { let { x } = $$props; @@ -26,7 +26,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, null, safe_not_equal, { x: 0 }); + init(this, options, instance, null, safe_not_equal, { x: 0 }, noop); } } diff --git a/test/js/samples/reactive-values-non-writable-dependencies/expected.js b/test/js/samples/reactive-values-non-writable-dependencies/expected.js index 5196a770d976..82e43098279f 100644 --- a/test/js/samples/reactive-values-non-writable-dependencies/expected.js +++ b/test/js/samples/reactive-values-non-writable-dependencies/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { SvelteComponent, init, safe_not_equal } from "svelte/internal"; +import { SvelteComponent, init, noop, safe_not_equal } from "svelte/internal"; function instance($$self, $$props, $$invalidate) { let { a = 1 } = $$props; @@ -22,7 +22,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, null, safe_not_equal, { a: 0, b: 1 }); + init(this, options, instance, null, safe_not_equal, { a: 0, b: 1 }, noop); } } diff --git a/test/js/samples/setup-method/expected.js b/test/js/samples/setup-method/expected.js index 8e30a03a7dd4..a5d2f046aadd 100644 --- a/test/js/samples/setup-method/expected.js +++ b/test/js/samples/setup-method/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { SvelteComponent, init, safe_not_equal } from "svelte/internal"; +import { SvelteComponent, init, noop, safe_not_equal } from "svelte/internal"; const SOME_CONSTANT = 42; @@ -14,7 +14,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, null, safe_not_equal, { foo: 0 }); + init(this, options, instance, null, safe_not_equal, { foo: 0 }, noop); } get foo() { diff --git a/test/js/samples/svg-title/expected.js b/test/js/samples/svg-title/expected.js index cd7ae3b55152..aacef416e230 100644 --- a/test/js/samples/svg-title/expected.js +++ b/test/js/samples/svg-title/expected.js @@ -39,7 +39,7 @@ function create_fragment(ctx) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, null, create_fragment, safe_not_equal, {}); + init(this, options, null, create_fragment, safe_not_equal, {}, noop); } } diff --git a/test/js/samples/valid-inner-html-for-static-element/expected.js b/test/js/samples/valid-inner-html-for-static-element/expected.js index f1ced27ba458..241e083b6155 100644 --- a/test/js/samples/valid-inner-html-for-static-element/expected.js +++ b/test/js/samples/valid-inner-html-for-static-element/expected.js @@ -32,7 +32,7 @@ function create_fragment(ctx) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, null, create_fragment, safe_not_equal, {}); + init(this, options, null, create_fragment, safe_not_equal, {}, noop); } } diff --git a/test/js/samples/video-bindings/expected.js b/test/js/samples/video-bindings/expected.js index 09f3b4a75fe4..5199c7fa834c 100644 --- a/test/js/samples/video-bindings/expected.js +++ b/test/js/samples/video-bindings/expected.js @@ -115,12 +115,20 @@ class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { - currentTime: 0, - videoHeight: 1, - videoWidth: 2, - offsetWidth: 3 - }, noop); + init( + this, + options, + instance, + create_fragment, + safe_not_equal, + { + currentTime: 0, + videoHeight: 1, + videoWidth: 2, + offsetWidth: 3 + }, + noop + ); } } From bf528d16b44e669ac21b55d0e0c8b0d01ca4f0b2 Mon Sep 17 00:00:00 2001 From: Ivan Hofer Date: Tue, 10 Nov 2020 08:21:05 +0100 Subject: [PATCH 08/31] add missing css to customElement constructor --- src/compiler/compile/render_dom/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/compiler/compile/render_dom/index.ts b/src/compiler/compile/render_dom/index.ts index 4673df575656..5917841073fd 100644 --- a/src/compiler/compile/render_dom/index.ts +++ b/src/compiler/compile/render_dom/index.ts @@ -475,6 +475,8 @@ export default function dom( constructor(options) { super(); + ${css.code && b`this.shadowRoot.innerHTML = \`\`;`} + @init(this, { target: this.shadowRoot, props: ${init_props} }, ${definition}, ${has_create_fragment ? 'create_fragment': 'null'}, ${not_equal}, ${prop_indexes}, ${x`@noop`}, ${dirty}); ${dev_props_check} From 5ad396b6b20eb0798c7b26557b2b463cd7e9c9a0 Mon Sep 17 00:00:00 2001 From: Ivan Hofer Date: Wed, 11 Nov 2020 09:42:20 +0100 Subject: [PATCH 09/31] refactor add styles method call to reduce generated output --- src/compiler/compile/render_dom/index.ts | 5 ++++- src/runtime/internal/Component.ts | 18 ++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/compiler/compile/render_dom/index.ts b/src/compiler/compile/render_dom/index.ts index 5917841073fd..61af64e92f79 100644 --- a/src/compiler/compile/render_dom/index.ts +++ b/src/compiler/compile/render_dom/index.ts @@ -528,7 +528,10 @@ export default function dom( class ${name} extends ${superclass} { constructor(options) { super(${options.dev && 'options'}); - @init(this, options, ${definition}, ${has_create_fragment ? 'create_fragment' : 'null'}, ${not_equal}, ${prop_indexes}, ${should_add_css ? add_css : x`@noop`}, ${dirty}); + + ${should_add_css && b`@addCssToComponent(this, add_css, options);`} + + @init(this, options, ${definition}, ${has_create_fragment ? 'create_fragment' : 'null'}, ${not_equal}, ${prop_indexes}, ${dirty}); ${options.dev && b`@dispatch_dev("SvelteRegisterComponent", { component: this, tagName: "${name.name}", options, id: create_fragment.name });`} ${dev_props_check} diff --git a/src/runtime/internal/Component.ts b/src/runtime/internal/Component.ts index 4524a5dba96e..763974adfb4e 100644 --- a/src/runtime/internal/Component.ts +++ b/src/runtime/internal/Component.ts @@ -34,7 +34,7 @@ interface T$$ { on_mount: any[]; on_destroy: any[]; skip_bound: boolean; - customStyleTag: HTMLElement; + customStyleTag?: HTMLElement; } export function bind(component, name, callback) { @@ -97,18 +97,26 @@ function make_dirty(component, i) { component.$$.dirty[(i / 31) | 0] |= (1 << (i % 31)); } -export function init(component, options, instance, create_fragment, not_equal, props, add_css, dirty = [-1]) { + +export function addCssToComponent(that, add_css, options) { + that.$$ = { + customStyleTag: options.customStyleTag || current_component && current_component.$$.customStyleTag + }; + add_css(that.$$.customStyleTag); +} + +export function init(component, options, instance, create_fragment, not_equal, props, dirty = [-1]) { const parent_component = current_component; set_current_component(component); const prop_values = options.props || {}; const $$: T$$ = component.$$ = { + ...component.$$, + fragment: null, ctx: null, - customStyleTag: options.customStyleTag || parent_component && parent_component.$$.customStyleTag, - // state props, update: noop, @@ -130,8 +138,6 @@ export function init(component, options, instance, create_fragment, not_equal, p let ready = false; - add_css($$.customStyleTag); - $$.ctx = instance ? instance(component, prop_values, (i, ret, ...rest) => { const value = rest.length ? rest[0] : ret; From c154895a7754ba51d263555e72eab452c2a585f4 Mon Sep 17 00:00:00 2001 From: Ivan Hofer Date: Thu, 12 Nov 2020 07:06:45 +0100 Subject: [PATCH 10/31] init $$ in component with empty object value --- src/runtime/internal/Component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime/internal/Component.ts b/src/runtime/internal/Component.ts index 763974adfb4e..f020b78e8a85 100644 --- a/src/runtime/internal/Component.ts +++ b/src/runtime/internal/Component.ts @@ -224,7 +224,7 @@ if (typeof HTMLElement === 'function') { } export class SvelteComponent { - $$: T$$; + $$: T$$ = {} as T$$; $$set?: ($$props: any) => void; $destroy() { From 675d6ddd100e51890587e0a7972de0e668e5fb4e Mon Sep 17 00:00:00 2001 From: Ivan Hofer Date: Thu, 12 Nov 2020 07:07:42 +0100 Subject: [PATCH 11/31] Revert "add 'noop' param to some more tests" This reverts commit 7bd2ed6096e51167ae094611f5287584075d62a4. --- test/js/samples/action/expected.js | 2 +- .../expected.js | 11 +++--- .../component-static-immutable/expected.js | 2 +- .../component-static-immutable2/expected.js | 2 +- .../expected.js | 3 +- .../samples/computed-collapsed-if/expected.js | 4 +-- test/js/samples/css-media-query/expected.js | 12 ++++--- .../css-shadow-dom-keyframes/expected.js | 3 +- .../js/samples/deconflict-globals/expected.js | 4 +-- .../samples/dont-invalidate-this/expected.js | 2 +- test/js/samples/dynamic-import/expected.js | 2 +- test/js/samples/empty-dom/expected.js | 4 +-- .../event-handler-no-passive/expected.js | 2 +- test/js/samples/event-modifiers/expected.js | 6 ++-- .../js/samples/head-no-whitespace/expected.js | 2 +- test/js/samples/hoisted-const/expected.js | 2 +- test/js/samples/hoisted-let/expected.js | 2 +- .../samples/hydrated-void-element/expected.js | 2 +- .../inline-style-unoptimized/expected.js | 2 +- .../inline-style-without-updates/expected.js | 2 +- .../input-no-initial-value/expected.js | 2 +- test/js/samples/legacy-input-type/expected.js | 2 +- test/js/samples/media-bindings/expected.js | 34 +++++++------------ .../non-imported-component/expected.js | 2 +- .../samples/non-mutable-reference/expected.js | 2 +- .../expected.js | 4 +-- .../expected.js | 4 +-- test/js/samples/setup-method/expected.js | 4 +-- test/js/samples/svg-title/expected.js | 2 +- .../expected.js | 2 +- test/js/samples/video-bindings/expected.js | 20 ++++------- 31 files changed, 69 insertions(+), 80 deletions(-) diff --git a/test/js/samples/action/expected.js b/test/js/samples/action/expected.js index 767a4574b81f..d52960bddd30 100644 --- a/test/js/samples/action/expected.js +++ b/test/js/samples/action/expected.js @@ -60,7 +60,7 @@ function link(node) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, null, create_fragment, safe_not_equal, {}, noop); + init(this, options, null, create_fragment, safe_not_equal, {}); } } diff --git a/test/js/samples/collapses-text-around-comments/expected.js b/test/js/samples/collapses-text-around-comments/expected.js index b32c38dd02f7..41a574eba5e5 100644 --- a/test/js/samples/collapses-text-around-comments/expected.js +++ b/test/js/samples/collapses-text-around-comments/expected.js @@ -2,7 +2,6 @@ import { SvelteComponent, append, - appendStyleIfNotPresent, attr, detach, element, @@ -14,8 +13,11 @@ import { text } from "svelte/internal"; -function add_css(customStyleTag) { - appendStyleIfNotPresent(customStyleTag || document.head, "svelte-1a7i8ec-style", "p.svelte-1a7i8ec{color:red}"); +function add_css() { + var style = element("style"); + style.id = "svelte-1a7i8ec-style"; + style.textContent = "p.svelte-1a7i8ec{color:red}"; + append(document.head, style); } function create_fragment(ctx) { @@ -56,7 +58,8 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { foo: 0 }, add_css); + if (!document.getElementById("svelte-1a7i8ec-style")) add_css(); + init(this, options, instance, create_fragment, safe_not_equal, { foo: 0 }, noop); } } diff --git a/test/js/samples/component-static-immutable/expected.js b/test/js/samples/component-static-immutable/expected.js index 7de4e04bb9b8..b0c416541334 100644 --- a/test/js/samples/component-static-immutable/expected.js +++ b/test/js/samples/component-static-immutable/expected.js @@ -48,7 +48,7 @@ function instance($$self) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, not_equal, {}, noop); + init(this, options, instance, create_fragment, not_equal, {}); } } diff --git a/test/js/samples/component-static-immutable2/expected.js b/test/js/samples/component-static-immutable2/expected.js index 7de4e04bb9b8..b0c416541334 100644 --- a/test/js/samples/component-static-immutable2/expected.js +++ b/test/js/samples/component-static-immutable2/expected.js @@ -48,7 +48,7 @@ function instance($$self) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, not_equal, {}, noop); + init(this, options, instance, create_fragment, not_equal, {}); } } diff --git a/test/js/samples/component-store-file-invalidate/expected.js b/test/js/samples/component-store-file-invalidate/expected.js index 27cfd9a56a2f..d2fb3d0be467 100644 --- a/test/js/samples/component-store-file-invalidate/expected.js +++ b/test/js/samples/component-store-file-invalidate/expected.js @@ -3,7 +3,6 @@ import { SvelteComponent, component_subscribe, init, - noop, safe_not_equal, set_store_value } from "svelte/internal"; @@ -24,7 +23,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, null, safe_not_equal, { increment: 0 }, noop); + init(this, options, instance, null, safe_not_equal, { increment: 0 }); } get increment() { diff --git a/test/js/samples/computed-collapsed-if/expected.js b/test/js/samples/computed-collapsed-if/expected.js index aea957865250..3e70d6a7ae18 100644 --- a/test/js/samples/computed-collapsed-if/expected.js +++ b/test/js/samples/computed-collapsed-if/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { SvelteComponent, init, noop, safe_not_equal } from "svelte/internal"; +import { SvelteComponent, init, safe_not_equal } from "svelte/internal"; function instance($$self, $$props, $$invalidate) { let { x } = $$props; @@ -22,7 +22,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, null, safe_not_equal, { x: 0, a: 1, b: 2 }, noop); + init(this, options, instance, null, safe_not_equal, { x: 0, a: 1, b: 2 }); } get a() { diff --git a/test/js/samples/css-media-query/expected.js b/test/js/samples/css-media-query/expected.js index 007636ce09ad..f4776700599d 100644 --- a/test/js/samples/css-media-query/expected.js +++ b/test/js/samples/css-media-query/expected.js @@ -1,7 +1,7 @@ /* generated by Svelte vX.Y.Z */ import { SvelteComponent, - appendStyleIfNotPresent, + append, attr, detach, element, @@ -11,8 +11,11 @@ import { safe_not_equal } from "svelte/internal"; -function add_css(customStyleTag) { - appendStyleIfNotPresent(customStyleTag || document.head, "svelte-1slhpfn-style", "@media(min-width: 1px){div.svelte-1slhpfn{color:red}}"); +function add_css() { + var style = element("style"); + style.id = "svelte-1slhpfn-style"; + style.textContent = "@media(min-width: 1px){div.svelte-1slhpfn{color:red}}"; + append(document.head, style); } function create_fragment(ctx) { @@ -38,7 +41,8 @@ function create_fragment(ctx) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, null, create_fragment, safe_not_equal, {}, add_css); + if (!document.getElementById("svelte-1slhpfn-style")) add_css(); + init(this, options, null, create_fragment, safe_not_equal, {}); } } diff --git a/test/js/samples/css-shadow-dom-keyframes/expected.js b/test/js/samples/css-shadow-dom-keyframes/expected.js index 5f87f4a0a8a5..82a39e5924ff 100644 --- a/test/js/samples/css-shadow-dom-keyframes/expected.js +++ b/test/js/samples/css-shadow-dom-keyframes/expected.js @@ -45,8 +45,7 @@ class Component extends SvelteElement { null, create_fragment, safe_not_equal, - {}, - noop + {} ); if (options) { diff --git a/test/js/samples/deconflict-globals/expected.js b/test/js/samples/deconflict-globals/expected.js index 290f8e65093c..7168eba6a5d9 100644 --- a/test/js/samples/deconflict-globals/expected.js +++ b/test/js/samples/deconflict-globals/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { SvelteComponent, init, noop, safe_not_equal } from "svelte/internal"; +import { SvelteComponent, init, safe_not_equal } from "svelte/internal"; import { onMount } from "svelte"; @@ -20,7 +20,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, null, safe_not_equal, { foo: 0 }, noop); + init(this, options, instance, null, safe_not_equal, { foo: 0 }); } } diff --git a/test/js/samples/dont-invalidate-this/expected.js b/test/js/samples/dont-invalidate-this/expected.js index 33d86f414801..0b155373a14f 100644 --- a/test/js/samples/dont-invalidate-this/expected.js +++ b/test/js/samples/dont-invalidate-this/expected.js @@ -45,7 +45,7 @@ function make_uppercase() { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, null, create_fragment, safe_not_equal, {}, noop); + init(this, options, null, create_fragment, safe_not_equal, {}); } } diff --git a/test/js/samples/dynamic-import/expected.js b/test/js/samples/dynamic-import/expected.js index 559ad9217cb0..d1085f431b7c 100644 --- a/test/js/samples/dynamic-import/expected.js +++ b/test/js/samples/dynamic-import/expected.js @@ -47,7 +47,7 @@ const func = () => import("./Foo.svelte"); class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, null, create_fragment, safe_not_equal, {}, noop); + init(this, options, null, create_fragment, safe_not_equal, {}); } } diff --git a/test/js/samples/empty-dom/expected.js b/test/js/samples/empty-dom/expected.js index b3e57758c150..d5c80be696b5 100644 --- a/test/js/samples/empty-dom/expected.js +++ b/test/js/samples/empty-dom/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { SvelteComponent, init, noop, safe_not_equal } from "svelte/internal"; +import { SvelteComponent, init, safe_not_equal } from "svelte/internal"; function instance($$self) { const a = 1 + 2; @@ -9,7 +9,7 @@ function instance($$self) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, null, safe_not_equal, {}, noop); + init(this, options, instance, null, safe_not_equal, {}); } } diff --git a/test/js/samples/event-handler-no-passive/expected.js b/test/js/samples/event-handler-no-passive/expected.js index de4b3225a234..4d4b910d4eae 100644 --- a/test/js/samples/event-handler-no-passive/expected.js +++ b/test/js/samples/event-handler-no-passive/expected.js @@ -46,7 +46,7 @@ const touchstart_handler = e => e.preventDefault(); class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, null, create_fragment, safe_not_equal, {}, noop); + init(this, options, null, create_fragment, safe_not_equal, {}); } } diff --git a/test/js/samples/event-modifiers/expected.js b/test/js/samples/event-modifiers/expected.js index b444d4cba187..3901753661d2 100644 --- a/test/js/samples/event-modifiers/expected.js +++ b/test/js/samples/event-modifiers/expected.js @@ -76,17 +76,17 @@ function create_fragment(ctx) { } function handleTouchstart() { - + } // ... function handleClick() { - + } // ... class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, null, create_fragment, safe_not_equal, {}, noop); + init(this, options, null, create_fragment, safe_not_equal, {}); } } diff --git a/test/js/samples/head-no-whitespace/expected.js b/test/js/samples/head-no-whitespace/expected.js index cf7104c744d9..444bad3fd48a 100644 --- a/test/js/samples/head-no-whitespace/expected.js +++ b/test/js/samples/head-no-whitespace/expected.js @@ -40,7 +40,7 @@ function create_fragment(ctx) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, null, create_fragment, safe_not_equal, {}, noop); + init(this, options, null, create_fragment, safe_not_equal, {}); } } diff --git a/test/js/samples/hoisted-const/expected.js b/test/js/samples/hoisted-const/expected.js index af72500ea95a..2842b547516e 100644 --- a/test/js/samples/hoisted-const/expected.js +++ b/test/js/samples/hoisted-const/expected.js @@ -38,7 +38,7 @@ function get_answer() { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, null, create_fragment, safe_not_equal, {}, noop); + init(this, options, null, create_fragment, safe_not_equal, {}); } } diff --git a/test/js/samples/hoisted-let/expected.js b/test/js/samples/hoisted-let/expected.js index d5401f2f21d7..285b12411835 100644 --- a/test/js/samples/hoisted-let/expected.js +++ b/test/js/samples/hoisted-let/expected.js @@ -38,7 +38,7 @@ function get_answer() { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, null, create_fragment, safe_not_equal, {}, noop); + init(this, options, null, create_fragment, safe_not_equal, {}); } } diff --git a/test/js/samples/hydrated-void-element/expected.js b/test/js/samples/hydrated-void-element/expected.js index b7e9990d1e17..e53d16d9250e 100644 --- a/test/js/samples/hydrated-void-element/expected.js +++ b/test/js/samples/hydrated-void-element/expected.js @@ -57,7 +57,7 @@ function create_fragment(ctx) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, null, create_fragment, safe_not_equal, {}, noop); + init(this, options, null, create_fragment, safe_not_equal, {}); } } diff --git a/test/js/samples/inline-style-unoptimized/expected.js b/test/js/samples/inline-style-unoptimized/expected.js index fac15c691a90..0688f14b9b24 100644 --- a/test/js/samples/inline-style-unoptimized/expected.js +++ b/test/js/samples/inline-style-unoptimized/expected.js @@ -66,7 +66,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { style: 0, key: 1, value: 2 }, noop); + init(this, options, instance, create_fragment, safe_not_equal, { style: 0, key: 1, value: 2 }); } } diff --git a/test/js/samples/inline-style-without-updates/expected.js b/test/js/samples/inline-style-without-updates/expected.js index 8a3768a04869..375896f259ea 100644 --- a/test/js/samples/inline-style-without-updates/expected.js +++ b/test/js/samples/inline-style-without-updates/expected.js @@ -35,7 +35,7 @@ let color = "red"; class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, null, create_fragment, safe_not_equal, {}, noop); + init(this, options, null, create_fragment, safe_not_equal, {}); } } diff --git a/test/js/samples/input-no-initial-value/expected.js b/test/js/samples/input-no-initial-value/expected.js index 8ece8f5ce2a4..3354aa31117e 100644 --- a/test/js/samples/input-no-initial-value/expected.js +++ b/test/js/samples/input-no-initial-value/expected.js @@ -83,7 +83,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}, noop); + init(this, options, instance, create_fragment, safe_not_equal, {}); } } diff --git a/test/js/samples/legacy-input-type/expected.js b/test/js/samples/legacy-input-type/expected.js index 6f07bbc8d5c2..2b76a485225a 100644 --- a/test/js/samples/legacy-input-type/expected.js +++ b/test/js/samples/legacy-input-type/expected.js @@ -33,7 +33,7 @@ function create_fragment(ctx) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, null, create_fragment, safe_not_equal, {}, noop); + init(this, options, null, create_fragment, safe_not_equal, {}); } } diff --git a/test/js/samples/media-bindings/expected.js b/test/js/samples/media-bindings/expected.js index 78f248588c2d..9ee63938fa08 100644 --- a/test/js/samples/media-bindings/expected.js +++ b/test/js/samples/media-bindings/expected.js @@ -215,27 +215,19 @@ class Component extends SvelteComponent { constructor(options) { super(); - init( - this, - options, - instance, - create_fragment, - safe_not_equal, - { - buffered: 0, - seekable: 1, - played: 2, - currentTime: 3, - duration: 4, - paused: 5, - volume: 6, - muted: 7, - playbackRate: 8, - seeking: 9, - ended: 10 - }, - noop - ); + init(this, options, instance, create_fragment, safe_not_equal, { + buffered: 0, + seekable: 1, + played: 2, + currentTime: 3, + duration: 4, + paused: 5, + volume: 6, + muted: 7, + playbackRate: 8, + seeking: 9, + ended: 10 + }, noop); } } diff --git a/test/js/samples/non-imported-component/expected.js b/test/js/samples/non-imported-component/expected.js index 5c77f9d9f478..5a6b8e8bb730 100644 --- a/test/js/samples/non-imported-component/expected.js +++ b/test/js/samples/non-imported-component/expected.js @@ -59,7 +59,7 @@ function create_fragment(ctx) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, null, create_fragment, safe_not_equal, {}, noop); + init(this, options, null, create_fragment, safe_not_equal, {}); } } diff --git a/test/js/samples/non-mutable-reference/expected.js b/test/js/samples/non-mutable-reference/expected.js index 46b175dcb007..93f2145a2e65 100644 --- a/test/js/samples/non-mutable-reference/expected.js +++ b/test/js/samples/non-mutable-reference/expected.js @@ -34,7 +34,7 @@ let name = "world"; class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, null, create_fragment, safe_not_equal, {}, noop); + init(this, options, null, create_fragment, safe_not_equal, {}); } } diff --git a/test/js/samples/reactive-values-non-topologically-ordered/expected.js b/test/js/samples/reactive-values-non-topologically-ordered/expected.js index 29ca096fddd1..15290496d527 100644 --- a/test/js/samples/reactive-values-non-topologically-ordered/expected.js +++ b/test/js/samples/reactive-values-non-topologically-ordered/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { SvelteComponent, init, noop, safe_not_equal } from "svelte/internal"; +import { SvelteComponent, init, safe_not_equal } from "svelte/internal"; function instance($$self, $$props, $$invalidate) { let { x } = $$props; @@ -26,7 +26,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, null, safe_not_equal, { x: 0 }, noop); + init(this, options, instance, null, safe_not_equal, { x: 0 }); } } diff --git a/test/js/samples/reactive-values-non-writable-dependencies/expected.js b/test/js/samples/reactive-values-non-writable-dependencies/expected.js index 82e43098279f..5196a770d976 100644 --- a/test/js/samples/reactive-values-non-writable-dependencies/expected.js +++ b/test/js/samples/reactive-values-non-writable-dependencies/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { SvelteComponent, init, noop, safe_not_equal } from "svelte/internal"; +import { SvelteComponent, init, safe_not_equal } from "svelte/internal"; function instance($$self, $$props, $$invalidate) { let { a = 1 } = $$props; @@ -22,7 +22,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, null, safe_not_equal, { a: 0, b: 1 }, noop); + init(this, options, instance, null, safe_not_equal, { a: 0, b: 1 }); } } diff --git a/test/js/samples/setup-method/expected.js b/test/js/samples/setup-method/expected.js index a5d2f046aadd..8e30a03a7dd4 100644 --- a/test/js/samples/setup-method/expected.js +++ b/test/js/samples/setup-method/expected.js @@ -1,5 +1,5 @@ /* generated by Svelte vX.Y.Z */ -import { SvelteComponent, init, noop, safe_not_equal } from "svelte/internal"; +import { SvelteComponent, init, safe_not_equal } from "svelte/internal"; const SOME_CONSTANT = 42; @@ -14,7 +14,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, null, safe_not_equal, { foo: 0 }, noop); + init(this, options, instance, null, safe_not_equal, { foo: 0 }); } get foo() { diff --git a/test/js/samples/svg-title/expected.js b/test/js/samples/svg-title/expected.js index aacef416e230..cd7ae3b55152 100644 --- a/test/js/samples/svg-title/expected.js +++ b/test/js/samples/svg-title/expected.js @@ -39,7 +39,7 @@ function create_fragment(ctx) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, null, create_fragment, safe_not_equal, {}, noop); + init(this, options, null, create_fragment, safe_not_equal, {}); } } diff --git a/test/js/samples/valid-inner-html-for-static-element/expected.js b/test/js/samples/valid-inner-html-for-static-element/expected.js index 241e083b6155..f1ced27ba458 100644 --- a/test/js/samples/valid-inner-html-for-static-element/expected.js +++ b/test/js/samples/valid-inner-html-for-static-element/expected.js @@ -32,7 +32,7 @@ function create_fragment(ctx) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, null, create_fragment, safe_not_equal, {}, noop); + init(this, options, null, create_fragment, safe_not_equal, {}); } } diff --git a/test/js/samples/video-bindings/expected.js b/test/js/samples/video-bindings/expected.js index 5199c7fa834c..09f3b4a75fe4 100644 --- a/test/js/samples/video-bindings/expected.js +++ b/test/js/samples/video-bindings/expected.js @@ -115,20 +115,12 @@ class Component extends SvelteComponent { constructor(options) { super(); - init( - this, - options, - instance, - create_fragment, - safe_not_equal, - { - currentTime: 0, - videoHeight: 1, - videoWidth: 2, - offsetWidth: 3 - }, - noop - ); + init(this, options, instance, create_fragment, safe_not_equal, { + currentTime: 0, + videoHeight: 1, + videoWidth: 2, + offsetWidth: 3 + }, noop); } } From ae4731772bad663916d3d9706e6e1ee766610458 Mon Sep 17 00:00:00 2001 From: Ivan Hofer Date: Thu, 12 Nov 2020 07:10:24 +0100 Subject: [PATCH 12/31] Revert "add 'noop' param to all tests" This reverts commit c0ac80fbda752d5f399dfec4ff714c3ce7565882. --- .../samples/action-custom-event-handler/expected.js | 4 ++-- test/js/samples/bind-online/expected.js | 2 +- test/js/samples/bind-open/expected.js | 2 +- test/js/samples/bind-width-height/expected.js | 2 +- test/js/samples/bindings-readonly-order/expected.js | 2 +- test/js/samples/capture-inject-dev-only/expected.js | 2 +- test/js/samples/capture-inject-state/expected.js | 2 +- .../collapses-text-around-comments/expected.js | 2 +- test/js/samples/component-static-array/expected.js | 2 +- test/js/samples/component-static-var/expected.js | 3 +-- test/js/samples/component-static/expected.js | 2 +- .../component-store-access-invalidate/expected.js | 2 +- .../component-store-reassign-invalidate/expected.js | 2 +- test/js/samples/data-attribute/expected.js | 2 +- test/js/samples/debug-empty/expected.js | 2 +- test/js/samples/debug-foo-bar-baz-things/expected.js | 2 +- test/js/samples/debug-foo/expected.js | 2 +- test/js/samples/debug-hoisted/expected.js | 2 +- test/js/samples/debug-no-dependencies/expected.js | 2 +- test/js/samples/deconflict-builtins/expected.js | 2 +- .../dev-warning-missing-data-computed/expected.js | 2 +- test/js/samples/each-block-array-literal/expected.js | 2 +- test/js/samples/each-block-changed-check/expected.js | 2 +- .../js/samples/each-block-keyed-animated/expected.js | 2 +- test/js/samples/each-block-keyed/expected.js | 2 +- test/js/samples/event-handler-dynamic/expected.js | 2 +- test/js/samples/if-block-complex/expected.js | 2 +- test/js/samples/if-block-no-update/expected.js | 2 +- test/js/samples/if-block-simple/expected.js | 4 ++-- test/js/samples/import-meta/expected.js | 2 +- test/js/samples/initial-context/expected.js | 2 +- .../inline-style-optimized-multiple/expected.js | 2 +- .../samples/inline-style-optimized-url/expected.js | 2 +- test/js/samples/inline-style-optimized/expected.js | 2 +- test/js/samples/input-files/expected.js | 2 +- test/js/samples/input-range/expected.js | 2 +- test/js/samples/input-value/expected.js | 2 +- .../samples/input-without-blowback-guard/expected.js | 2 +- .../instrumentation-script-if-no-block/expected.js | 2 +- .../instrumentation-script-main-block/expected.js | 2 +- .../instrumentation-script-x-equals-x/expected.js | 2 +- .../instrumentation-template-if-no-block/expected.js | 2 +- .../instrumentation-template-x-equals-x/expected.js | 2 +- test/js/samples/loop-protect/expected.js | 2 +- test/js/samples/media-bindings/expected.js | 2 +- test/js/samples/optional-chaining/expected.js | 3 +-- test/js/samples/select-dynamic-value/expected.js | 2 +- test/js/samples/src-attribute-check/expected.js | 2 +- test/js/samples/title/expected.js | 2 +- test/js/samples/transition-local/expected.js | 4 ++-- .../js/samples/transition-repeated-outro/expected.js | 3 +-- test/js/samples/unchanged-expression/expected.js | 2 +- .../unreferenced-state-not-invalidated/expected.js | 2 +- test/js/samples/use-elements-as-anchors/expected.js | 12 ++++++------ test/js/samples/video-bindings/expected.js | 2 +- test/js/samples/window-binding-online/expected.js | 2 +- test/js/samples/window-binding-scroll/expected.js | 2 +- 57 files changed, 65 insertions(+), 68 deletions(-) diff --git a/test/js/samples/action-custom-event-handler/expected.js b/test/js/samples/action-custom-event-handler/expected.js index c5c2ea454de3..51656290d668 100644 --- a/test/js/samples/action-custom-event-handler/expected.js +++ b/test/js/samples/action-custom-event-handler/expected.js @@ -48,7 +48,7 @@ function handleFoo(bar) { } function foo(node, callback) { - + } // code goes here function instance($$self, $$props, $$invalidate) { @@ -65,7 +65,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { bar: 0 }, noop); + init(this, options, instance, create_fragment, safe_not_equal, { bar: 0 }); } } diff --git a/test/js/samples/bind-online/expected.js b/test/js/samples/bind-online/expected.js index 1b9fd41bc627..887195bce1b3 100644 --- a/test/js/samples/bind-online/expected.js +++ b/test/js/samples/bind-online/expected.js @@ -49,7 +49,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}, noop); + init(this, options, instance, create_fragment, safe_not_equal, {}); } } diff --git a/test/js/samples/bind-open/expected.js b/test/js/samples/bind-open/expected.js index 5ff4dc1ad133..56ff30284572 100644 --- a/test/js/samples/bind-open/expected.js +++ b/test/js/samples/bind-open/expected.js @@ -62,7 +62,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { open: 0 }, noop); + init(this, options, instance, create_fragment, safe_not_equal, { open: 0 }); } } diff --git a/test/js/samples/bind-width-height/expected.js b/test/js/samples/bind-width-height/expected.js index c583acf64158..f23c20b68316 100644 --- a/test/js/samples/bind-width-height/expected.js +++ b/test/js/samples/bind-width-height/expected.js @@ -57,7 +57,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { w: 0, h: 1 }, noop); + init(this, options, instance, create_fragment, safe_not_equal, { w: 0, h: 1 }); } } diff --git a/test/js/samples/bindings-readonly-order/expected.js b/test/js/samples/bindings-readonly-order/expected.js index 063f2b28d4a3..78a71dcd8414 100644 --- a/test/js/samples/bindings-readonly-order/expected.js +++ b/test/js/samples/bindings-readonly-order/expected.js @@ -78,7 +78,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { files: 0 }, noop); + init(this, options, instance, create_fragment, safe_not_equal, { files: 0 }); } } diff --git a/test/js/samples/capture-inject-dev-only/expected.js b/test/js/samples/capture-inject-dev-only/expected.js index e3fc6f9b7c23..a87693dd9e8e 100644 --- a/test/js/samples/capture-inject-dev-only/expected.js +++ b/test/js/samples/capture-inject-dev-only/expected.js @@ -75,7 +75,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}, noop); + init(this, options, instance, create_fragment, safe_not_equal, {}); } } diff --git a/test/js/samples/capture-inject-state/expected.js b/test/js/samples/capture-inject-state/expected.js index b5ce98de7050..6a0351ae449e 100644 --- a/test/js/samples/capture-inject-state/expected.js +++ b/test/js/samples/capture-inject-state/expected.js @@ -158,7 +158,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponentDev { constructor(options) { super(options); - init(this, options, instance, create_fragment, safe_not_equal, { prop: 0, alias: 1 }, noop); + init(this, options, instance, create_fragment, safe_not_equal, { prop: 0, alias: 1 }); dispatch_dev("SvelteRegisterComponent", { component: this, diff --git a/test/js/samples/collapses-text-around-comments/expected.js b/test/js/samples/collapses-text-around-comments/expected.js index 41a574eba5e5..67335ce2469e 100644 --- a/test/js/samples/collapses-text-around-comments/expected.js +++ b/test/js/samples/collapses-text-around-comments/expected.js @@ -59,7 +59,7 @@ class Component extends SvelteComponent { constructor(options) { super(); if (!document.getElementById("svelte-1a7i8ec-style")) add_css(); - init(this, options, instance, create_fragment, safe_not_equal, { foo: 0 }, noop); + init(this, options, instance, create_fragment, safe_not_equal, { foo: 0 }); } } diff --git a/test/js/samples/component-static-array/expected.js b/test/js/samples/component-static-array/expected.js index d3a28d36b36e..0ecb0f32ba08 100644 --- a/test/js/samples/component-static-array/expected.js +++ b/test/js/samples/component-static-array/expected.js @@ -48,7 +48,7 @@ function instance($$self) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}, noop); + init(this, options, instance, create_fragment, safe_not_equal, {}); } } diff --git a/test/js/samples/component-static-var/expected.js b/test/js/samples/component-static-var/expected.js index c129f252caa7..2cd5ed386f07 100644 --- a/test/js/samples/component-static-var/expected.js +++ b/test/js/samples/component-static-var/expected.js @@ -9,7 +9,6 @@ import { insert, listen, mount_component, - noop, safe_not_equal, set_input_value, space, @@ -102,7 +101,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}, noop); + init(this, options, instance, create_fragment, safe_not_equal, {}); } } diff --git a/test/js/samples/component-static/expected.js b/test/js/samples/component-static/expected.js index dd0a1da29462..186f6350e6bd 100644 --- a/test/js/samples/component-static/expected.js +++ b/test/js/samples/component-static/expected.js @@ -48,7 +48,7 @@ function instance($$self) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}, noop); + init(this, options, instance, create_fragment, safe_not_equal, {}); } } diff --git a/test/js/samples/component-store-access-invalidate/expected.js b/test/js/samples/component-store-access-invalidate/expected.js index 790b8b1a5e7d..4c7bfd7009c3 100644 --- a/test/js/samples/component-store-access-invalidate/expected.js +++ b/test/js/samples/component-store-access-invalidate/expected.js @@ -49,7 +49,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}, noop); + init(this, options, instance, create_fragment, safe_not_equal, {}); } } diff --git a/test/js/samples/component-store-reassign-invalidate/expected.js b/test/js/samples/component-store-reassign-invalidate/expected.js index 31c92c66f7bc..0cf555bf0d96 100644 --- a/test/js/samples/component-store-reassign-invalidate/expected.js +++ b/test/js/samples/component-store-reassign-invalidate/expected.js @@ -74,7 +74,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}, noop); + init(this, options, instance, create_fragment, safe_not_equal, {}); } } diff --git a/test/js/samples/data-attribute/expected.js b/test/js/samples/data-attribute/expected.js index 5f80efc52f33..8c30e6f6dbb5 100644 --- a/test/js/samples/data-attribute/expected.js +++ b/test/js/samples/data-attribute/expected.js @@ -57,7 +57,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { bar: 0 }, noop); + init(this, options, instance, create_fragment, safe_not_equal, { bar: 0 }); } } diff --git a/test/js/samples/debug-empty/expected.js b/test/js/samples/debug-empty/expected.js index 1142b90e4409..f427f1bf4581 100644 --- a/test/js/samples/debug-empty/expected.js +++ b/test/js/samples/debug-empty/expected.js @@ -98,7 +98,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponentDev { constructor(options) { super(options); - init(this, options, instance, create_fragment, safe_not_equal, { name: 0 }, noop); + init(this, options, instance, create_fragment, safe_not_equal, { name: 0 }); dispatch_dev("SvelteRegisterComponent", { component: this, diff --git a/test/js/samples/debug-foo-bar-baz-things/expected.js b/test/js/samples/debug-foo-bar-baz-things/expected.js index e0c87cc33f1f..7439b3310b3a 100644 --- a/test/js/samples/debug-foo-bar-baz-things/expected.js +++ b/test/js/samples/debug-foo-bar-baz-things/expected.js @@ -208,7 +208,7 @@ 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: 1, bar: 2, baz: 3 }, noop); + init(this, options, instance, create_fragment, safe_not_equal, { things: 0, foo: 1, bar: 2, baz: 3 }); dispatch_dev("SvelteRegisterComponent", { component: this, diff --git a/test/js/samples/debug-foo/expected.js b/test/js/samples/debug-foo/expected.js index 540c423a5d68..d869a5cf9e84 100644 --- a/test/js/samples/debug-foo/expected.js +++ b/test/js/samples/debug-foo/expected.js @@ -196,7 +196,7 @@ 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: 1 }, noop); + init(this, options, instance, create_fragment, safe_not_equal, { things: 0, foo: 1 }); dispatch_dev("SvelteRegisterComponent", { component: this, diff --git a/test/js/samples/debug-hoisted/expected.js b/test/js/samples/debug-hoisted/expected.js index ba575f49aa8d..c6257ac90d5a 100644 --- a/test/js/samples/debug-hoisted/expected.js +++ b/test/js/samples/debug-hoisted/expected.js @@ -76,7 +76,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponentDev { constructor(options) { super(options); - init(this, options, instance, create_fragment, safe_not_equal, {}, noop); + init(this, options, instance, create_fragment, safe_not_equal, {}); dispatch_dev("SvelteRegisterComponent", { component: this, diff --git a/test/js/samples/debug-no-dependencies/expected.js b/test/js/samples/debug-no-dependencies/expected.js index d74c540948a6..4d8d05d3aa6e 100644 --- a/test/js/samples/debug-no-dependencies/expected.js +++ b/test/js/samples/debug-no-dependencies/expected.js @@ -150,7 +150,7 @@ function instance($$self, $$props) { class Component extends SvelteComponentDev { constructor(options) { super(options); - init(this, options, instance, create_fragment, safe_not_equal, {}, noop); + init(this, options, instance, create_fragment, safe_not_equal, {}); dispatch_dev("SvelteRegisterComponent", { component: this, diff --git a/test/js/samples/deconflict-builtins/expected.js b/test/js/samples/deconflict-builtins/expected.js index f4180b971229..6bc60194aaa5 100644 --- a/test/js/samples/deconflict-builtins/expected.js +++ b/test/js/samples/deconflict-builtins/expected.js @@ -114,7 +114,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { createElement: 0 }, noop); + init(this, options, instance, create_fragment, safe_not_equal, { createElement: 0 }); } } diff --git a/test/js/samples/dev-warning-missing-data-computed/expected.js b/test/js/samples/dev-warning-missing-data-computed/expected.js index b5419d19bde2..8c7f8bb1cff8 100644 --- a/test/js/samples/dev-warning-missing-data-computed/expected.js +++ b/test/js/samples/dev-warning-missing-data-computed/expected.js @@ -102,7 +102,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponentDev { constructor(options) { super(options); - init(this, options, instance, create_fragment, safe_not_equal, { foo: 0 }, noop); + init(this, options, instance, create_fragment, safe_not_equal, { foo: 0 }); dispatch_dev("SvelteRegisterComponent", { component: this, diff --git a/test/js/samples/each-block-array-literal/expected.js b/test/js/samples/each-block-array-literal/expected.js index b497887f7862..fe51ac5bc3aa 100644 --- a/test/js/samples/each-block-array-literal/expected.js +++ b/test/js/samples/each-block-array-literal/expected.js @@ -120,7 +120,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { a: 0, b: 1, c: 2, d: 3, e: 4 }, noop); + init(this, options, instance, create_fragment, safe_not_equal, { a: 0, b: 1, c: 2, d: 3, e: 4 }); } } diff --git a/test/js/samples/each-block-changed-check/expected.js b/test/js/samples/each-block-changed-check/expected.js index 40f6cdfe32b8..63bc1d8607b8 100644 --- a/test/js/samples/each-block-changed-check/expected.js +++ b/test/js/samples/each-block-changed-check/expected.js @@ -165,7 +165,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { comments: 0, elapsed: 1, time: 2, foo: 3 }, noop); + init(this, options, instance, create_fragment, safe_not_equal, { comments: 0, elapsed: 1, time: 2, foo: 3 }); } } diff --git a/test/js/samples/each-block-keyed-animated/expected.js b/test/js/samples/each-block-keyed-animated/expected.js index 5cc2b196e928..46ef63ee7f17 100644 --- a/test/js/samples/each-block-keyed-animated/expected.js +++ b/test/js/samples/each-block-keyed-animated/expected.js @@ -138,7 +138,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { things: 0 }, noop); + init(this, options, instance, create_fragment, safe_not_equal, { things: 0 }); } } diff --git a/test/js/samples/each-block-keyed/expected.js b/test/js/samples/each-block-keyed/expected.js index f6897a1cd6fb..71853cf295ef 100644 --- a/test/js/samples/each-block-keyed/expected.js +++ b/test/js/samples/each-block-keyed/expected.js @@ -107,7 +107,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { things: 0 }, noop); + init(this, options, instance, create_fragment, safe_not_equal, { things: 0 }); } } diff --git a/test/js/samples/event-handler-dynamic/expected.js b/test/js/samples/event-handler-dynamic/expected.js index 9e4e78cca007..dacdfe15ac37 100644 --- a/test/js/samples/event-handler-dynamic/expected.js +++ b/test/js/samples/event-handler-dynamic/expected.js @@ -103,7 +103,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}, noop); + init(this, options, instance, create_fragment, safe_not_equal, {}); } } diff --git a/test/js/samples/if-block-complex/expected.js b/test/js/samples/if-block-complex/expected.js index 2cc568f1ddca..a8244de8b02d 100644 --- a/test/js/samples/if-block-complex/expected.js +++ b/test/js/samples/if-block-complex/expected.js @@ -60,7 +60,7 @@ function instance($$self) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}, noop); + init(this, options, instance, create_fragment, safe_not_equal, {}); } } diff --git a/test/js/samples/if-block-no-update/expected.js b/test/js/samples/if-block-no-update/expected.js index b35a805f6a54..c67b33fa8557 100644 --- a/test/js/samples/if-block-no-update/expected.js +++ b/test/js/samples/if-block-no-update/expected.js @@ -98,7 +98,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { foo: 0 }, noop); + init(this, options, instance, create_fragment, safe_not_equal, { foo: 0 }); } } diff --git a/test/js/samples/if-block-simple/expected.js b/test/js/samples/if-block-simple/expected.js index abc3a31a959a..4cdd73cddbc1 100644 --- a/test/js/samples/if-block-simple/expected.js +++ b/test/js/samples/if-block-simple/expected.js @@ -43,7 +43,7 @@ function create_fragment(ctx) { p(ctx, [dirty]) { if (/*foo*/ ctx[0]) { if (if_block) { - + } else { if_block = create_if_block(ctx); if_block.c(); @@ -76,7 +76,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { foo: 0 }, noop); + init(this, options, instance, create_fragment, safe_not_equal, { foo: 0 }); } } diff --git a/test/js/samples/import-meta/expected.js b/test/js/samples/import-meta/expected.js index f3b90c0b2d6c..ba77398321cf 100644 --- a/test/js/samples/import-meta/expected.js +++ b/test/js/samples/import-meta/expected.js @@ -46,7 +46,7 @@ function instance($$self) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}, noop); + init(this, options, instance, create_fragment, safe_not_equal, {}); } } diff --git a/test/js/samples/initial-context/expected.js b/test/js/samples/initial-context/expected.js index e9b5892ef64c..592e2a709e9c 100644 --- a/test/js/samples/initial-context/expected.js +++ b/test/js/samples/initial-context/expected.js @@ -52,7 +52,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}, noop); + init(this, options, instance, create_fragment, safe_not_equal, {}); } } diff --git a/test/js/samples/inline-style-optimized-multiple/expected.js b/test/js/samples/inline-style-optimized-multiple/expected.js index 29818b3dccd0..0a9d0a1e8eba 100644 --- a/test/js/samples/inline-style-optimized-multiple/expected.js +++ b/test/js/samples/inline-style-optimized-multiple/expected.js @@ -56,7 +56,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { color: 0, x: 1, y: 2 }, noop); + init(this, options, instance, create_fragment, safe_not_equal, { color: 0, x: 1, y: 2 }); } } diff --git a/test/js/samples/inline-style-optimized-url/expected.js b/test/js/samples/inline-style-optimized-url/expected.js index 7ac128ed3b61..0debb035854f 100644 --- a/test/js/samples/inline-style-optimized-url/expected.js +++ b/test/js/samples/inline-style-optimized-url/expected.js @@ -47,7 +47,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { data: 0 }, noop); + init(this, options, instance, create_fragment, safe_not_equal, { data: 0 }); } } diff --git a/test/js/samples/inline-style-optimized/expected.js b/test/js/samples/inline-style-optimized/expected.js index 79fb9f1f875a..b7db0f1cf30b 100644 --- a/test/js/samples/inline-style-optimized/expected.js +++ b/test/js/samples/inline-style-optimized/expected.js @@ -47,7 +47,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { color: 0 }, noop); + init(this, options, instance, create_fragment, safe_not_equal, { color: 0 }); } } diff --git a/test/js/samples/input-files/expected.js b/test/js/samples/input-files/expected.js index d35feefa943d..8adc7443f5c1 100644 --- a/test/js/samples/input-files/expected.js +++ b/test/js/samples/input-files/expected.js @@ -59,7 +59,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { files: 0 }, noop); + init(this, options, instance, create_fragment, safe_not_equal, { files: 0 }); } } diff --git a/test/js/samples/input-range/expected.js b/test/js/samples/input-range/expected.js index 7e985d77e3db..a855ca3653fe 100644 --- a/test/js/samples/input-range/expected.js +++ b/test/js/samples/input-range/expected.js @@ -70,7 +70,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { value: 0 }, noop); + init(this, options, instance, create_fragment, safe_not_equal, { value: 0 }); } } diff --git a/test/js/samples/input-value/expected.js b/test/js/samples/input-value/expected.js index 6de379e63114..781a2ae60358 100644 --- a/test/js/samples/input-value/expected.js +++ b/test/js/samples/input-value/expected.js @@ -76,7 +76,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}, noop); + init(this, options, instance, create_fragment, safe_not_equal, {}); } } diff --git a/test/js/samples/input-without-blowback-guard/expected.js b/test/js/samples/input-without-blowback-guard/expected.js index 98f3bf79498d..6c5b2156232f 100644 --- a/test/js/samples/input-without-blowback-guard/expected.js +++ b/test/js/samples/input-without-blowback-guard/expected.js @@ -63,7 +63,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { foo: 0 }, noop); + init(this, options, instance, create_fragment, safe_not_equal, { foo: 0 }); } } diff --git a/test/js/samples/instrumentation-script-if-no-block/expected.js b/test/js/samples/instrumentation-script-if-no-block/expected.js index 11dde75a7937..7f51c6455007 100644 --- a/test/js/samples/instrumentation-script-if-no-block/expected.js +++ b/test/js/samples/instrumentation-script-if-no-block/expected.js @@ -72,7 +72,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}, noop); + init(this, options, instance, create_fragment, safe_not_equal, {}); } } diff --git a/test/js/samples/instrumentation-script-main-block/expected.js b/test/js/samples/instrumentation-script-main-block/expected.js index 19bf4f0f0bd4..bc809246028b 100644 --- a/test/js/samples/instrumentation-script-main-block/expected.js +++ b/test/js/samples/instrumentation-script-main-block/expected.js @@ -68,7 +68,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}, noop); + init(this, options, instance, create_fragment, safe_not_equal, {}); } } diff --git a/test/js/samples/instrumentation-script-x-equals-x/expected.js b/test/js/samples/instrumentation-script-x-equals-x/expected.js index a6db9a42f523..ea0d65acb906 100644 --- a/test/js/samples/instrumentation-script-x-equals-x/expected.js +++ b/test/js/samples/instrumentation-script-x-equals-x/expected.js @@ -74,7 +74,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}, noop); + init(this, options, instance, create_fragment, safe_not_equal, {}); } } diff --git a/test/js/samples/instrumentation-template-if-no-block/expected.js b/test/js/samples/instrumentation-template-if-no-block/expected.js index acc277f41992..0c2713a9cc64 100644 --- a/test/js/samples/instrumentation-template-if-no-block/expected.js +++ b/test/js/samples/instrumentation-template-if-no-block/expected.js @@ -72,7 +72,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}, noop); + init(this, options, instance, create_fragment, safe_not_equal, {}); } } diff --git a/test/js/samples/instrumentation-template-x-equals-x/expected.js b/test/js/samples/instrumentation-template-x-equals-x/expected.js index 5a1b436ddeba..55cd310661e7 100644 --- a/test/js/samples/instrumentation-template-x-equals-x/expected.js +++ b/test/js/samples/instrumentation-template-x-equals-x/expected.js @@ -74,7 +74,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}, noop); + init(this, options, instance, create_fragment, safe_not_equal, {}); } } diff --git a/test/js/samples/loop-protect/expected.js b/test/js/samples/loop-protect/expected.js index df6bcd25f93e..1042b20823b8 100644 --- a/test/js/samples/loop-protect/expected.js +++ b/test/js/samples/loop-protect/expected.js @@ -154,7 +154,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponentDev { constructor(options) { super(options); - init(this, options, instance, create_fragment, safe_not_equal, {}, noop); + init(this, options, instance, create_fragment, safe_not_equal, {}); dispatch_dev("SvelteRegisterComponent", { component: this, diff --git a/test/js/samples/media-bindings/expected.js b/test/js/samples/media-bindings/expected.js index 9ee63938fa08..867d4a7dadfb 100644 --- a/test/js/samples/media-bindings/expected.js +++ b/test/js/samples/media-bindings/expected.js @@ -227,7 +227,7 @@ class Component extends SvelteComponent { playbackRate: 8, seeking: 9, ended: 10 - }, noop); + }); } } diff --git a/test/js/samples/optional-chaining/expected.js b/test/js/samples/optional-chaining/expected.js index e39ad17a7daa..8aa94796c1b0 100644 --- a/test/js/samples/optional-chaining/expected.js +++ b/test/js/samples/optional-chaining/expected.js @@ -9,7 +9,6 @@ import { init, insert, mount_component, - noop, safe_not_equal, set_data, space, @@ -183,7 +182,7 @@ function instance($$self, $$props, $$invalidate) { class Component_1 extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { a: 0, b: 1, c: 2, d: 3, e: 4, f: 5 }, noop); + init(this, options, instance, create_fragment, safe_not_equal, { a: 0, b: 1, c: 2, d: 3, e: 4, f: 5 }); } } diff --git a/test/js/samples/select-dynamic-value/expected.js b/test/js/samples/select-dynamic-value/expected.js index ddc5c63d7781..8777cd260072 100644 --- a/test/js/samples/select-dynamic-value/expected.js +++ b/test/js/samples/select-dynamic-value/expected.js @@ -60,7 +60,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { current: 0 }, noop); + init(this, options, instance, create_fragment, safe_not_equal, { current: 0 }); } } diff --git a/test/js/samples/src-attribute-check/expected.js b/test/js/samples/src-attribute-check/expected.js index f478b53124d8..93638edfb43b 100644 --- a/test/js/samples/src-attribute-check/expected.js +++ b/test/js/samples/src-attribute-check/expected.js @@ -78,7 +78,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { url: 0, slug: 1 }, noop); + init(this, options, instance, create_fragment, safe_not_equal, { url: 0, slug: 1 }); } } diff --git a/test/js/samples/title/expected.js b/test/js/samples/title/expected.js index 834ee9eb040e..b10f569759d4 100644 --- a/test/js/samples/title/expected.js +++ b/test/js/samples/title/expected.js @@ -32,7 +32,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { custom: 0 }, noop); + init(this, options, instance, create_fragment, safe_not_equal, { custom: 0 }); } } diff --git a/test/js/samples/transition-local/expected.js b/test/js/samples/transition-local/expected.js index 83623be737f6..ea3d9db3d7e6 100644 --- a/test/js/samples/transition-local/expected.js +++ b/test/js/samples/transition-local/expected.js @@ -117,7 +117,7 @@ function create_fragment(ctx) { } function foo() { - + } function instance($$self, $$props, $$invalidate) { @@ -135,7 +135,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { x: 0, y: 1 }, noop); + init(this, options, instance, create_fragment, safe_not_equal, { x: 0, y: 1 }); } } diff --git a/test/js/samples/transition-repeated-outro/expected.js b/test/js/samples/transition-repeated-outro/expected.js index 6e4126d2db50..12483ab91af7 100644 --- a/test/js/samples/transition-repeated-outro/expected.js +++ b/test/js/samples/transition-repeated-outro/expected.js @@ -9,7 +9,6 @@ import { group_outros, init, insert, - noop, safe_not_equal, transition_in, transition_out @@ -113,7 +112,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { num: 0 }, noop); + init(this, options, instance, create_fragment, safe_not_equal, { num: 0 }); } } diff --git a/test/js/samples/unchanged-expression/expected.js b/test/js/samples/unchanged-expression/expected.js index d50c7172787a..673d5b6abc8d 100644 --- a/test/js/samples/unchanged-expression/expected.js +++ b/test/js/samples/unchanged-expression/expected.js @@ -85,7 +85,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}, noop); + init(this, options, instance, create_fragment, safe_not_equal, {}); } } diff --git a/test/js/samples/unreferenced-state-not-invalidated/expected.js b/test/js/samples/unreferenced-state-not-invalidated/expected.js index 15182df8c3dc..b10ea815b966 100644 --- a/test/js/samples/unreferenced-state-not-invalidated/expected.js +++ b/test/js/samples/unreferenced-state-not-invalidated/expected.js @@ -70,7 +70,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}, noop); + init(this, options, instance, create_fragment, safe_not_equal, {}); } } diff --git a/test/js/samples/use-elements-as-anchors/expected.js b/test/js/samples/use-elements-as-anchors/expected.js index 3ac9717a9160..d07411518e91 100644 --- a/test/js/samples/use-elements-as-anchors/expected.js +++ b/test/js/samples/use-elements-as-anchors/expected.js @@ -158,7 +158,7 @@ function create_fragment(ctx) { p(ctx, [dirty]) { if (/*a*/ ctx[0]) { if (if_block0) { - + } else { if_block0 = create_if_block_4(ctx); if_block0.c(); @@ -171,7 +171,7 @@ function create_fragment(ctx) { if (/*b*/ ctx[1]) { if (if_block1) { - + } else { if_block1 = create_if_block_3(ctx); if_block1.c(); @@ -184,7 +184,7 @@ function create_fragment(ctx) { if (/*c*/ ctx[2]) { if (if_block2) { - + } else { if_block2 = create_if_block_2(ctx); if_block2.c(); @@ -197,7 +197,7 @@ function create_fragment(ctx) { if (/*d*/ ctx[3]) { if (if_block3) { - + } else { if_block3 = create_if_block_1(ctx); if_block3.c(); @@ -210,7 +210,7 @@ function create_fragment(ctx) { if (/*e*/ ctx[4]) { if (if_block4) { - + } else { if_block4 = create_if_block(ctx); if_block4.c(); @@ -257,7 +257,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { a: 0, b: 1, c: 2, d: 3, e: 4 }, noop); + init(this, options, instance, create_fragment, safe_not_equal, { a: 0, b: 1, c: 2, d: 3, e: 4 }); } } diff --git a/test/js/samples/video-bindings/expected.js b/test/js/samples/video-bindings/expected.js index 09f3b4a75fe4..8afa670bbb52 100644 --- a/test/js/samples/video-bindings/expected.js +++ b/test/js/samples/video-bindings/expected.js @@ -120,7 +120,7 @@ class Component extends SvelteComponent { videoHeight: 1, videoWidth: 2, offsetWidth: 3 - }, noop); + }); } } diff --git a/test/js/samples/window-binding-online/expected.js b/test/js/samples/window-binding-online/expected.js index 1b9fd41bc627..887195bce1b3 100644 --- a/test/js/samples/window-binding-online/expected.js +++ b/test/js/samples/window-binding-online/expected.js @@ -49,7 +49,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, {}, noop); + init(this, options, instance, create_fragment, safe_not_equal, {}); } } diff --git a/test/js/samples/window-binding-scroll/expected.js b/test/js/samples/window-binding-scroll/expected.js index c170d67102bc..09a4d3737d29 100644 --- a/test/js/samples/window-binding-scroll/expected.js +++ b/test/js/samples/window-binding-scroll/expected.js @@ -88,7 +88,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - init(this, options, instance, create_fragment, safe_not_equal, { y: 0 }, noop); + init(this, options, instance, create_fragment, safe_not_equal, { y: 0 }); } } From f5f56ce992d4df70ea518cc038ef0c17d324325d Mon Sep 17 00:00:00 2001 From: Ivan Hofer Date: Thu, 12 Nov 2020 07:17:07 +0100 Subject: [PATCH 13/31] pass correct add_css method --- src/compiler/compile/render_dom/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/compile/render_dom/index.ts b/src/compiler/compile/render_dom/index.ts index 61af64e92f79..0f90132768e3 100644 --- a/src/compiler/compile/render_dom/index.ts +++ b/src/compiler/compile/render_dom/index.ts @@ -529,7 +529,7 @@ export default function dom( constructor(options) { super(${options.dev && 'options'}); - ${should_add_css && b`@addCssToComponent(this, add_css, options);`} + ${should_add_css && b`@addCssToComponent(this, ${add_css}, options);`} @init(this, options, ${definition}, ${has_create_fragment ? 'create_fragment' : 'null'}, ${not_equal}, ${prop_indexes}, ${dirty}); ${options.dev && b`@dispatch_dev("SvelteRegisterComponent", { component: this, tagName: "${name.name}", options, id: create_fragment.name });`} From 9a4cf3c3f85b804a4fed0722e643a06cb78b7e78 Mon Sep 17 00:00:00 2001 From: Ivan Hofer Date: Thu, 12 Nov 2020 07:26:27 +0100 Subject: [PATCH 14/31] remove noop from from customElement init --- src/compiler/compile/render_dom/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/compile/render_dom/index.ts b/src/compiler/compile/render_dom/index.ts index 0f90132768e3..4db7a6815acb 100644 --- a/src/compiler/compile/render_dom/index.ts +++ b/src/compiler/compile/render_dom/index.ts @@ -477,7 +477,7 @@ export default function dom( ${css.code && b`this.shadowRoot.innerHTML = \`\`;`} - @init(this, { target: this.shadowRoot, props: ${init_props} }, ${definition}, ${has_create_fragment ? 'create_fragment': 'null'}, ${not_equal}, ${prop_indexes}, ${x`@noop`}, ${dirty}); + @init(this, { target: this.shadowRoot, props: ${init_props} }, ${definition}, ${has_create_fragment ? 'create_fragment': 'null'}, ${not_equal}, ${prop_indexes}, ${dirty}); ${dev_props_check} From 83d5fe8256870f2f6b4fbc3daf78ce1b0ba36b6b Mon Sep 17 00:00:00 2001 From: Ivan Hofer Date: Thu, 12 Nov 2020 07:32:45 +0100 Subject: [PATCH 15/31] fix tests using new add_css methods --- .../collapses-text-around-comments/expected.js | 11 +++++------ test/js/samples/css-media-query/expected.js | 12 +++++------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/test/js/samples/collapses-text-around-comments/expected.js b/test/js/samples/collapses-text-around-comments/expected.js index 67335ce2469e..e4c120b638d9 100644 --- a/test/js/samples/collapses-text-around-comments/expected.js +++ b/test/js/samples/collapses-text-around-comments/expected.js @@ -1,7 +1,9 @@ /* generated by Svelte vX.Y.Z */ import { SvelteComponent, + addCssToComponent, append, + appendStyleIfNotPresent, attr, detach, element, @@ -13,11 +15,8 @@ import { text } from "svelte/internal"; -function add_css() { - var style = element("style"); - style.id = "svelte-1a7i8ec-style"; - style.textContent = "p.svelte-1a7i8ec{color:red}"; - append(document.head, style); +function add_css(customStyleTag) { + appendStyleIfNotPresent(customStyleTag || document.head, "svelte-1a7i8ec-style", "p.svelte-1a7i8ec{color:red}"); } function create_fragment(ctx) { @@ -58,7 +57,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - if (!document.getElementById("svelte-1a7i8ec-style")) add_css(); + addCssToComponent(this, add_css, options); init(this, options, instance, create_fragment, safe_not_equal, { foo: 0 }); } } diff --git a/test/js/samples/css-media-query/expected.js b/test/js/samples/css-media-query/expected.js index f4776700599d..b8e1531bf133 100644 --- a/test/js/samples/css-media-query/expected.js +++ b/test/js/samples/css-media-query/expected.js @@ -1,7 +1,8 @@ /* generated by Svelte vX.Y.Z */ import { SvelteComponent, - append, + addCssToComponent, + appendStyleIfNotPresent, attr, detach, element, @@ -11,11 +12,8 @@ import { safe_not_equal } from "svelte/internal"; -function add_css() { - var style = element("style"); - style.id = "svelte-1slhpfn-style"; - style.textContent = "@media(min-width: 1px){div.svelte-1slhpfn{color:red}}"; - append(document.head, style); +function add_css(customStyleTag) { + appendStyleIfNotPresent(customStyleTag || document.head, "svelte-1slhpfn-style", "@media(min-width: 1px){div.svelte-1slhpfn{color:red}}"); } function create_fragment(ctx) { @@ -41,7 +39,7 @@ function create_fragment(ctx) { class Component extends SvelteComponent { constructor(options) { super(); - if (!document.getElementById("svelte-1slhpfn-style")) add_css(); + addCssToComponent(this, add_css, options); init(this, options, null, create_fragment, safe_not_equal, {}); } } From bf87612acf35a9986b0351b955f3fad83f223efa Mon Sep 17 00:00:00 2001 From: Ivan Hofer Date: Thu, 12 Nov 2020 07:58:49 +0100 Subject: [PATCH 16/31] Revert "init $$ in component with empty object value" This reverts commit c154895a7754ba51d263555e72eab452c2a585f4. --- src/runtime/internal/Component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime/internal/Component.ts b/src/runtime/internal/Component.ts index f020b78e8a85..763974adfb4e 100644 --- a/src/runtime/internal/Component.ts +++ b/src/runtime/internal/Component.ts @@ -224,7 +224,7 @@ if (typeof HTMLElement === 'function') { } export class SvelteComponent { - $$: T$$ = {} as T$$; + $$: T$$; $$set?: ($$props: any) => void; $destroy() { From b80990daaf4894140919fd8174c8110a4a442a90 Mon Sep 17 00:00:00 2001 From: Ivan Hofer Date: Sat, 14 Nov 2020 17:48:00 +0100 Subject: [PATCH 17/31] rename 'that' to 'component' --- src/runtime/internal/Component.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/runtime/internal/Component.ts b/src/runtime/internal/Component.ts index 763974adfb4e..8be0b7cb1937 100644 --- a/src/runtime/internal/Component.ts +++ b/src/runtime/internal/Component.ts @@ -98,11 +98,11 @@ function make_dirty(component, i) { } -export function addCssToComponent(that, add_css, options) { - that.$$ = { +export function addCssToComponent(component, add_css, options) { + component.$$ = { customStyleTag: options.customStyleTag || current_component && current_component.$$.customStyleTag }; - add_css(that.$$.customStyleTag); + add_css(component.$$.customStyleTag); } export function init(component, options, instance, create_fragment, not_equal, props, dirty = [-1]) { From 4f9a15eced22021b3b78b16eba1a750da742f48d Mon Sep 17 00:00:00 2001 From: Ivan Hofer Date: Sat, 14 Nov 2020 18:05:40 +0100 Subject: [PATCH 18/31] slightly improve output size by refactoring add_css method --- src/compiler/compile/render_dom/index.ts | 2 +- src/runtime/internal/dom.ts | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/compiler/compile/render_dom/index.ts b/src/compiler/compile/render_dom/index.ts index 4db7a6815acb..22eacde32b25 100644 --- a/src/compiler/compile/render_dom/index.ts +++ b/src/compiler/compile/render_dom/index.ts @@ -45,7 +45,7 @@ export default function dom( if (should_add_css) { body.push(b` function ${add_css}(customStyleTag) { - @appendStyleIfNotPresent(customStyleTag || @_document.head, "${component.stylesheet.id}-style", "${styles}"); + @appendStyleIfNotPresent(customStyleTag, "${component.stylesheet.id}", "${styles}"); } `); } diff --git a/src/runtime/internal/dom.ts b/src/runtime/internal/dom.ts index 94214eef0256..ed665427d03d 100644 --- a/src/runtime/internal/dom.ts +++ b/src/runtime/internal/dom.ts @@ -1,6 +1,10 @@ import { has_prop } from './utils'; -export function appendStyleIfNotPresent(target: Element, styleId: string, styles: string) { +export function appendStyleIfNotPresent( + target: Element = document.head, + styleSheetId: string, + styles: string, + styleId:string = styleSheetId + '-style') { if (!target.querySelector('#' + styleId)) { const style = element('style'); style.id = styleId; From b0cacd7f2566cee31fc6691435f6f8e366abb163 Mon Sep 17 00:00:00 2001 From: Ivan Hofer Date: Sat, 14 Nov 2020 18:20:23 +0100 Subject: [PATCH 19/31] slightly improve output size by refactoring add_css method --- src/compiler/compile/render_dom/index.ts | 2 +- src/runtime/internal/dom.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/compile/render_dom/index.ts b/src/compiler/compile/render_dom/index.ts index 22eacde32b25..050b23abc38d 100644 --- a/src/compiler/compile/render_dom/index.ts +++ b/src/compiler/compile/render_dom/index.ts @@ -45,7 +45,7 @@ export default function dom( if (should_add_css) { body.push(b` function ${add_css}(customStyleTag) { - @appendStyleIfNotPresent(customStyleTag, "${component.stylesheet.id}", "${styles}"); + @appendStyleIfNotPresent(customStyleTag, "${component.stylesheet.id.replace('svelte-', '')}", "${styles}"); } `); } diff --git a/src/runtime/internal/dom.ts b/src/runtime/internal/dom.ts index ed665427d03d..af35105b1118 100644 --- a/src/runtime/internal/dom.ts +++ b/src/runtime/internal/dom.ts @@ -4,7 +4,7 @@ export function appendStyleIfNotPresent( target: Element = document.head, styleSheetId: string, styles: string, - styleId:string = styleSheetId + '-style') { + styleId:string = `svelte-${styleSheetId}-style`) { if (!target.querySelector('#' + styleId)) { const style = element('style'); style.id = styleId; From 5c3038ccaed6f680cd6a012b793793c841cf9c92 Mon Sep 17 00:00:00 2001 From: Ivan Hofer Date: Sat, 14 Nov 2020 18:20:57 +0100 Subject: [PATCH 20/31] fix tests --- test/js/samples/collapses-text-around-comments/expected.js | 2 +- test/js/samples/css-media-query/expected.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/js/samples/collapses-text-around-comments/expected.js b/test/js/samples/collapses-text-around-comments/expected.js index e4c120b638d9..021baa10bee6 100644 --- a/test/js/samples/collapses-text-around-comments/expected.js +++ b/test/js/samples/collapses-text-around-comments/expected.js @@ -16,7 +16,7 @@ import { } from "svelte/internal"; function add_css(customStyleTag) { - appendStyleIfNotPresent(customStyleTag || document.head, "svelte-1a7i8ec-style", "p.svelte-1a7i8ec{color:red}"); + appendStyleIfNotPresent(customStyleTag, "1a7i8ec", "p.svelte-1a7i8ec{color:red}"); } function create_fragment(ctx) { diff --git a/test/js/samples/css-media-query/expected.js b/test/js/samples/css-media-query/expected.js index b8e1531bf133..36b88810b81c 100644 --- a/test/js/samples/css-media-query/expected.js +++ b/test/js/samples/css-media-query/expected.js @@ -13,7 +13,7 @@ import { } from "svelte/internal"; function add_css(customStyleTag) { - appendStyleIfNotPresent(customStyleTag || document.head, "svelte-1slhpfn-style", "@media(min-width: 1px){div.svelte-1slhpfn{color:red}}"); + appendStyleIfNotPresent(customStyleTag, "1slhpfn", "@media(min-width: 1px){div.svelte-1slhpfn{color:red}}"); } function create_fragment(ctx) { From 6d852658583b9b538b0a79e467c1f24b6c85b87e Mon Sep 17 00:00:00 2001 From: Ivan Hofer Date: Sat, 14 Nov 2020 18:45:24 +0100 Subject: [PATCH 21/31] move document.head to addCssToComponent method --- src/compiler/compile/render_dom/index.ts | 4 ++-- src/runtime/internal/Component.ts | 2 +- src/runtime/internal/dom.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compiler/compile/render_dom/index.ts b/src/compiler/compile/render_dom/index.ts index 050b23abc38d..a32db46078a4 100644 --- a/src/compiler/compile/render_dom/index.ts +++ b/src/compiler/compile/render_dom/index.ts @@ -44,8 +44,8 @@ export default function dom( if (should_add_css) { body.push(b` - function ${add_css}(customStyleTag) { - @appendStyleIfNotPresent(customStyleTag, "${component.stylesheet.id.replace('svelte-', '')}", "${styles}"); + function ${add_css}(target) { + @appendStyleIfNotPresent(target, "${component.stylesheet.id.replace('svelte-', '')}", "${styles}"); } `); } diff --git a/src/runtime/internal/Component.ts b/src/runtime/internal/Component.ts index 8be0b7cb1937..871d248969b1 100644 --- a/src/runtime/internal/Component.ts +++ b/src/runtime/internal/Component.ts @@ -102,7 +102,7 @@ export function addCssToComponent(component, add_css, options) { component.$$ = { customStyleTag: options.customStyleTag || current_component && current_component.$$.customStyleTag }; - add_css(component.$$.customStyleTag); + add_css(component.$$.customStyleTag || document.head); } export function init(component, options, instance, create_fragment, not_equal, props, dirty = [-1]) { diff --git a/src/runtime/internal/dom.ts b/src/runtime/internal/dom.ts index af35105b1118..08070c514a4b 100644 --- a/src/runtime/internal/dom.ts +++ b/src/runtime/internal/dom.ts @@ -1,7 +1,7 @@ import { has_prop } from './utils'; export function appendStyleIfNotPresent( - target: Element = document.head, + target: Element, styleSheetId: string, styles: string, styleId:string = `svelte-${styleSheetId}-style`) { From b6e9574805886786589d020086710de287fbd058 Mon Sep 17 00:00:00 2001 From: Ivan Hofer Date: Sat, 14 Nov 2020 18:47:02 +0100 Subject: [PATCH 22/31] use snake_case for method names --- src/compiler/compile/render_dom/index.ts | 4 ++-- src/runtime/internal/Component.ts | 2 +- src/runtime/internal/dom.ts | 2 +- .../samples/collapses-text-around-comments/expected.js | 10 +++++----- test/js/samples/css-media-query/expected.js | 10 +++++----- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/compiler/compile/render_dom/index.ts b/src/compiler/compile/render_dom/index.ts index a32db46078a4..6c0070e635cc 100644 --- a/src/compiler/compile/render_dom/index.ts +++ b/src/compiler/compile/render_dom/index.ts @@ -45,7 +45,7 @@ export default function dom( if (should_add_css) { body.push(b` function ${add_css}(target) { - @appendStyleIfNotPresent(target, "${component.stylesheet.id.replace('svelte-', '')}", "${styles}"); + @append_style_if_not_present(target, "${component.stylesheet.id.replace('svelte-', '')}", "${styles}"); } `); } @@ -529,7 +529,7 @@ export default function dom( constructor(options) { super(${options.dev && 'options'}); - ${should_add_css && b`@addCssToComponent(this, ${add_css}, options);`} + ${should_add_css && b`@add_css_to_component(this, ${add_css}, options);`} @init(this, options, ${definition}, ${has_create_fragment ? 'create_fragment' : 'null'}, ${not_equal}, ${prop_indexes}, ${dirty}); ${options.dev && b`@dispatch_dev("SvelteRegisterComponent", { component: this, tagName: "${name.name}", options, id: create_fragment.name });`} diff --git a/src/runtime/internal/Component.ts b/src/runtime/internal/Component.ts index 871d248969b1..52ab54fa8d84 100644 --- a/src/runtime/internal/Component.ts +++ b/src/runtime/internal/Component.ts @@ -98,7 +98,7 @@ function make_dirty(component, i) { } -export function addCssToComponent(component, add_css, options) { +export function add_css_to_component(component, add_css, options) { component.$$ = { customStyleTag: options.customStyleTag || current_component && current_component.$$.customStyleTag }; diff --git a/src/runtime/internal/dom.ts b/src/runtime/internal/dom.ts index 08070c514a4b..4d4da3f7bd52 100644 --- a/src/runtime/internal/dom.ts +++ b/src/runtime/internal/dom.ts @@ -1,6 +1,6 @@ import { has_prop } from './utils'; -export function appendStyleIfNotPresent( +export function append_style_if_not_present( target: Element, styleSheetId: string, styles: string, diff --git a/test/js/samples/collapses-text-around-comments/expected.js b/test/js/samples/collapses-text-around-comments/expected.js index 021baa10bee6..57b370d36870 100644 --- a/test/js/samples/collapses-text-around-comments/expected.js +++ b/test/js/samples/collapses-text-around-comments/expected.js @@ -1,9 +1,9 @@ /* generated by Svelte vX.Y.Z */ import { SvelteComponent, - addCssToComponent, + add_css_to_component, append, - appendStyleIfNotPresent, + append_style_if_not_present, attr, detach, element, @@ -15,8 +15,8 @@ import { text } from "svelte/internal"; -function add_css(customStyleTag) { - appendStyleIfNotPresent(customStyleTag, "1a7i8ec", "p.svelte-1a7i8ec{color:red}"); +function add_css(target) { + append_style_if_not_present(target, "1a7i8ec", "p.svelte-1a7i8ec{color:red}"); } function create_fragment(ctx) { @@ -57,7 +57,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - addCssToComponent(this, add_css, options); + add_css_to_component(this, add_css, options); init(this, options, instance, create_fragment, safe_not_equal, { foo: 0 }); } } diff --git a/test/js/samples/css-media-query/expected.js b/test/js/samples/css-media-query/expected.js index 36b88810b81c..6dde01582691 100644 --- a/test/js/samples/css-media-query/expected.js +++ b/test/js/samples/css-media-query/expected.js @@ -1,8 +1,8 @@ /* generated by Svelte vX.Y.Z */ import { SvelteComponent, - addCssToComponent, - appendStyleIfNotPresent, + add_css_to_component, + append_style_if_not_present, attr, detach, element, @@ -12,8 +12,8 @@ import { safe_not_equal } from "svelte/internal"; -function add_css(customStyleTag) { - appendStyleIfNotPresent(customStyleTag, "1slhpfn", "@media(min-width: 1px){div.svelte-1slhpfn{color:red}}"); +function add_css(target) { + append_style_if_not_present(target, "1slhpfn", "@media(min-width: 1px){div.svelte-1slhpfn{color:red}}"); } function create_fragment(ctx) { @@ -39,7 +39,7 @@ function create_fragment(ctx) { class Component extends SvelteComponent { constructor(options) { super(); - addCssToComponent(this, add_css, options); + add_css_to_component(this, add_css, options); init(this, options, null, create_fragment, safe_not_equal, {}); } } From e8065eb22e6db806702b379c3b027b14bc96dfcd Mon Sep 17 00:00:00 2001 From: Ivan Hofer Date: Fri, 20 Nov 2020 07:56:28 +0100 Subject: [PATCH 23/31] don't save customStyleTag in component.$$ --- src/runtime/internal/Component.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/runtime/internal/Component.ts b/src/runtime/internal/Component.ts index 52ab54fa8d84..cd7c68a3eb0b 100644 --- a/src/runtime/internal/Component.ts +++ b/src/runtime/internal/Component.ts @@ -98,11 +98,11 @@ function make_dirty(component, i) { } -export function add_css_to_component(component, add_css, options) { - component.$$ = { - customStyleTag: options.customStyleTag || current_component && current_component.$$.customStyleTag - }; - add_css(component.$$.customStyleTag || document.head); +let appendStylesTo = document.head; + +export function add_css_to_component(add_css, { customStyleTag }) { + if (customStyleTag) appendStylesTo = customStyleTag; + add_css(appendStylesTo); } export function init(component, options, instance, create_fragment, not_equal, props, dirty = [-1]) { @@ -112,8 +112,6 @@ export function init(component, options, instance, create_fragment, not_equal, p const prop_values = options.props || {}; const $$: T$$ = component.$$ = { - ...component.$$, - fragment: null, ctx: null, From b38e2b7b9a4c21beedb4f469657846e3cf2adda5 Mon Sep 17 00:00:00 2001 From: Ivan Hofer Date: Fri, 20 Nov 2020 08:13:43 +0100 Subject: [PATCH 24/31] refactor add_css_to_component to not save customStyleTag in component.$$ --- src/compiler/compile/render_dom/index.ts | 6 +++--- src/runtime/internal/Component.ts | 19 +++++++++++++++---- src/runtime/internal/dom.ts | 13 ------------- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/compiler/compile/render_dom/index.ts b/src/compiler/compile/render_dom/index.ts index 6c0070e635cc..d92e5981a43d 100644 --- a/src/compiler/compile/render_dom/index.ts +++ b/src/compiler/compile/render_dom/index.ts @@ -44,8 +44,8 @@ export default function dom( if (should_add_css) { body.push(b` - function ${add_css}(target) { - @append_style_if_not_present(target, "${component.stylesheet.id.replace('svelte-', '')}", "${styles}"); + function ${add_css}(options) { + @add_css_to_component(options, "${component.stylesheet.id.replace('svelte-', '')}", "${styles}"); } `); } @@ -529,7 +529,7 @@ export default function dom( constructor(options) { super(${options.dev && 'options'}); - ${should_add_css && b`@add_css_to_component(this, ${add_css}, options);`} + ${should_add_css && b`${add_css}(options);`} @init(this, options, ${definition}, ${has_create_fragment ? 'create_fragment' : 'null'}, ${not_equal}, ${prop_indexes}, ${dirty}); ${options.dev && b`@dispatch_dev("SvelteRegisterComponent", { component: this, tagName: "${name.name}", options, id: create_fragment.name });`} diff --git a/src/runtime/internal/Component.ts b/src/runtime/internal/Component.ts index cd7c68a3eb0b..334c58c33c4a 100644 --- a/src/runtime/internal/Component.ts +++ b/src/runtime/internal/Component.ts @@ -1,7 +1,7 @@ import { add_render_callback, flush, schedule_update, dirty_components } from './scheduler'; import { current_component, set_current_component } from './lifecycle'; import { blank_object, is_empty, is_function, run, run_all, noop } from './utils'; -import { children, detach } from './dom'; +import { append, children, detach, element } from './dom'; import { transition_in } from './transitions'; interface Fragment { @@ -100,9 +100,20 @@ function make_dirty(component, i) { let appendStylesTo = document.head; -export function add_css_to_component(add_css, { customStyleTag }) { - if (customStyleTag) appendStylesTo = customStyleTag; - add_css(appendStylesTo); +export function add_css_to_component( + { customStyleTag }, + styleSheetId: string, + styles: string, + styleId:string = `svelte-${styleSheetId}-style`) { + + if (customStyleTag) appendStylesTo = customStyleTag; + + if (!appendStylesTo.querySelector('#' + styleId)) { + const style = element('style'); + style.id = styleId; + style.textContent = styles; + append(appendStylesTo, style); + } } export function init(component, options, instance, create_fragment, not_equal, props, dirty = [-1]) { diff --git a/src/runtime/internal/dom.ts b/src/runtime/internal/dom.ts index 4d4da3f7bd52..91e575ebf630 100644 --- a/src/runtime/internal/dom.ts +++ b/src/runtime/internal/dom.ts @@ -1,18 +1,5 @@ import { has_prop } from './utils'; -export function append_style_if_not_present( - target: Element, - styleSheetId: string, - styles: string, - styleId:string = `svelte-${styleSheetId}-style`) { - if (!target.querySelector('#' + styleId)) { - const style = element('style'); - style.id = styleId; - style.textContent = styles; - append(target, style); - } -} - export function append(target: Node, node: Node) { target.appendChild(node); } From f611abcbbb357b9f76a58c5fb564c5406dfae7e6 Mon Sep 17 00:00:00 2001 From: Ivan Hofer Date: Fri, 20 Nov 2020 08:15:50 +0100 Subject: [PATCH 25/31] fix failing tests --- test/js/samples/collapses-text-around-comments/expected.js | 7 +++---- test/js/samples/css-media-query/expected.js | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/test/js/samples/collapses-text-around-comments/expected.js b/test/js/samples/collapses-text-around-comments/expected.js index 57b370d36870..f0a9f3163446 100644 --- a/test/js/samples/collapses-text-around-comments/expected.js +++ b/test/js/samples/collapses-text-around-comments/expected.js @@ -3,7 +3,6 @@ import { SvelteComponent, add_css_to_component, append, - append_style_if_not_present, attr, detach, element, @@ -15,8 +14,8 @@ import { text } from "svelte/internal"; -function add_css(target) { - append_style_if_not_present(target, "1a7i8ec", "p.svelte-1a7i8ec{color:red}"); +function add_css(options) { + add_css_to_component(options, "1a7i8ec", "p.svelte-1a7i8ec{color:red}"); } function create_fragment(ctx) { @@ -57,7 +56,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - add_css_to_component(this, add_css, options); + add_css(options); init(this, options, instance, create_fragment, safe_not_equal, { foo: 0 }); } } diff --git a/test/js/samples/css-media-query/expected.js b/test/js/samples/css-media-query/expected.js index 6dde01582691..7661567bf113 100644 --- a/test/js/samples/css-media-query/expected.js +++ b/test/js/samples/css-media-query/expected.js @@ -2,7 +2,6 @@ import { SvelteComponent, add_css_to_component, - append_style_if_not_present, attr, detach, element, @@ -12,8 +11,8 @@ import { safe_not_equal } from "svelte/internal"; -function add_css(target) { - append_style_if_not_present(target, "1slhpfn", "@media(min-width: 1px){div.svelte-1slhpfn{color:red}}"); +function add_css(options) { + add_css_to_component(options, "1slhpfn", "@media(min-width: 1px){div.svelte-1slhpfn{color:red}}"); } function create_fragment(ctx) { @@ -39,7 +38,7 @@ function create_fragment(ctx) { class Component extends SvelteComponent { constructor(options) { super(); - add_css_to_component(this, add_css, options); + add_css(options); init(this, options, null, create_fragment, safe_not_equal, {}); } } From d54ab8cddb05f5593915bf98c9024e5029d5687c Mon Sep 17 00:00:00 2001 From: Ivan Hofer Date: Fri, 20 Nov 2020 16:13:06 +0100 Subject: [PATCH 26/31] move append_styles function to dom.ts --- src/compiler/compile/render_dom/index.ts | 2 +- src/runtime/internal/Component.ts | 21 +-------------------- src/runtime/internal/dom.ts | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/compiler/compile/render_dom/index.ts b/src/compiler/compile/render_dom/index.ts index 6c6cafda4d86..e204858df4f5 100644 --- a/src/compiler/compile/render_dom/index.ts +++ b/src/compiler/compile/render_dom/index.ts @@ -50,7 +50,7 @@ export default function dom( if (should_add_css) { body.push(b` function ${add_css}(options) { - @add_css_to_component(options, "${component.stylesheet.id.replace('svelte-', '')}", "${styles}"); + @append_styles(options, "${component.stylesheet.id.replace('svelte-', '')}", "${styles}"); } `); } diff --git a/src/runtime/internal/Component.ts b/src/runtime/internal/Component.ts index 334c58c33c4a..9f5691ff9a4b 100644 --- a/src/runtime/internal/Component.ts +++ b/src/runtime/internal/Component.ts @@ -1,7 +1,7 @@ import { add_render_callback, flush, schedule_update, dirty_components } from './scheduler'; import { current_component, set_current_component } from './lifecycle'; import { blank_object, is_empty, is_function, run, run_all, noop } from './utils'; -import { append, children, detach, element } from './dom'; +import { children, detach } from './dom'; import { transition_in } from './transitions'; interface Fragment { @@ -97,25 +97,6 @@ function make_dirty(component, i) { component.$$.dirty[(i / 31) | 0] |= (1 << (i % 31)); } - -let appendStylesTo = document.head; - -export function add_css_to_component( - { customStyleTag }, - styleSheetId: string, - styles: string, - styleId:string = `svelte-${styleSheetId}-style`) { - - if (customStyleTag) appendStylesTo = customStyleTag; - - if (!appendStylesTo.querySelector('#' + styleId)) { - const style = element('style'); - style.id = styleId; - style.textContent = styles; - append(appendStylesTo, style); - } -} - export function init(component, options, instance, create_fragment, not_equal, props, dirty = [-1]) { const parent_component = current_component; set_current_component(component); diff --git a/src/runtime/internal/dom.ts b/src/runtime/internal/dom.ts index 91e575ebf630..c373f7cc186f 100644 --- a/src/runtime/internal/dom.ts +++ b/src/runtime/internal/dom.ts @@ -1,5 +1,24 @@ import { has_prop } from './utils'; +let appendStylesTo = document.head; + +export function append_styles( + { customStyleTag }, + styleSheetId: string, + styles: string, + styleId:string = `svelte-${styleSheetId}-style`) { + + if (customStyleTag) appendStylesTo = customStyleTag; + + if (!appendStylesTo.querySelector('#' + styleId)) { + const style = element('style'); + style.id = styleId; + style.textContent = styles; + append(appendStylesTo, style); + } +} + + export function append(target: Node, node: Node) { target.appendChild(node); } From ada8969fe5dea3ee5d8a6fc8ca47ecdd4061f32b Mon Sep 17 00:00:00 2001 From: Ivan Hofer Date: Fri, 20 Nov 2020 16:46:57 +0100 Subject: [PATCH 27/31] fix failing tests --- test/js/samples/collapses-text-around-comments/expected.js | 4 ++-- test/js/samples/css-media-query/expected.js | 4 ++-- test/sourcemaps/samples/compile-option-dev/test.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/js/samples/collapses-text-around-comments/expected.js b/test/js/samples/collapses-text-around-comments/expected.js index f0a9f3163446..e3e000094ff7 100644 --- a/test/js/samples/collapses-text-around-comments/expected.js +++ b/test/js/samples/collapses-text-around-comments/expected.js @@ -1,8 +1,8 @@ /* generated by Svelte vX.Y.Z */ import { SvelteComponent, - add_css_to_component, append, + append_styles, attr, detach, element, @@ -15,7 +15,7 @@ import { } from "svelte/internal"; function add_css(options) { - add_css_to_component(options, "1a7i8ec", "p.svelte-1a7i8ec{color:red}"); + append_styles(options, "1a7i8ec", "p.svelte-1a7i8ec{color:red}"); } function create_fragment(ctx) { diff --git a/test/js/samples/css-media-query/expected.js b/test/js/samples/css-media-query/expected.js index 7661567bf113..749c692aa143 100644 --- a/test/js/samples/css-media-query/expected.js +++ b/test/js/samples/css-media-query/expected.js @@ -1,7 +1,7 @@ /* generated by Svelte vX.Y.Z */ import { SvelteComponent, - add_css_to_component, + append_styles, attr, detach, element, @@ -12,7 +12,7 @@ import { } from "svelte/internal"; function add_css(options) { - add_css_to_component(options, "1slhpfn", "@media(min-width: 1px){div.svelte-1slhpfn{color:red}}"); + append_styles(options, "1slhpfn", "@media(min-width: 1px){div.svelte-1slhpfn{color:red}}"); } function create_fragment(ctx) { diff --git a/test/sourcemaps/samples/compile-option-dev/test.js b/test/sourcemaps/samples/compile-option-dev/test.js index bf240a5a8927..750a6afc640d 100644 --- a/test/sourcemaps/samples/compile-option-dev/test.js +++ b/test/sourcemaps/samples/compile-option-dev/test.js @@ -4,8 +4,8 @@ const b64dec = s => Buffer.from(s, 'base64').toString(); export async function test({ assert, css, js }) { - // We check that the css source map embedded in the js is accurate - const match = js.code.match(/\tstyle\.textContent = "(.*?)(?:\\n\/\*# sourceMappingURL=data:(.*?);charset=(.*?);base64,(.*?) \*\/)?";\n/); + // We check that the css source map embedded in the js is accurate + const match = js.code.match(/\tappend_styles\(options, ".{6}", "(.*?)(?:\\n\/\*# sourceMappingURL=data:(.*?);charset=(.*?);base64,(.*?) \*\/)?"\);\n/); assert.notEqual(match, null); const [mimeType, encoding, cssMapBase64] = match.slice(2); From 801001d468e21876c651265b70f6e15a146d6cc8 Mon Sep 17 00:00:00 2001 From: Ivan Hofer Date: Wed, 25 Nov 2020 17:00:10 +0100 Subject: [PATCH 28/31] add docs for customStyleTag --- site/content/docs/03-run-time.md | 1 + 1 file changed, 1 insertion(+) diff --git a/site/content/docs/03-run-time.md b/site/content/docs/03-run-time.md index b35af9383878..8adb3559f997 100644 --- a/site/content/docs/03-run-time.md +++ b/site/content/docs/03-run-time.md @@ -886,6 +886,7 @@ The following initialisation options can be provided: | `props` | `{}` | An object of properties to supply to the component | `hydrate` | `false` | See below | `intro` | `false` | If `true`, will play transitions on initial render, rather than waiting for subsequent state changes +| `customStyleTag` | `document.head` | An `HTMLElement` the styles should be appended to. It will only work if the component was compiled with the [`css: true` option](docs#svelte_compile). Existing children of `target` are left where they are. From 54d3e91929070ab95d759cecf84d5e5207eb3692 Mon Sep 17 00:00:00 2001 From: Ivan Hofer Date: Sun, 29 Nov 2020 10:50:44 +0100 Subject: [PATCH 29/31] add customStyleTag to component constructor options --- src/runtime/internal/dev.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/runtime/internal/dev.ts b/src/runtime/internal/dev.ts index e93523572fe8..4cd3193a73ee 100644 --- a/src/runtime/internal/dev.ts +++ b/src/runtime/internal/dev.ts @@ -136,7 +136,8 @@ export class SvelteComponentDev< $$slot_def: Slots; constructor(options: { - target: Element; + target: Element | ShadowRoot; + customStyleTag: Element | ShadowRoot; anchor?: Element; props?: Props; hydrate?: boolean; From ee789853e7660c2a54b3ee5f5fe91d5bf7293845 Mon Sep 17 00:00:00 2001 From: Ivan Hofer Date: Sun, 29 Nov 2020 13:09:09 +0100 Subject: [PATCH 30/31] update style_manager to use customStyleTag --- src/runtime/internal/dom.ts | 3 +++ src/runtime/internal/style_manager.ts | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/runtime/internal/dom.ts b/src/runtime/internal/dom.ts index c373f7cc186f..69cd8ed5e479 100644 --- a/src/runtime/internal/dom.ts +++ b/src/runtime/internal/dom.ts @@ -18,6 +18,9 @@ export function append_styles( } } +export function append_empty_stylesheet() { + return appendStylesTo.appendChild(element('style') as HTMLStyleElement); +} export function append(target: Node, node: Node) { target.appendChild(node); diff --git a/src/runtime/internal/style_manager.ts b/src/runtime/internal/style_manager.ts index 8060e65a5d3f..4e16bdb3cf78 100644 --- a/src/runtime/internal/style_manager.ts +++ b/src/runtime/internal/style_manager.ts @@ -1,4 +1,4 @@ -import { element } from './dom'; +import { append_empty_stylesheet } from './dom'; import { raf } from './environment'; interface ExtendedDoc extends Document { @@ -31,7 +31,7 @@ export function create_rule(node: Element & ElementCSSInlineStyle, a: number, b: const name = `__svelte_${hash(rule)}_${uid}`; const doc = node.ownerDocument as ExtendedDoc; active_docs.add(doc); - const stylesheet = doc.__svelte_stylesheet || (doc.__svelte_stylesheet = doc.head.appendChild(element('style') as HTMLStyleElement).sheet as CSSStyleSheet); + const stylesheet = doc.__svelte_stylesheet || (doc.__svelte_stylesheet = append_empty_stylesheet().sheet as CSSStyleSheet); const current_rules = doc.__svelte_rules || (doc.__svelte_rules = {}); if (!current_rules[name]) { From 901204ed5817a718d82bcd66dbb5ebdaaeb5838a Mon Sep 17 00:00:00 2001 From: Ivan Hofer Date: Thu, 3 Dec 2020 07:11:48 +0100 Subject: [PATCH 31/31] add customStyleTag to component constructor options --- src/runtime/internal/dev.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/runtime/internal/dev.ts b/src/runtime/internal/dev.ts index e7c4a26d9ad8..41a78528c560 100644 --- a/src/runtime/internal/dev.ts +++ b/src/runtime/internal/dev.ts @@ -117,7 +117,8 @@ export class SvelteComponentDev extends SvelteComponent { $$prop_def: Props; constructor(options: { - target: Element; + target: Element | ShadowRoot; + customStyleTag: Element | ShadowRoot; anchor?: Element; props?: Props; hydrate?: boolean;