From 86d3476b5592ecd3818fc5798fe6cf6a996eda40 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sat, 28 Apr 2018 13:41:30 -0400 Subject: [PATCH] minor fixes, update various tests --- src/generators/nodes/Attribute.ts | 6 +-- src/generators/nodes/Comment.ts | 6 +++ src/generators/nodes/Element.ts | 6 +-- src/generators/nodes/Title.ts | 2 +- src/utils/createDebuggingComment.ts | 27 ++++++------ src/utils/getExpressionPrecedence.ts | 1 + test/js/index.js | 2 +- test/js/samples/action/expected-bundle.js | 4 +- test/js/samples/action/expected.js | 4 +- .../expected-bundle.js | 8 ++-- .../expected.js | 8 ++-- .../expected-bundle.js | 2 +- .../component-static-immutable/expected.js | 2 +- .../expected-bundle.js | 2 +- .../component-static-immutable2/expected.js | 2 +- .../component-static/expected-bundle.js | 2 +- test/js/samples/component-static/expected.js | 2 +- .../computed-collapsed-if/expected-bundle.js | 2 +- .../samples/computed-collapsed-if/expected.js | 2 +- .../css-media-query/expected-bundle.js | 2 +- test/js/samples/css-media-query/expected.js | 2 +- .../expected-bundle.js | 2 +- .../css-shadow-dom-keyframes/expected.js | 2 +- .../deconflict-builtins/expected-bundle.js | 24 +++++----- .../samples/deconflict-builtins/expected.js | 24 +++++----- .../deconflict-globals/expected-bundle.js | 2 +- .../js/samples/deconflict-globals/expected.js | 2 +- .../expected-bundle.js | 12 ++--- .../expected.js | 12 ++--- .../samples/do-use-dataset/expected-bundle.js | 8 ++-- test/js/samples/do-use-dataset/expected.js | 8 ++-- .../expected-bundle.js | 8 ++-- .../dont-use-dataset-in-legacy/expected.js | 8 ++-- .../expected-bundle.js | 8 ++-- .../dont-use-dataset-in-svg/expected.js | 8 ++-- .../expected-bundle.js | 34 +++++++------- .../each-block-changed-check/expected.js | 34 +++++++------- .../event-handlers-custom/expected-bundle.js | 9 ++-- .../samples/event-handlers-custom/expected.js | 9 ++-- .../head-no-whitespace/expected-bundle.js | 2 +- .../js/samples/head-no-whitespace/expected.js | 2 +- .../if-block-no-update/expected-bundle.js | 20 ++++----- .../js/samples/if-block-no-update/expected.js | 20 ++++----- .../if-block-simple/expected-bundle.js | 12 ++--- test/js/samples/if-block-simple/expected.js | 12 ++--- .../expected-bundle.js | 12 ++--- .../expected.js | 12 ++--- .../expected-bundle.js | 8 ++-- .../inline-style-optimized-url/expected.js | 8 ++-- .../inline-style-optimized/expected-bundle.js | 8 ++-- .../inline-style-optimized/expected.js | 8 ++-- .../expected-bundle.js | 12 ++--- .../inline-style-unoptimized/expected.js | 12 ++--- .../expected-bundle.js | 8 ++-- .../input-without-blowback-guard/expected.js | 8 ++-- .../legacy-input-type/expected-bundle.js | 2 +- test/js/samples/legacy-input-type/expected.js | 2 +- .../samples/media-bindings/expected-bundle.js | 20 ++++----- test/js/samples/media-bindings/expected.js | 20 ++++----- .../non-imported-component/expected-bundle.js | 2 +- .../non-imported-component/expected.js | 2 +- .../samples/setup-method/expected-bundle.js | 2 +- test/js/samples/setup-method/expected.js | 2 +- .../ssr-no-oncreate-etc/expected-bundle.js | 4 +- .../samples/ssr-no-oncreate-etc/expected.js | 4 +- .../ssr-preserve-comments/expected-bundle.js | 4 +- .../samples/ssr-preserve-comments/expected.js | 4 +- test/js/samples/svg-title/expected-bundle.js | 2 +- test/js/samples/svg-title/expected.js | 2 +- test/js/samples/title/expected-bundle.js | 8 ++-- test/js/samples/title/expected.js | 8 ++-- .../expected-bundle.js | 44 +++++++++---------- .../use-elements-as-anchors/expected.js | 44 +++++++++---------- .../window-binding-scroll/expected-bundle.js | 8 ++-- .../samples/window-binding-scroll/expected.js | 8 ++-- 75 files changed, 328 insertions(+), 336 deletions(-) diff --git a/src/generators/nodes/Attribute.ts b/src/generators/nodes/Attribute.ts index e7d475eee6..3d4b5eb9a2 100644 --- a/src/generators/nodes/Attribute.ts +++ b/src/generators/nodes/Attribute.ts @@ -89,7 +89,7 @@ export default class Attribute extends Node { if (chunk.type === 'Text') { return stringify(chunk.data); } else { - return getExpressionPrecedence(chunk) <= 13 ? `(${chunk.snippet})` : snippet; + return getExpressionPrecedence(chunk.node) <= 13 ? `(${chunk.snippet})` : snippet; } }) .join(' + '); @@ -183,7 +183,7 @@ export default class Attribute extends Node { allDependencies.add(d); }); - return getExpressionPrecedence(chunk) <= 13 ? `(${snippet})` : snippet; + return getExpressionPrecedence(chunk.node) <= 13 ? `(${snippet})` : snippet; } }) .join(' + '); @@ -330,7 +330,7 @@ export default class Attribute extends Node { allDependencies.add(d); }); - return getExpressionPrecedence(chunk) <= 13 ? `(${snippet})` : snippet; + return getExpressionPrecedence(chunk.node) <= 13 ? `(${snippet})` : snippet; } }) .join(' + '); diff --git a/src/generators/nodes/Comment.ts b/src/generators/nodes/Comment.ts index cae96b7b6f..31289c1110 100644 --- a/src/generators/nodes/Comment.ts +++ b/src/generators/nodes/Comment.ts @@ -2,4 +2,10 @@ import Node from './shared/Node'; export default class Comment extends Node { type: 'Comment'; + data: string; + + constructor(compiler, parent, scope, info) { + super(compiler, parent, scope, info); + this.data = info.data; + } } \ No newline at end of file diff --git a/src/generators/nodes/Element.ts b/src/generators/nodes/Element.ts index dc061d270a..a2c9ef0bcc 100644 --- a/src/generators/nodes/Element.ts +++ b/src/generators/nodes/Element.ts @@ -160,19 +160,19 @@ export default class Element extends Node { }); this.actions.forEach(action => { - this.cannotUseInnerHTML(); + this.parent.cannotUseInnerHTML(); if (action.expression) { block.addDependencies(action.expression.dependencies); } }); this.bindings.forEach(binding => { - this.cannotUseInnerHTML(); + this.parent.cannotUseInnerHTML(); block.addDependencies(binding.value.dependencies); }); this.handlers.forEach(handler => { - this.cannotUseInnerHTML(); + this.parent.cannotUseInnerHTML(); block.addDependencies(handler.dependencies); }); diff --git a/src/generators/nodes/Title.ts b/src/generators/nodes/Title.ts index d2f553c938..ff4203c8bd 100644 --- a/src/generators/nodes/Title.ts +++ b/src/generators/nodes/Title.ts @@ -57,7 +57,7 @@ export default class Title extends Node { allDependencies.add(d); }); - return getExpressionPrecedence(chunk) <= 13 ? `(${snippet})` : snippet; + return getExpressionPrecedence(chunk.node) <= 13 ? `(${snippet})` : snippet; } }) .join(' + '); diff --git a/src/utils/createDebuggingComment.ts b/src/utils/createDebuggingComment.ts index 61dc2ddba0..d3ae5c1f82 100644 --- a/src/utils/createDebuggingComment.ts +++ b/src/utils/createDebuggingComment.ts @@ -1,22 +1,21 @@ import { DomGenerator } from '../generators/dom/index'; import { Node } from '../interfaces'; -export default function createDebuggingComment(node: Node, generator: DomGenerator) { - return `TODO ${node.start}-${node.end}`; - // const { locate, source } = generator; +export default function createDebuggingComment(node: Node, compiler: DomGenerator) { + const { locate, source } = compiler; - // let c = node.start; - // if (node.type === 'ElseBlock') { - // while (source[c - 1] !== '{') c -= 1; - // while (source[c - 1] === '{') c -= 1; - // } + let c = node.start; + if (node.type === 'ElseBlock') { + while (source[c - 1] !== '{') c -= 1; + while (source[c - 1] === '{') c -= 1; + } - // let d = node.expression ? node.expression.end : c; - // while (source[d] !== '}') d += 1; - // while (source[d] === '}') d += 1; + let d = node.expression ? node.expression.node.end : c; + while (source[d] !== '}') d += 1; + while (source[d] === '}') d += 1; - // const start = locate(c); - // const loc = `(${start.line + 1}:${start.column})`; + const start = locate(c); + const loc = `(${start.line + 1}:${start.column})`; - // return `${loc} ${source.slice(c, d)}`.replace(/\s/g, ' '); + return `${loc} ${source.slice(c, d)}`.replace(/\s/g, ' '); } diff --git a/src/utils/getExpressionPrecedence.ts b/src/utils/getExpressionPrecedence.ts index 3e136246ba..7cd26293af 100644 --- a/src/utils/getExpressionPrecedence.ts +++ b/src/utils/getExpressionPrecedence.ts @@ -48,6 +48,7 @@ const precedence: Record number> = { SequenceExpression: () => 0 }; +// TODO make this a method of Expression export default function getExpressionPrecedence(expression: Node) { return expression.type in precedence ? precedence[expression.type](expression) : 0; } \ No newline at end of file diff --git a/test/js/index.js b/test/js/index.js index 8c6104fa37..28d40c0740 100644 --- a/test/js/index.js +++ b/test/js/index.js @@ -4,7 +4,7 @@ import * as path from "path"; import { rollup } from "rollup"; import { loadConfig, svelte } from "../helpers.js"; -describe("js", () => { +describe.only("js", () => { fs.readdirSync("test/js/samples").forEach(dir => { if (dir[0] === ".") return; diff --git a/test/js/samples/action/expected-bundle.js b/test/js/samples/action/expected-bundle.js index 6c93a26fbb..f1ee2f4b20 100644 --- a/test/js/samples/action/expected-bundle.js +++ b/test/js/samples/action/expected-bundle.js @@ -136,7 +136,7 @@ var proto = { /* generated by Svelte vX.Y.Z */ function link(node) { - + function onClick(event) { event.preventDefault(); history.pushState(null, null, event.target.href); @@ -150,7 +150,7 @@ function link(node) { } } } -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var a, link_action; return { diff --git a/test/js/samples/action/expected.js b/test/js/samples/action/expected.js index 5562b84529..40459f03f9 100644 --- a/test/js/samples/action/expected.js +++ b/test/js/samples/action/expected.js @@ -2,7 +2,7 @@ import { assign, createElement, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; function link(node) { - + function onClick(event) { event.preventDefault(); history.pushState(null, null, event.target.href); @@ -17,7 +17,7 @@ function link(node) { } }; -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var a, link_action; return { diff --git a/test/js/samples/collapses-text-around-comments/expected-bundle.js b/test/js/samples/collapses-text-around-comments/expected-bundle.js index 6d3d9653a4..98b4f05e99 100644 --- a/test/js/samples/collapses-text-around-comments/expected-bundle.js +++ b/test/js/samples/collapses-text-around-comments/expected-bundle.js @@ -153,13 +153,13 @@ function add_css() { appendNode(style, document.head); } -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var p, text; return { c: function create() { p = createElement("p"); - text = createText(state.foo); + text = createText(ctx.foo); this.h(); }, @@ -172,9 +172,9 @@ function create_main_fragment(component, state) { appendNode(text, p); }, - p: function update(changed, state) { + p: function update(changed, ctx) { if (changed.foo) { - text.data = state.foo; + text.data = ctx.foo; } }, diff --git a/test/js/samples/collapses-text-around-comments/expected.js b/test/js/samples/collapses-text-around-comments/expected.js index 2f50f85a68..4f2e57b79b 100644 --- a/test/js/samples/collapses-text-around-comments/expected.js +++ b/test/js/samples/collapses-text-around-comments/expected.js @@ -12,13 +12,13 @@ function add_css() { appendNode(style, document.head); } -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var p, text; return { c: function create() { p = createElement("p"); - text = createText(state.foo); + text = createText(ctx.foo); this.h(); }, @@ -31,9 +31,9 @@ function create_main_fragment(component, state) { appendNode(text, p); }, - p: function update(changed, state) { + p: function update(changed, ctx) { if (changed.foo) { - text.data = state.foo; + text.data = ctx.foo; } }, diff --git a/test/js/samples/component-static-immutable/expected-bundle.js b/test/js/samples/component-static-immutable/expected-bundle.js index 885c914ee4..afb5806709 100644 --- a/test/js/samples/component-static-immutable/expected-bundle.js +++ b/test/js/samples/component-static-immutable/expected-bundle.js @@ -129,7 +129,7 @@ var proto = { var Nested = window.Nested; -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var nested_initial_data = { foo: "bar" }; var nested = new Nested({ diff --git a/test/js/samples/component-static-immutable/expected.js b/test/js/samples/component-static-immutable/expected.js index ee5a447d64..eceb10bda2 100644 --- a/test/js/samples/component-static-immutable/expected.js +++ b/test/js/samples/component-static-immutable/expected.js @@ -3,7 +3,7 @@ import { _differsImmutable, assign, callAll, init, noop, proto } from "svelte/sh var Nested = window.Nested; -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var nested_initial_data = { foo: "bar" }; var nested = new Nested({ diff --git a/test/js/samples/component-static-immutable2/expected-bundle.js b/test/js/samples/component-static-immutable2/expected-bundle.js index 885c914ee4..afb5806709 100644 --- a/test/js/samples/component-static-immutable2/expected-bundle.js +++ b/test/js/samples/component-static-immutable2/expected-bundle.js @@ -129,7 +129,7 @@ var proto = { var Nested = window.Nested; -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var nested_initial_data = { foo: "bar" }; var nested = new Nested({ diff --git a/test/js/samples/component-static-immutable2/expected.js b/test/js/samples/component-static-immutable2/expected.js index ee5a447d64..eceb10bda2 100644 --- a/test/js/samples/component-static-immutable2/expected.js +++ b/test/js/samples/component-static-immutable2/expected.js @@ -3,7 +3,7 @@ import { _differsImmutable, assign, callAll, init, noop, proto } from "svelte/sh var Nested = window.Nested; -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var nested_initial_data = { foo: "bar" }; var nested = new Nested({ diff --git a/test/js/samples/component-static/expected-bundle.js b/test/js/samples/component-static/expected-bundle.js index 3a076f7b06..486a6dd613 100644 --- a/test/js/samples/component-static/expected-bundle.js +++ b/test/js/samples/component-static/expected-bundle.js @@ -125,7 +125,7 @@ var proto = { var Nested = window.Nested; -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var nested_initial_data = { foo: "bar" }; var nested = new Nested({ diff --git a/test/js/samples/component-static/expected.js b/test/js/samples/component-static/expected.js index 93584db49e..1e7a22f061 100644 --- a/test/js/samples/component-static/expected.js +++ b/test/js/samples/component-static/expected.js @@ -3,7 +3,7 @@ import { assign, callAll, init, noop, proto } from "svelte/shared.js"; var Nested = window.Nested; -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var nested_initial_data = { foo: "bar" }; var nested = new Nested({ diff --git a/test/js/samples/computed-collapsed-if/expected-bundle.js b/test/js/samples/computed-collapsed-if/expected-bundle.js index c4ee816672..0ea5200f7d 100644 --- a/test/js/samples/computed-collapsed-if/expected-bundle.js +++ b/test/js/samples/computed-collapsed-if/expected-bundle.js @@ -131,7 +131,7 @@ function b({ x }) { return x * 3; } -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { return { c: noop, diff --git a/test/js/samples/computed-collapsed-if/expected.js b/test/js/samples/computed-collapsed-if/expected.js index f1228ca0b6..5c248bf515 100644 --- a/test/js/samples/computed-collapsed-if/expected.js +++ b/test/js/samples/computed-collapsed-if/expected.js @@ -9,7 +9,7 @@ function b({ x }) { return x * 3; } -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { return { c: noop, diff --git a/test/js/samples/css-media-query/expected-bundle.js b/test/js/samples/css-media-query/expected-bundle.js index 4a9ed1203e..960dc9a446 100644 --- a/test/js/samples/css-media-query/expected-bundle.js +++ b/test/js/samples/css-media-query/expected-bundle.js @@ -146,7 +146,7 @@ function add_css() { appendNode(style, document.head); } -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var div; return { diff --git a/test/js/samples/css-media-query/expected.js b/test/js/samples/css-media-query/expected.js index 893af23035..83b85d974b 100644 --- a/test/js/samples/css-media-query/expected.js +++ b/test/js/samples/css-media-query/expected.js @@ -8,7 +8,7 @@ function add_css() { appendNode(style, document.head); } -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var div; return { diff --git a/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js b/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js index fe55d1c905..86200cb8c0 100644 --- a/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js +++ b/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js @@ -135,7 +135,7 @@ var proto = { /* generated by Svelte vX.Y.Z */ -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var div; return { diff --git a/test/js/samples/css-shadow-dom-keyframes/expected.js b/test/js/samples/css-shadow-dom-keyframes/expected.js index eeac231db1..fa4eec75b0 100644 --- a/test/js/samples/css-shadow-dom-keyframes/expected.js +++ b/test/js/samples/css-shadow-dom-keyframes/expected.js @@ -1,7 +1,7 @@ /* generated by Svelte vX.Y.Z */ import { assign, createElement, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var div; return { diff --git a/test/js/samples/deconflict-builtins/expected-bundle.js b/test/js/samples/deconflict-builtins/expected-bundle.js index f26f231f4a..4bc21f60a6 100644 --- a/test/js/samples/deconflict-builtins/expected-bundle.js +++ b/test/js/samples/deconflict-builtins/expected-bundle.js @@ -153,15 +153,15 @@ var proto = { /* generated by Svelte vX.Y.Z */ -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var each_anchor; - var each_value = state.createElement; + var each_value = ctx.createElement; var each_blocks = []; for (var i = 0; i < each_value.length; i += 1) { - each_blocks[i] = create_each_block(component, assign(assign({}, state), { + each_blocks[i] = create_each_block(component, assign(assign({}, ctx), { each_value: each_value, node: each_value[i], node_index: i @@ -185,12 +185,12 @@ function create_main_fragment(component, state) { insertNode(each_anchor, target, anchor); }, - p: function update(changed, state) { - var each_value = state.createElement; + p: function update(changed, ctx) { + var each_value = ctx.createElement; if (changed.createElement) { for (var i = 0; i < each_value.length; i += 1) { - var each_context = assign(assign({}, state), { + var each_context = assign(assign({}, ctx), { each_value: each_value, node: each_value[i], node_index: i @@ -228,9 +228,8 @@ function create_main_fragment(component, state) { } // (1:0) {#each createElement as node} -function create_each_block(component, state) { - var node = state.node, each_value = state.each_value, node_index = state.node_index; - var span, text_value = node, text; +function create_each_block(component, ctx) { + var span, text_value = ctx.node, text; return { c: function create() { @@ -243,11 +242,8 @@ function create_each_block(component, state) { appendNode(text, span); }, - p: function update(changed, state) { - node = state.node; - each_value = state.each_value; - node_index = state.node_index; - if ((changed.createElement) && text_value !== (text_value = node)) { + p: function update(changed, ctx) { + if ((changed.createElement) && text_value !== (text_value = ctx.node)) { text.data = text_value; } }, diff --git a/test/js/samples/deconflict-builtins/expected.js b/test/js/samples/deconflict-builtins/expected.js index f6861d2557..aa928967c4 100644 --- a/test/js/samples/deconflict-builtins/expected.js +++ b/test/js/samples/deconflict-builtins/expected.js @@ -1,15 +1,15 @@ /* generated by Svelte vX.Y.Z */ import { appendNode, assign, createComment, createElement, createText, destroyEach, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var each_anchor; - var each_value = state.createElement; + var each_value = ctx.createElement; var each_blocks = []; for (var i = 0; i < each_value.length; i += 1) { - each_blocks[i] = create_each_block(component, assign(assign({}, state), { + each_blocks[i] = create_each_block(component, assign(assign({}, ctx), { each_value: each_value, node: each_value[i], node_index: i @@ -33,12 +33,12 @@ function create_main_fragment(component, state) { insertNode(each_anchor, target, anchor); }, - p: function update(changed, state) { - var each_value = state.createElement; + p: function update(changed, ctx) { + var each_value = ctx.createElement; if (changed.createElement) { for (var i = 0; i < each_value.length; i += 1) { - var each_context = assign(assign({}, state), { + var each_context = assign(assign({}, ctx), { each_value: each_value, node: each_value[i], node_index: i @@ -76,9 +76,8 @@ function create_main_fragment(component, state) { } // (1:0) {#each createElement as node} -function create_each_block(component, state) { - var node = state.node, each_value = state.each_value, node_index = state.node_index; - var span, text_value = node, text; +function create_each_block(component, ctx) { + var span, text_value = ctx.node, text; return { c: function create() { @@ -91,11 +90,8 @@ function create_each_block(component, state) { appendNode(text, span); }, - p: function update(changed, state) { - node = state.node; - each_value = state.each_value; - node_index = state.node_index; - if ((changed.createElement) && text_value !== (text_value = node)) { + p: function update(changed, ctx) { + if ((changed.createElement) && text_value !== (text_value = ctx.node)) { text.data = text_value; } }, diff --git a/test/js/samples/deconflict-globals/expected-bundle.js b/test/js/samples/deconflict-globals/expected-bundle.js index 2db12d46fb..304b7cd956 100644 --- a/test/js/samples/deconflict-globals/expected-bundle.js +++ b/test/js/samples/deconflict-globals/expected-bundle.js @@ -137,7 +137,7 @@ function data_1() { function oncreate() { alert(JSON.stringify(data())); } -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { return { c: noop, diff --git a/test/js/samples/deconflict-globals/expected.js b/test/js/samples/deconflict-globals/expected.js index 8b91d1550a..a12da57b8a 100644 --- a/test/js/samples/deconflict-globals/expected.js +++ b/test/js/samples/deconflict-globals/expected.js @@ -11,7 +11,7 @@ function oncreate() { alert(JSON.stringify(data())); }; -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { return { c: noop, diff --git a/test/js/samples/dev-warning-missing-data-computed/expected-bundle.js b/test/js/samples/dev-warning-missing-data-computed/expected-bundle.js index 574211a6e0..bea4d272db 100644 --- a/test/js/samples/dev-warning-missing-data-computed/expected-bundle.js +++ b/test/js/samples/dev-warning-missing-data-computed/expected-bundle.js @@ -165,15 +165,15 @@ function bar({ foo }) { return foo * 2; } -function create_main_fragment(component, state) { - var p, text_value = state.Math.max(0, state.foo), text, text_1, text_2; +function create_main_fragment(component, ctx) { + var p, text_value = ctx.Math.max(0, ctx.foo), text, text_1, text_2; return { c: function create() { p = createElement("p"); text = createText(text_value); text_1 = createText("\n\t"); - text_2 = createText(state.bar); + text_2 = createText(ctx.bar); }, m: function mount(target, anchor) { @@ -183,13 +183,13 @@ function create_main_fragment(component, state) { appendNode(text_2, p); }, - p: function update(changed, state) { - if ((changed.Math || changed.foo) && text_value !== (text_value = state.Math.max(0, state.foo))) { + p: function update(changed, ctx) { + if ((changed.Math || changed.foo) && text_value !== (text_value = ctx.Math.max(0, ctx.foo))) { text.data = text_value; } if (changed.bar) { - text_2.data = state.bar; + text_2.data = ctx.bar; } }, 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 52dee37250..93be0ba0c1 100644 --- a/test/js/samples/dev-warning-missing-data-computed/expected.js +++ b/test/js/samples/dev-warning-missing-data-computed/expected.js @@ -5,15 +5,15 @@ function bar({ foo }) { return foo * 2; } -function create_main_fragment(component, state) { - var p, text_value = state.Math.max(0, state.foo), text, text_1, text_2; +function create_main_fragment(component, ctx) { + var p, text_value = ctx.Math.max(0, ctx.foo), text, text_1, text_2; return { c: function create() { p = createElement("p"); text = createText(text_value); text_1 = createText("\n\t"); - text_2 = createText(state.bar); + text_2 = createText(ctx.bar); }, m: function mount(target, anchor) { @@ -23,13 +23,13 @@ function create_main_fragment(component, state) { appendNode(text_2, p); }, - p: function update(changed, state) { - if ((changed.Math || changed.foo) && text_value !== (text_value = state.Math.max(0, state.foo))) { + p: function update(changed, ctx) { + if ((changed.Math || changed.foo) && text_value !== (text_value = ctx.Math.max(0, ctx.foo))) { text.data = text_value; } if (changed.bar) { - text_2.data = state.bar; + text_2.data = ctx.bar; } }, diff --git a/test/js/samples/do-use-dataset/expected-bundle.js b/test/js/samples/do-use-dataset/expected-bundle.js index 7e6d87e70d..b7e86d5e5c 100644 --- a/test/js/samples/do-use-dataset/expected-bundle.js +++ b/test/js/samples/do-use-dataset/expected-bundle.js @@ -139,7 +139,7 @@ var proto = { /* generated by Svelte vX.Y.Z */ -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var div, text, div_1; return { @@ -152,7 +152,7 @@ function create_main_fragment(component, state) { h: function hydrate() { div.dataset.foo = "bar"; - div_1.dataset.foo = state.bar; + div_1.dataset.foo = ctx.bar; }, m: function mount(target, anchor) { @@ -161,9 +161,9 @@ function create_main_fragment(component, state) { insertNode(div_1, target, anchor); }, - p: function update(changed, state) { + p: function update(changed, ctx) { if (changed.bar) { - div_1.dataset.foo = state.bar; + div_1.dataset.foo = ctx.bar; } }, diff --git a/test/js/samples/do-use-dataset/expected.js b/test/js/samples/do-use-dataset/expected.js index b88636a606..aac859dd79 100644 --- a/test/js/samples/do-use-dataset/expected.js +++ b/test/js/samples/do-use-dataset/expected.js @@ -1,7 +1,7 @@ /* generated by Svelte vX.Y.Z */ import { assign, createElement, createText, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var div, text, div_1; return { @@ -14,7 +14,7 @@ function create_main_fragment(component, state) { h: function hydrate() { div.dataset.foo = "bar"; - div_1.dataset.foo = state.bar; + div_1.dataset.foo = ctx.bar; }, m: function mount(target, anchor) { @@ -23,9 +23,9 @@ function create_main_fragment(component, state) { insertNode(div_1, target, anchor); }, - p: function update(changed, state) { + p: function update(changed, ctx) { if (changed.bar) { - div_1.dataset.foo = state.bar; + div_1.dataset.foo = ctx.bar; } }, diff --git a/test/js/samples/dont-use-dataset-in-legacy/expected-bundle.js b/test/js/samples/dont-use-dataset-in-legacy/expected-bundle.js index e7bd12a65e..59dbcf65c6 100644 --- a/test/js/samples/dont-use-dataset-in-legacy/expected-bundle.js +++ b/test/js/samples/dont-use-dataset-in-legacy/expected-bundle.js @@ -143,7 +143,7 @@ var proto = { /* generated by Svelte vX.Y.Z */ -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var div, text, div_1; return { @@ -156,7 +156,7 @@ function create_main_fragment(component, state) { h: function hydrate() { setAttribute(div, "data-foo", "bar"); - setAttribute(div_1, "data-foo", state.bar); + setAttribute(div_1, "data-foo", ctx.bar); }, m: function mount(target, anchor) { @@ -165,9 +165,9 @@ function create_main_fragment(component, state) { insertNode(div_1, target, anchor); }, - p: function update(changed, state) { + p: function update(changed, ctx) { if (changed.bar) { - setAttribute(div_1, "data-foo", state.bar); + setAttribute(div_1, "data-foo", ctx.bar); } }, diff --git a/test/js/samples/dont-use-dataset-in-legacy/expected.js b/test/js/samples/dont-use-dataset-in-legacy/expected.js index 699da1270b..b6e891dbf5 100644 --- a/test/js/samples/dont-use-dataset-in-legacy/expected.js +++ b/test/js/samples/dont-use-dataset-in-legacy/expected.js @@ -1,7 +1,7 @@ /* generated by Svelte vX.Y.Z */ import { assign, createElement, createText, detachNode, init, insertNode, noop, proto, setAttribute } from "svelte/shared.js"; -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var div, text, div_1; return { @@ -14,7 +14,7 @@ function create_main_fragment(component, state) { h: function hydrate() { setAttribute(div, "data-foo", "bar"); - setAttribute(div_1, "data-foo", state.bar); + setAttribute(div_1, "data-foo", ctx.bar); }, m: function mount(target, anchor) { @@ -23,9 +23,9 @@ function create_main_fragment(component, state) { insertNode(div_1, target, anchor); }, - p: function update(changed, state) { + p: function update(changed, ctx) { if (changed.bar) { - setAttribute(div_1, "data-foo", state.bar); + setAttribute(div_1, "data-foo", ctx.bar); } }, diff --git a/test/js/samples/dont-use-dataset-in-svg/expected-bundle.js b/test/js/samples/dont-use-dataset-in-svg/expected-bundle.js index 51c29449e7..f633f315d8 100644 --- a/test/js/samples/dont-use-dataset-in-svg/expected-bundle.js +++ b/test/js/samples/dont-use-dataset-in-svg/expected-bundle.js @@ -143,7 +143,7 @@ var proto = { /* generated by Svelte vX.Y.Z */ -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var svg, g, g_1; return { @@ -156,7 +156,7 @@ function create_main_fragment(component, state) { h: function hydrate() { setAttribute(g, "data-foo", "bar"); - setAttribute(g_1, "data-foo", state.bar); + setAttribute(g_1, "data-foo", ctx.bar); }, m: function mount(target, anchor) { @@ -165,9 +165,9 @@ function create_main_fragment(component, state) { appendNode(g_1, svg); }, - p: function update(changed, state) { + p: function update(changed, ctx) { if (changed.bar) { - setAttribute(g_1, "data-foo", state.bar); + setAttribute(g_1, "data-foo", ctx.bar); } }, diff --git a/test/js/samples/dont-use-dataset-in-svg/expected.js b/test/js/samples/dont-use-dataset-in-svg/expected.js index 4269367254..917538a141 100644 --- a/test/js/samples/dont-use-dataset-in-svg/expected.js +++ b/test/js/samples/dont-use-dataset-in-svg/expected.js @@ -1,7 +1,7 @@ /* generated by Svelte vX.Y.Z */ import { appendNode, assign, createSvgElement, detachNode, init, insertNode, noop, proto, setAttribute } from "svelte/shared.js"; -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var svg, g, g_1; return { @@ -14,7 +14,7 @@ function create_main_fragment(component, state) { h: function hydrate() { setAttribute(g, "data-foo", "bar"); - setAttribute(g_1, "data-foo", state.bar); + setAttribute(g_1, "data-foo", ctx.bar); }, m: function mount(target, anchor) { @@ -23,9 +23,9 @@ function create_main_fragment(component, state) { appendNode(g_1, svg); }, - p: function update(changed, state) { + p: function update(changed, ctx) { if (changed.bar) { - setAttribute(g_1, "data-foo", state.bar); + setAttribute(g_1, "data-foo", ctx.bar); } }, diff --git a/test/js/samples/each-block-changed-check/expected-bundle.js b/test/js/samples/each-block-changed-check/expected-bundle.js index fc21b6f747..560c0514ae 100644 --- a/test/js/samples/each-block-changed-check/expected-bundle.js +++ b/test/js/samples/each-block-changed-check/expected-bundle.js @@ -155,15 +155,15 @@ var proto = { /* generated by Svelte vX.Y.Z */ -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var text, p, text_1; - var each_value = state.comments; + var each_value = ctx.comments; var each_blocks = []; for (var i = 0; i < each_value.length; i += 1) { - each_blocks[i] = create_each_block(component, assign(assign({}, state), { + each_blocks[i] = create_each_block(component, assign(assign({}, ctx), { each_value: each_value, comment: each_value[i], i: i @@ -178,7 +178,7 @@ function create_main_fragment(component, state) { text = createText("\n\n"); p = createElement("p"); - text_1 = createText(state.foo); + text_1 = createText(ctx.foo); }, m: function mount(target, anchor) { @@ -191,12 +191,12 @@ function create_main_fragment(component, state) { appendNode(text_1, p); }, - p: function update(changed, state) { - var each_value = state.comments; + p: function update(changed, ctx) { + var each_value = ctx.comments; if (changed.comments || changed.elapsed || changed.time) { for (var i = 0; i < each_value.length; i += 1) { - var each_context = assign(assign({}, state), { + var each_context = assign(assign({}, ctx), { each_value: each_value, comment: each_value[i], i: i @@ -219,7 +219,7 @@ function create_main_fragment(component, state) { } if (changed.foo) { - text_1.data = state.foo; + text_1.data = ctx.foo; } }, @@ -239,15 +239,14 @@ function create_main_fragment(component, state) { } // (1:0) {#each comments as comment, i} -function create_each_block(component, state) { - var comment = state.comment, each_value = state.each_value, i = state.i; - var div, strong, text, text_1, span, text_2_value = comment.author, text_2, text_3, text_4_value = state.elapsed(comment.time, state.time), text_4, text_5, text_6, raw_value = comment.html, raw_before; +function create_each_block(component, ctx) { + var div, strong, text, text_1, span, text_2_value = ctx.comment.author, text_2, text_3, text_4_value = ctx.elapsed(ctx.comment.time, ctx.time), text_4, text_5, text_6, raw_value = ctx.comment.html, raw_before; return { c: function create() { div = createElement("div"); strong = createElement("strong"); - text = createText(i); + text = createText(ctx.i); text_1 = createText("\n\n\t\t"); span = createElement("span"); text_2 = createText(text_2_value); @@ -279,19 +278,16 @@ function create_each_block(component, state) { raw_before.insertAdjacentHTML("afterend", raw_value); }, - p: function update(changed, state) { - comment = state.comment; - each_value = state.each_value; - i = state.i; - if ((changed.comments) && text_2_value !== (text_2_value = comment.author)) { + p: function update(changed, ctx) { + if ((changed.comments) && text_2_value !== (text_2_value = ctx.comment.author)) { text_2.data = text_2_value; } - if ((changed.elapsed || changed.comments || changed.time) && text_4_value !== (text_4_value = state.elapsed(comment.time, state.time))) { + if ((changed.elapsed || changed.comments || changed.time) && text_4_value !== (text_4_value = ctx.elapsed(ctx.comment.time, ctx.time))) { text_4.data = text_4_value; } - if ((changed.comments) && raw_value !== (raw_value = comment.html)) { + if ((changed.comments) && raw_value !== (raw_value = ctx.comment.html)) { detachAfter(raw_before); raw_before.insertAdjacentHTML("afterend", raw_value); } diff --git a/test/js/samples/each-block-changed-check/expected.js b/test/js/samples/each-block-changed-check/expected.js index e7e0ccca30..6b15078c79 100644 --- a/test/js/samples/each-block-changed-check/expected.js +++ b/test/js/samples/each-block-changed-check/expected.js @@ -1,15 +1,15 @@ /* generated by Svelte vX.Y.Z */ import { appendNode, assign, createElement, createText, destroyEach, detachAfter, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var text, p, text_1; - var each_value = state.comments; + var each_value = ctx.comments; var each_blocks = []; for (var i = 0; i < each_value.length; i += 1) { - each_blocks[i] = create_each_block(component, assign(assign({}, state), { + each_blocks[i] = create_each_block(component, assign(assign({}, ctx), { each_value: each_value, comment: each_value[i], i: i @@ -24,7 +24,7 @@ function create_main_fragment(component, state) { text = createText("\n\n"); p = createElement("p"); - text_1 = createText(state.foo); + text_1 = createText(ctx.foo); }, m: function mount(target, anchor) { @@ -37,12 +37,12 @@ function create_main_fragment(component, state) { appendNode(text_1, p); }, - p: function update(changed, state) { - var each_value = state.comments; + p: function update(changed, ctx) { + var each_value = ctx.comments; if (changed.comments || changed.elapsed || changed.time) { for (var i = 0; i < each_value.length; i += 1) { - var each_context = assign(assign({}, state), { + var each_context = assign(assign({}, ctx), { each_value: each_value, comment: each_value[i], i: i @@ -65,7 +65,7 @@ function create_main_fragment(component, state) { } if (changed.foo) { - text_1.data = state.foo; + text_1.data = ctx.foo; } }, @@ -85,15 +85,14 @@ function create_main_fragment(component, state) { } // (1:0) {#each comments as comment, i} -function create_each_block(component, state) { - var comment = state.comment, each_value = state.each_value, i = state.i; - var div, strong, text, text_1, span, text_2_value = comment.author, text_2, text_3, text_4_value = state.elapsed(comment.time, state.time), text_4, text_5, text_6, raw_value = comment.html, raw_before; +function create_each_block(component, ctx) { + var div, strong, text, text_1, span, text_2_value = ctx.comment.author, text_2, text_3, text_4_value = ctx.elapsed(ctx.comment.time, ctx.time), text_4, text_5, text_6, raw_value = ctx.comment.html, raw_before; return { c: function create() { div = createElement("div"); strong = createElement("strong"); - text = createText(i); + text = createText(ctx.i); text_1 = createText("\n\n\t\t"); span = createElement("span"); text_2 = createText(text_2_value); @@ -125,19 +124,16 @@ function create_each_block(component, state) { raw_before.insertAdjacentHTML("afterend", raw_value); }, - p: function update(changed, state) { - comment = state.comment; - each_value = state.each_value; - i = state.i; - if ((changed.comments) && text_2_value !== (text_2_value = comment.author)) { + p: function update(changed, ctx) { + if ((changed.comments) && text_2_value !== (text_2_value = ctx.comment.author)) { text_2.data = text_2_value; } - if ((changed.elapsed || changed.comments || changed.time) && text_4_value !== (text_4_value = state.elapsed(comment.time, state.time))) { + if ((changed.elapsed || changed.comments || changed.time) && text_4_value !== (text_4_value = ctx.elapsed(ctx.comment.time, ctx.time))) { text_4.data = text_4_value; } - if ((changed.comments) && raw_value !== (raw_value = comment.html)) { + if ((changed.comments) && raw_value !== (raw_value = ctx.comment.html)) { detachAfter(raw_before); raw_before.insertAdjacentHTML("afterend", raw_value); } diff --git a/test/js/samples/event-handlers-custom/expected-bundle.js b/test/js/samples/event-handlers-custom/expected-bundle.js index 0cfb3a6cee..d6564452d8 100644 --- a/test/js/samples/event-handlers-custom/expected-bundle.js +++ b/test/js/samples/event-handlers-custom/expected-bundle.js @@ -144,7 +144,7 @@ var methods = { } }; -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var button, foo_handler; return { @@ -156,8 +156,7 @@ function create_main_fragment(component, state) { h: function hydrate() { foo_handler = foo.call(component, button, function(event) { - var state = component.get(); - component.foo( state.bar ); + component.foo( ctx.bar ); }); }, @@ -165,7 +164,9 @@ function create_main_fragment(component, state) { insertNode(button, target, anchor); }, - p: noop, + p: function(changed, _ctx) { + ctx = _ctx; + }, u: function unmount() { detachNode(button); diff --git a/test/js/samples/event-handlers-custom/expected.js b/test/js/samples/event-handlers-custom/expected.js index 3975641534..5c357c6e19 100644 --- a/test/js/samples/event-handlers-custom/expected.js +++ b/test/js/samples/event-handlers-custom/expected.js @@ -11,7 +11,7 @@ var methods = { } }; -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var button, foo_handler; return { @@ -23,8 +23,7 @@ function create_main_fragment(component, state) { h: function hydrate() { foo_handler = foo.call(component, button, function(event) { - var state = component.get(); - component.foo( state.bar ); + component.foo( ctx.bar ); }); }, @@ -32,7 +31,9 @@ function create_main_fragment(component, state) { insertNode(button, target, anchor); }, - p: noop, + p: function update(changed, _ctx) { + ctx = _ctx; + }, u: function unmount() { detachNode(button); diff --git a/test/js/samples/head-no-whitespace/expected-bundle.js b/test/js/samples/head-no-whitespace/expected-bundle.js index f812b7f6e2..25439d6ca5 100644 --- a/test/js/samples/head-no-whitespace/expected-bundle.js +++ b/test/js/samples/head-no-whitespace/expected-bundle.js @@ -135,7 +135,7 @@ var proto = { /* generated by Svelte vX.Y.Z */ -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var meta, meta_1; return { diff --git a/test/js/samples/head-no-whitespace/expected.js b/test/js/samples/head-no-whitespace/expected.js index 9818f42116..f22c973692 100644 --- a/test/js/samples/head-no-whitespace/expected.js +++ b/test/js/samples/head-no-whitespace/expected.js @@ -1,7 +1,7 @@ /* generated by Svelte vX.Y.Z */ import { appendNode, assign, createElement, detachNode, init, noop, proto } from "svelte/shared.js"; -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var meta, meta_1; return { diff --git a/test/js/samples/if-block-no-update/expected-bundle.js b/test/js/samples/if-block-no-update/expected-bundle.js index 3455491811..8386ba6b04 100644 --- a/test/js/samples/if-block-no-update/expected-bundle.js +++ b/test/js/samples/if-block-no-update/expected-bundle.js @@ -139,16 +139,16 @@ var proto = { /* generated by Svelte vX.Y.Z */ -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var if_block_anchor; - function select_block_type(state) { - if (state.foo) return create_if_block; + function select_block_type(ctx) { + if (ctx.foo) return create_if_block; return create_if_block_1; } - var current_block_type = select_block_type(state); - var if_block = current_block_type(component, state); + var current_block_type = select_block_type(ctx); + var if_block = current_block_type(component, ctx); return { c: function create() { @@ -161,11 +161,11 @@ function create_main_fragment(component, state) { insertNode(if_block_anchor, target, anchor); }, - p: function update(changed, state) { - if (current_block_type !== (current_block_type = select_block_type(state))) { + p: function update(changed, ctx) { + if (current_block_type !== (current_block_type = select_block_type(ctx))) { if_block.u(); if_block.d(); - if_block = current_block_type(component, state); + if_block = current_block_type(component, ctx); if_block.c(); if_block.m(if_block_anchor.parentNode, if_block_anchor); } @@ -183,7 +183,7 @@ function create_main_fragment(component, state) { } // (1:0) {#if foo} -function create_if_block(component, state) { +function create_if_block(component, ctx) { var p; return { @@ -205,7 +205,7 @@ function create_if_block(component, state) { } // (3:0) {:else} -function create_if_block_1(component, state) { +function create_if_block_1(component, ctx) { var p; return { diff --git a/test/js/samples/if-block-no-update/expected.js b/test/js/samples/if-block-no-update/expected.js index c06ff6ee67..6980164b8d 100644 --- a/test/js/samples/if-block-no-update/expected.js +++ b/test/js/samples/if-block-no-update/expected.js @@ -1,16 +1,16 @@ /* generated by Svelte vX.Y.Z */ import { assign, createComment, createElement, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var if_block_anchor; - function select_block_type(state) { - if (state.foo) return create_if_block; + function select_block_type(ctx) { + if (ctx.foo) return create_if_block; return create_if_block_1; } - var current_block_type = select_block_type(state); - var if_block = current_block_type(component, state); + var current_block_type = select_block_type(ctx); + var if_block = current_block_type(component, ctx); return { c: function create() { @@ -23,11 +23,11 @@ function create_main_fragment(component, state) { insertNode(if_block_anchor, target, anchor); }, - p: function update(changed, state) { - if (current_block_type !== (current_block_type = select_block_type(state))) { + p: function update(changed, ctx) { + if (current_block_type !== (current_block_type = select_block_type(ctx))) { if_block.u(); if_block.d(); - if_block = current_block_type(component, state); + if_block = current_block_type(component, ctx); if_block.c(); if_block.m(if_block_anchor.parentNode, if_block_anchor); } @@ -45,7 +45,7 @@ function create_main_fragment(component, state) { } // (1:0) {#if foo} -function create_if_block(component, state) { +function create_if_block(component, ctx) { var p; return { @@ -67,7 +67,7 @@ function create_if_block(component, state) { } // (3:0) {:else} -function create_if_block_1(component, state) { +function create_if_block_1(component, ctx) { var p; return { diff --git a/test/js/samples/if-block-simple/expected-bundle.js b/test/js/samples/if-block-simple/expected-bundle.js index 3e1925e2ea..4ee5eccd19 100644 --- a/test/js/samples/if-block-simple/expected-bundle.js +++ b/test/js/samples/if-block-simple/expected-bundle.js @@ -139,10 +139,10 @@ var proto = { /* generated by Svelte vX.Y.Z */ -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var if_block_anchor; - var if_block = (state.foo) && create_if_block(component, state); + var if_block = (ctx.foo) && create_if_block(component, ctx); return { c: function create() { @@ -155,10 +155,10 @@ function create_main_fragment(component, state) { insertNode(if_block_anchor, target, anchor); }, - p: function update(changed, state) { - if (state.foo) { + p: function update(changed, ctx) { + if (ctx.foo) { if (!if_block) { - if_block = create_if_block(component, state); + if_block = create_if_block(component, ctx); if_block.c(); if_block.m(if_block_anchor.parentNode, if_block_anchor); } @@ -181,7 +181,7 @@ function create_main_fragment(component, state) { } // (1:0) {#if foo} -function create_if_block(component, state) { +function create_if_block(component, ctx) { var p; return { diff --git a/test/js/samples/if-block-simple/expected.js b/test/js/samples/if-block-simple/expected.js index b3447471d3..4dcd6d3baa 100644 --- a/test/js/samples/if-block-simple/expected.js +++ b/test/js/samples/if-block-simple/expected.js @@ -1,10 +1,10 @@ /* generated by Svelte vX.Y.Z */ import { assign, createComment, createElement, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var if_block_anchor; - var if_block = (state.foo) && create_if_block(component, state); + var if_block = (ctx.foo) && create_if_block(component, ctx); return { c: function create() { @@ -17,10 +17,10 @@ function create_main_fragment(component, state) { insertNode(if_block_anchor, target, anchor); }, - p: function update(changed, state) { - if (state.foo) { + p: function update(changed, ctx) { + if (ctx.foo) { if (!if_block) { - if_block = create_if_block(component, state); + if_block = create_if_block(component, ctx); if_block.c(); if_block.m(if_block_anchor.parentNode, if_block_anchor); } @@ -43,7 +43,7 @@ function create_main_fragment(component, state) { } // (1:0) {#if foo} -function create_if_block(component, state) { +function create_if_block(component, ctx) { var p; return { diff --git a/test/js/samples/inline-style-optimized-multiple/expected-bundle.js b/test/js/samples/inline-style-optimized-multiple/expected-bundle.js index 77e36beceb..76833190e1 100644 --- a/test/js/samples/inline-style-optimized-multiple/expected-bundle.js +++ b/test/js/samples/inline-style-optimized-multiple/expected-bundle.js @@ -139,7 +139,7 @@ var proto = { /* generated by Svelte vX.Y.Z */ -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var div; return { @@ -149,21 +149,21 @@ function create_main_fragment(component, state) { }, h: function hydrate() { - setStyle(div, "color", state.color); - setStyle(div, "transform", "translate(" + state.x + "px," + state.y + "px)"); + setStyle(div, "color", ctx.color); + setStyle(div, "transform", "translate(" + ctx.x + "px," + ctx.y + "px)"); }, m: function mount(target, anchor) { insertNode(div, target, anchor); }, - p: function update(changed, state) { + p: function update(changed, ctx) { if (changed.color) { - setStyle(div, "color", state.color); + setStyle(div, "color", ctx.color); } if (changed.x || changed.y) { - setStyle(div, "transform", "translate(" + state.x + "px," + state.y + "px)"); + setStyle(div, "transform", "translate(" + ctx.x + "px," + ctx.y + "px)"); } }, diff --git a/test/js/samples/inline-style-optimized-multiple/expected.js b/test/js/samples/inline-style-optimized-multiple/expected.js index 7a94993b69..6533514de7 100644 --- a/test/js/samples/inline-style-optimized-multiple/expected.js +++ b/test/js/samples/inline-style-optimized-multiple/expected.js @@ -1,7 +1,7 @@ /* generated by Svelte vX.Y.Z */ import { assign, createElement, detachNode, init, insertNode, noop, proto, setStyle } from "svelte/shared.js"; -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var div; return { @@ -11,21 +11,21 @@ function create_main_fragment(component, state) { }, h: function hydrate() { - setStyle(div, "color", state.color); - setStyle(div, "transform", "translate(" + state.x + "px," + state.y + "px)"); + setStyle(div, "color", ctx.color); + setStyle(div, "transform", "translate(" + ctx.x + "px," + ctx.y + "px)"); }, m: function mount(target, anchor) { insertNode(div, target, anchor); }, - p: function update(changed, state) { + p: function update(changed, ctx) { if (changed.color) { - setStyle(div, "color", state.color); + setStyle(div, "color", ctx.color); } if (changed.x || changed.y) { - setStyle(div, "transform", "translate(" + state.x + "px," + state.y + "px)"); + setStyle(div, "transform", "translate(" + ctx.x + "px," + ctx.y + "px)"); } }, diff --git a/test/js/samples/inline-style-optimized-url/expected-bundle.js b/test/js/samples/inline-style-optimized-url/expected-bundle.js index 2850b95305..d1a1696790 100644 --- a/test/js/samples/inline-style-optimized-url/expected-bundle.js +++ b/test/js/samples/inline-style-optimized-url/expected-bundle.js @@ -139,7 +139,7 @@ var proto = { /* generated by Svelte vX.Y.Z */ -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var div; return { @@ -149,16 +149,16 @@ function create_main_fragment(component, state) { }, h: function hydrate() { - setStyle(div, "background", "url(data:image/png;base64," + state.data + ")"); + setStyle(div, "background", "url(data:image/png;base64," + ctx.data + ")"); }, m: function mount(target, anchor) { insertNode(div, target, anchor); }, - p: function update(changed, state) { + p: function update(changed, ctx) { if (changed.data) { - setStyle(div, "background", "url(data:image/png;base64," + state.data + ")"); + setStyle(div, "background", "url(data:image/png;base64," + ctx.data + ")"); } }, diff --git a/test/js/samples/inline-style-optimized-url/expected.js b/test/js/samples/inline-style-optimized-url/expected.js index 5a27ecfa49..333232fbb0 100644 --- a/test/js/samples/inline-style-optimized-url/expected.js +++ b/test/js/samples/inline-style-optimized-url/expected.js @@ -1,7 +1,7 @@ /* generated by Svelte vX.Y.Z */ import { assign, createElement, detachNode, init, insertNode, noop, proto, setStyle } from "svelte/shared.js"; -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var div; return { @@ -11,16 +11,16 @@ function create_main_fragment(component, state) { }, h: function hydrate() { - setStyle(div, "background", "url(data:image/png;base64," + state.data + ")"); + setStyle(div, "background", "url(data:image/png;base64," + ctx.data + ")"); }, m: function mount(target, anchor) { insertNode(div, target, anchor); }, - p: function update(changed, state) { + p: function update(changed, ctx) { if (changed.data) { - setStyle(div, "background", "url(data:image/png;base64," + state.data + ")"); + setStyle(div, "background", "url(data:image/png;base64," + ctx.data + ")"); } }, diff --git a/test/js/samples/inline-style-optimized/expected-bundle.js b/test/js/samples/inline-style-optimized/expected-bundle.js index eade3769ee..133aa3dd26 100644 --- a/test/js/samples/inline-style-optimized/expected-bundle.js +++ b/test/js/samples/inline-style-optimized/expected-bundle.js @@ -139,7 +139,7 @@ var proto = { /* generated by Svelte vX.Y.Z */ -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var div; return { @@ -149,16 +149,16 @@ function create_main_fragment(component, state) { }, h: function hydrate() { - setStyle(div, "color", state.color); + setStyle(div, "color", ctx.color); }, m: function mount(target, anchor) { insertNode(div, target, anchor); }, - p: function update(changed, state) { + p: function update(changed, ctx) { if (changed.color) { - setStyle(div, "color", state.color); + setStyle(div, "color", ctx.color); } }, diff --git a/test/js/samples/inline-style-optimized/expected.js b/test/js/samples/inline-style-optimized/expected.js index 86dabe8d21..e73cad385f 100644 --- a/test/js/samples/inline-style-optimized/expected.js +++ b/test/js/samples/inline-style-optimized/expected.js @@ -1,7 +1,7 @@ /* generated by Svelte vX.Y.Z */ import { assign, createElement, detachNode, init, insertNode, noop, proto, setStyle } from "svelte/shared.js"; -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var div; return { @@ -11,16 +11,16 @@ function create_main_fragment(component, state) { }, h: function hydrate() { - setStyle(div, "color", state.color); + setStyle(div, "color", ctx.color); }, m: function mount(target, anchor) { insertNode(div, target, anchor); }, - p: function update(changed, state) { + p: function update(changed, ctx) { if (changed.color) { - setStyle(div, "color", state.color); + setStyle(div, "color", ctx.color); } }, diff --git a/test/js/samples/inline-style-unoptimized/expected-bundle.js b/test/js/samples/inline-style-unoptimized/expected-bundle.js index 4b696f17af..0670680e56 100644 --- a/test/js/samples/inline-style-unoptimized/expected-bundle.js +++ b/test/js/samples/inline-style-unoptimized/expected-bundle.js @@ -139,7 +139,7 @@ var proto = { /* generated by Svelte vX.Y.Z */ -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var div, text, div_1, div_1_style_value; return { @@ -151,8 +151,8 @@ function create_main_fragment(component, state) { }, h: function hydrate() { - div.style.cssText = state.style; - div_1.style.cssText = div_1_style_value = "" + state.key + ": " + state.value; + div.style.cssText = ctx.style; + div_1.style.cssText = div_1_style_value = "" + ctx.key + ": " + ctx.value; }, m: function mount(target, anchor) { @@ -161,12 +161,12 @@ function create_main_fragment(component, state) { insertNode(div_1, target, anchor); }, - p: function update(changed, state) { + p: function update(changed, ctx) { if (changed.style) { - div.style.cssText = state.style; + div.style.cssText = ctx.style; } - if ((changed.key || changed.value) && div_1_style_value !== (div_1_style_value = "" + state.key + ": " + state.value)) { + if ((changed.key || changed.value) && div_1_style_value !== (div_1_style_value = "" + ctx.key + ": " + ctx.value)) { div_1.style.cssText = div_1_style_value; } }, diff --git a/test/js/samples/inline-style-unoptimized/expected.js b/test/js/samples/inline-style-unoptimized/expected.js index 7d7e933c12..1438b9d0fa 100644 --- a/test/js/samples/inline-style-unoptimized/expected.js +++ b/test/js/samples/inline-style-unoptimized/expected.js @@ -1,7 +1,7 @@ /* generated by Svelte vX.Y.Z */ import { assign, createElement, createText, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var div, text, div_1, div_1_style_value; return { @@ -13,8 +13,8 @@ function create_main_fragment(component, state) { }, h: function hydrate() { - div.style.cssText = state.style; - div_1.style.cssText = div_1_style_value = "" + state.key + ": " + state.value; + div.style.cssText = ctx.style; + div_1.style.cssText = div_1_style_value = "" + ctx.key + ": " + ctx.value; }, m: function mount(target, anchor) { @@ -23,12 +23,12 @@ function create_main_fragment(component, state) { insertNode(div_1, target, anchor); }, - p: function update(changed, state) { + p: function update(changed, ctx) { if (changed.style) { - div.style.cssText = state.style; + div.style.cssText = ctx.style; } - if ((changed.key || changed.value) && div_1_style_value !== (div_1_style_value = "" + state.key + ": " + state.value)) { + if ((changed.key || changed.value) && div_1_style_value !== (div_1_style_value = "" + ctx.key + ": " + ctx.value)) { div_1.style.cssText = div_1_style_value; } }, diff --git a/test/js/samples/input-without-blowback-guard/expected-bundle.js b/test/js/samples/input-without-blowback-guard/expected-bundle.js index 9101a81c6c..d536c4eb02 100644 --- a/test/js/samples/input-without-blowback-guard/expected-bundle.js +++ b/test/js/samples/input-without-blowback-guard/expected-bundle.js @@ -147,7 +147,7 @@ var proto = { /* generated by Svelte vX.Y.Z */ -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var input; function input_change_handler() { @@ -168,11 +168,11 @@ function create_main_fragment(component, state) { m: function mount(target, anchor) { insertNode(input, target, anchor); - input.checked = state.foo; + input.checked = ctx.foo; }, - p: function update(changed, state) { - input.checked = state.foo; + p: function update(changed, ctx) { + input.checked = ctx.foo; }, u: function unmount() { diff --git a/test/js/samples/input-without-blowback-guard/expected.js b/test/js/samples/input-without-blowback-guard/expected.js index ba99db4541..f5ad5369cc 100644 --- a/test/js/samples/input-without-blowback-guard/expected.js +++ b/test/js/samples/input-without-blowback-guard/expected.js @@ -1,7 +1,7 @@ /* generated by Svelte vX.Y.Z */ import { addListener, assign, createElement, detachNode, init, insertNode, proto, removeListener, setAttribute } from "svelte/shared.js"; -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var input; function input_change_handler() { @@ -22,11 +22,11 @@ function create_main_fragment(component, state) { m: function mount(target, anchor) { insertNode(input, target, anchor); - input.checked = state.foo; + input.checked = ctx.foo; }, - p: function update(changed, state) { - input.checked = state.foo; + p: function update(changed, ctx) { + input.checked = ctx.foo; }, u: function unmount() { diff --git a/test/js/samples/legacy-input-type/expected-bundle.js b/test/js/samples/legacy-input-type/expected-bundle.js index f07c5c914e..b4cd16281e 100644 --- a/test/js/samples/legacy-input-type/expected-bundle.js +++ b/test/js/samples/legacy-input-type/expected-bundle.js @@ -141,7 +141,7 @@ var proto = { /* generated by Svelte vX.Y.Z */ -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var input; return { diff --git a/test/js/samples/legacy-input-type/expected.js b/test/js/samples/legacy-input-type/expected.js index 2426c06481..e4c03516eb 100644 --- a/test/js/samples/legacy-input-type/expected.js +++ b/test/js/samples/legacy-input-type/expected.js @@ -1,7 +1,7 @@ /* generated by Svelte vX.Y.Z */ import { assign, createElement, detachNode, init, insertNode, noop, proto, setInputType } from "svelte/shared.js"; -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var input; return { diff --git a/test/js/samples/media-bindings/expected-bundle.js b/test/js/samples/media-bindings/expected-bundle.js index b2010075af..d997e2d595 100644 --- a/test/js/samples/media-bindings/expected-bundle.js +++ b/test/js/samples/media-bindings/expected-bundle.js @@ -151,7 +151,7 @@ var proto = { /* generated by Svelte vX.Y.Z */ -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var audio, audio_is_paused = true, audio_updating = false, audio_animationframe; function audio_timeupdate_handler() { @@ -194,28 +194,28 @@ function create_main_fragment(component, state) { h: function hydrate() { addListener(audio, "timeupdate", audio_timeupdate_handler); - if (!('played' in state && 'currentTime' in state)) component.root._beforecreate.push(audio_timeupdate_handler); + if (!('played' in ctx && 'currentTime' in ctx)) component.root._beforecreate.push(audio_timeupdate_handler); addListener(audio, "durationchange", audio_durationchange_handler); - if (!('duration' in state)) component.root._beforecreate.push(audio_durationchange_handler); + if (!('duration' in ctx)) component.root._beforecreate.push(audio_durationchange_handler); addListener(audio, "play", audio_play_pause_handler); addListener(audio, "pause", audio_play_pause_handler); addListener(audio, "progress", audio_progress_handler); - if (!('buffered' in state)) component.root._beforecreate.push(audio_progress_handler); + if (!('buffered' in ctx)) component.root._beforecreate.push(audio_progress_handler); addListener(audio, "loadedmetadata", audio_loadedmetadata_handler); - if (!('buffered' in state && 'seekable' in state)) component.root._beforecreate.push(audio_loadedmetadata_handler); + if (!('buffered' in ctx && 'seekable' in ctx)) component.root._beforecreate.push(audio_loadedmetadata_handler); addListener(audio, "volumechange", audio_volumechange_handler); }, m: function mount(target, anchor) { insertNode(audio, target, anchor); - audio.volume = state.volume; + audio.volume = ctx.volume; }, - p: function update(changed, state) { - if (!audio_updating && !isNaN(state.currentTime )) audio.currentTime = state.currentTime ; - if (!audio_updating && audio_is_paused !== (audio_is_paused = state.paused )) audio[audio_is_paused ? "pause" : "play"](); - if (!audio_updating && !isNaN(state.volume)) audio.volume = state.volume; + p: function update(changed, ctx) { + if (!audio_updating && !isNaN(ctx.currentTime )) audio.currentTime = ctx.currentTime ; + if (!audio_updating && audio_is_paused !== (audio_is_paused = ctx.paused )) audio[audio_is_paused ? "pause" : "play"](); + if (!audio_updating && !isNaN(ctx.volume)) audio.volume = ctx.volume; }, u: function unmount() { diff --git a/test/js/samples/media-bindings/expected.js b/test/js/samples/media-bindings/expected.js index a395dd4385..24b59d7c22 100644 --- a/test/js/samples/media-bindings/expected.js +++ b/test/js/samples/media-bindings/expected.js @@ -1,7 +1,7 @@ /* generated by Svelte vX.Y.Z */ import { addListener, assign, callAll, createElement, detachNode, init, insertNode, proto, removeListener, timeRangesToArray } from "svelte/shared.js"; -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var audio, audio_is_paused = true, audio_updating = false, audio_animationframe; function audio_timeupdate_handler() { @@ -44,28 +44,28 @@ function create_main_fragment(component, state) { h: function hydrate() { addListener(audio, "timeupdate", audio_timeupdate_handler); - if (!('played' in state && 'currentTime' in state)) component.root._beforecreate.push(audio_timeupdate_handler); + if (!('played' in ctx && 'currentTime' in ctx)) component.root._beforecreate.push(audio_timeupdate_handler); addListener(audio, "durationchange", audio_durationchange_handler); - if (!('duration' in state)) component.root._beforecreate.push(audio_durationchange_handler); + if (!('duration' in ctx)) component.root._beforecreate.push(audio_durationchange_handler); addListener(audio, "play", audio_play_pause_handler); addListener(audio, "pause", audio_play_pause_handler); addListener(audio, "progress", audio_progress_handler); - if (!('buffered' in state)) component.root._beforecreate.push(audio_progress_handler); + if (!('buffered' in ctx)) component.root._beforecreate.push(audio_progress_handler); addListener(audio, "loadedmetadata", audio_loadedmetadata_handler); - if (!('buffered' in state && 'seekable' in state)) component.root._beforecreate.push(audio_loadedmetadata_handler); + if (!('buffered' in ctx && 'seekable' in ctx)) component.root._beforecreate.push(audio_loadedmetadata_handler); addListener(audio, "volumechange", audio_volumechange_handler); }, m: function mount(target, anchor) { insertNode(audio, target, anchor); - audio.volume = state.volume; + audio.volume = ctx.volume; }, - p: function update(changed, state) { - if (!audio_updating && !isNaN(state.currentTime )) audio.currentTime = state.currentTime ; - if (!audio_updating && audio_is_paused !== (audio_is_paused = state.paused )) audio[audio_is_paused ? "pause" : "play"](); - if (!audio_updating && !isNaN(state.volume)) audio.volume = state.volume; + p: function update(changed, ctx) { + if (!audio_updating && !isNaN(ctx.currentTime )) audio.currentTime = ctx.currentTime ; + if (!audio_updating && audio_is_paused !== (audio_is_paused = ctx.paused )) audio[audio_is_paused ? "pause" : "play"](); + if (!audio_updating && !isNaN(ctx.volume)) audio.volume = ctx.volume; }, u: function unmount() { diff --git a/test/js/samples/non-imported-component/expected-bundle.js b/test/js/samples/non-imported-component/expected-bundle.js index 871f615eb9..d7e74b5a28 100644 --- a/test/js/samples/non-imported-component/expected-bundle.js +++ b/test/js/samples/non-imported-component/expected-bundle.js @@ -139,7 +139,7 @@ var proto = { -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var text; var imported = new Imported({ diff --git a/test/js/samples/non-imported-component/expected.js b/test/js/samples/non-imported-component/expected.js index c1637b7cc4..6edf88eaa3 100644 --- a/test/js/samples/non-imported-component/expected.js +++ b/test/js/samples/non-imported-component/expected.js @@ -4,7 +4,7 @@ import Imported from 'Imported.html'; -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var text; var imported = new Imported({ diff --git a/test/js/samples/setup-method/expected-bundle.js b/test/js/samples/setup-method/expected-bundle.js index 53edf878f8..83c58b1f41 100644 --- a/test/js/samples/setup-method/expected-bundle.js +++ b/test/js/samples/setup-method/expected-bundle.js @@ -139,7 +139,7 @@ function setup(Component) { Component.prototype.foo( 'baz' ); } -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { return { c: noop, diff --git a/test/js/samples/setup-method/expected.js b/test/js/samples/setup-method/expected.js index d39c4288e3..cb565b0f74 100644 --- a/test/js/samples/setup-method/expected.js +++ b/test/js/samples/setup-method/expected.js @@ -17,7 +17,7 @@ function setup(Component) { Component.prototype.foo( 'baz' ); } -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { return { c: noop, diff --git a/test/js/samples/ssr-no-oncreate-etc/expected-bundle.js b/test/js/samples/ssr-no-oncreate-etc/expected-bundle.js index b1d2e97e04..e2f68fda3c 100644 --- a/test/js/samples/ssr-no-oncreate-etc/expected-bundle.js +++ b/test/js/samples/ssr-no-oncreate-etc/expected-bundle.js @@ -28,10 +28,10 @@ SvelteComponent.render = function(state, options = {}) { }; }; -SvelteComponent._render = function(__result, state, options) { +SvelteComponent._render = function(__result, ctx, options) { __result.addComponent(SvelteComponent); - state = Object.assign({}, state); + ctx = Object.assign({}, ctx); return ``; }; diff --git a/test/js/samples/ssr-no-oncreate-etc/expected.js b/test/js/samples/ssr-no-oncreate-etc/expected.js index 0aec3a5874..5a2af8759f 100644 --- a/test/js/samples/ssr-no-oncreate-etc/expected.js +++ b/test/js/samples/ssr-no-oncreate-etc/expected.js @@ -32,10 +32,10 @@ SvelteComponent.render = function(state, options = {}) { }; } -SvelteComponent._render = function(__result, state, options) { +SvelteComponent._render = function(__result, ctx, options) { __result.addComponent(SvelteComponent); - state = Object.assign({}, state); + ctx = Object.assign({}, ctx); return ``; }; diff --git a/test/js/samples/ssr-preserve-comments/expected-bundle.js b/test/js/samples/ssr-preserve-comments/expected-bundle.js index 7ccd01cbef..06799a65da 100644 --- a/test/js/samples/ssr-preserve-comments/expected-bundle.js +++ b/test/js/samples/ssr-preserve-comments/expected-bundle.js @@ -25,10 +25,10 @@ SvelteComponent.render = function(state, options = {}) { }; }; -SvelteComponent._render = function(__result, state, options) { +SvelteComponent._render = function(__result, ctx, options) { __result.addComponent(SvelteComponent); - state = Object.assign({}, state); + ctx = Object.assign({}, ctx); return `
content
diff --git a/test/js/samples/ssr-preserve-comments/expected.js b/test/js/samples/ssr-preserve-comments/expected.js index a672879685..ccbadca003 100644 --- a/test/js/samples/ssr-preserve-comments/expected.js +++ b/test/js/samples/ssr-preserve-comments/expected.js @@ -28,10 +28,10 @@ SvelteComponent.render = function(state, options = {}) { }; } -SvelteComponent._render = function(__result, state, options) { +SvelteComponent._render = function(__result, ctx, options) { __result.addComponent(SvelteComponent); - state = Object.assign({}, state); + ctx = Object.assign({}, ctx); return `
content
diff --git a/test/js/samples/svg-title/expected-bundle.js b/test/js/samples/svg-title/expected-bundle.js index 5b9452eb77..35807ca053 100644 --- a/test/js/samples/svg-title/expected-bundle.js +++ b/test/js/samples/svg-title/expected-bundle.js @@ -143,7 +143,7 @@ var proto = { /* generated by Svelte vX.Y.Z */ -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var svg, title, text; return { diff --git a/test/js/samples/svg-title/expected.js b/test/js/samples/svg-title/expected.js index 3f7ea0b8e9..7c17e7ba96 100644 --- a/test/js/samples/svg-title/expected.js +++ b/test/js/samples/svg-title/expected.js @@ -1,7 +1,7 @@ /* generated by Svelte vX.Y.Z */ import { appendNode, assign, createSvgElement, createText, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var svg, title, text; return { diff --git a/test/js/samples/title/expected-bundle.js b/test/js/samples/title/expected-bundle.js index 1403bdadcd..131548dbe0 100644 --- a/test/js/samples/title/expected-bundle.js +++ b/test/js/samples/title/expected-bundle.js @@ -123,18 +123,18 @@ var proto = { /* generated by Svelte vX.Y.Z */ -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var title_value; - document.title = title_value = "a " + state.custom + " title"; + document.title = title_value = "a " + ctx.custom + " title"; return { c: noop, m: noop, - p: function update(changed, state) { - if ((changed.custom) && title_value !== (title_value = "a " + state.custom + " title")) { + p: function update(changed, ctx) { + if ((changed.custom) && title_value !== (title_value = "a " + ctx.custom + " title")) { document.title = title_value; } }, diff --git a/test/js/samples/title/expected.js b/test/js/samples/title/expected.js index 0e059bbb4c..12c18b0f8b 100644 --- a/test/js/samples/title/expected.js +++ b/test/js/samples/title/expected.js @@ -1,18 +1,18 @@ /* generated by Svelte vX.Y.Z */ import { assign, init, noop, proto } from "svelte/shared.js"; -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var title_value; - document.title = title_value = "a " + state.custom + " title"; + document.title = title_value = "a " + ctx.custom + " title"; return { c: noop, m: noop, - p: function update(changed, state) { - if ((changed.custom) && title_value !== (title_value = "a " + state.custom + " title")) { + p: function update(changed, ctx) { + if ((changed.custom) && title_value !== (title_value = "a " + ctx.custom + " title")) { document.title = title_value; } }, diff --git a/test/js/samples/use-elements-as-anchors/expected-bundle.js b/test/js/samples/use-elements-as-anchors/expected-bundle.js index 5554270e8b..bc3963e5ef 100644 --- a/test/js/samples/use-elements-as-anchors/expected-bundle.js +++ b/test/js/samples/use-elements-as-anchors/expected-bundle.js @@ -147,18 +147,18 @@ var proto = { /* generated by Svelte vX.Y.Z */ -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var div, text, p, text_2, text_3, text_4, p_1, text_6, text_8, if_block_4_anchor; - var if_block = (state.a) && create_if_block(component, state); + var if_block = (ctx.a) && create_if_block(component, ctx); - var if_block_1 = (state.b) && create_if_block_1(component, state); + var if_block_1 = (ctx.b) && create_if_block_1(component, ctx); - var if_block_2 = (state.c) && create_if_block_2(component, state); + var if_block_2 = (ctx.c) && create_if_block_2(component, ctx); - var if_block_3 = (state.d) && create_if_block_3(component, state); + var if_block_3 = (ctx.d) && create_if_block_3(component, ctx); - var if_block_4 = (state.e) && create_if_block_4(component, state); + var if_block_4 = (ctx.e) && create_if_block_4(component, ctx); return { c: function create() { @@ -199,10 +199,10 @@ function create_main_fragment(component, state) { insertNode(if_block_4_anchor, target, anchor); }, - p: function update(changed, state) { - if (state.a) { + p: function update(changed, ctx) { + if (ctx.a) { if (!if_block) { - if_block = create_if_block(component, state); + if_block = create_if_block(component, ctx); if_block.c(); if_block.m(div, text); } @@ -212,9 +212,9 @@ function create_main_fragment(component, state) { if_block = null; } - if (state.b) { + if (ctx.b) { if (!if_block_1) { - if_block_1 = create_if_block_1(component, state); + if_block_1 = create_if_block_1(component, ctx); if_block_1.c(); if_block_1.m(div, text_3); } @@ -224,9 +224,9 @@ function create_main_fragment(component, state) { if_block_1 = null; } - if (state.c) { + if (ctx.c) { if (!if_block_2) { - if_block_2 = create_if_block_2(component, state); + if_block_2 = create_if_block_2(component, ctx); if_block_2.c(); if_block_2.m(div, text_4); } @@ -236,9 +236,9 @@ function create_main_fragment(component, state) { if_block_2 = null; } - if (state.d) { + if (ctx.d) { if (!if_block_3) { - if_block_3 = create_if_block_3(component, state); + if_block_3 = create_if_block_3(component, ctx); if_block_3.c(); if_block_3.m(div, null); } @@ -248,9 +248,9 @@ function create_main_fragment(component, state) { if_block_3 = null; } - if (state.e) { + if (ctx.e) { if (!if_block_4) { - if_block_4 = create_if_block_4(component, state); + if_block_4 = create_if_block_4(component, ctx); if_block_4.c(); if_block_4.m(if_block_4_anchor.parentNode, if_block_4_anchor); } @@ -283,7 +283,7 @@ function create_main_fragment(component, state) { } // (2:1) {#if a} -function create_if_block(component, state) { +function create_if_block(component, ctx) { var p; return { @@ -305,7 +305,7 @@ function create_if_block(component, state) { } // (8:1) {#if b} -function create_if_block_1(component, state) { +function create_if_block_1(component, ctx) { var p; return { @@ -327,7 +327,7 @@ function create_if_block_1(component, state) { } // (12:1) {#if c} -function create_if_block_2(component, state) { +function create_if_block_2(component, ctx) { var p; return { @@ -349,7 +349,7 @@ function create_if_block_2(component, state) { } // (18:1) {#if d} -function create_if_block_3(component, state) { +function create_if_block_3(component, ctx) { var p; return { @@ -371,7 +371,7 @@ function create_if_block_3(component, state) { } // (25:0) {#if e} -function create_if_block_4(component, state) { +function create_if_block_4(component, ctx) { var p; return { diff --git a/test/js/samples/use-elements-as-anchors/expected.js b/test/js/samples/use-elements-as-anchors/expected.js index d9cff08d3f..26d1790205 100644 --- a/test/js/samples/use-elements-as-anchors/expected.js +++ b/test/js/samples/use-elements-as-anchors/expected.js @@ -1,18 +1,18 @@ /* generated by Svelte vX.Y.Z */ import { appendNode, assign, createComment, createElement, createText, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var div, text, p, text_2, text_3, text_4, p_1, text_6, text_8, if_block_4_anchor; - var if_block = (state.a) && create_if_block(component, state); + var if_block = (ctx.a) && create_if_block(component, ctx); - var if_block_1 = (state.b) && create_if_block_1(component, state); + var if_block_1 = (ctx.b) && create_if_block_1(component, ctx); - var if_block_2 = (state.c) && create_if_block_2(component, state); + var if_block_2 = (ctx.c) && create_if_block_2(component, ctx); - var if_block_3 = (state.d) && create_if_block_3(component, state); + var if_block_3 = (ctx.d) && create_if_block_3(component, ctx); - var if_block_4 = (state.e) && create_if_block_4(component, state); + var if_block_4 = (ctx.e) && create_if_block_4(component, ctx); return { c: function create() { @@ -53,10 +53,10 @@ function create_main_fragment(component, state) { insertNode(if_block_4_anchor, target, anchor); }, - p: function update(changed, state) { - if (state.a) { + p: function update(changed, ctx) { + if (ctx.a) { if (!if_block) { - if_block = create_if_block(component, state); + if_block = create_if_block(component, ctx); if_block.c(); if_block.m(div, text); } @@ -66,9 +66,9 @@ function create_main_fragment(component, state) { if_block = null; } - if (state.b) { + if (ctx.b) { if (!if_block_1) { - if_block_1 = create_if_block_1(component, state); + if_block_1 = create_if_block_1(component, ctx); if_block_1.c(); if_block_1.m(div, text_3); } @@ -78,9 +78,9 @@ function create_main_fragment(component, state) { if_block_1 = null; } - if (state.c) { + if (ctx.c) { if (!if_block_2) { - if_block_2 = create_if_block_2(component, state); + if_block_2 = create_if_block_2(component, ctx); if_block_2.c(); if_block_2.m(div, text_4); } @@ -90,9 +90,9 @@ function create_main_fragment(component, state) { if_block_2 = null; } - if (state.d) { + if (ctx.d) { if (!if_block_3) { - if_block_3 = create_if_block_3(component, state); + if_block_3 = create_if_block_3(component, ctx); if_block_3.c(); if_block_3.m(div, null); } @@ -102,9 +102,9 @@ function create_main_fragment(component, state) { if_block_3 = null; } - if (state.e) { + if (ctx.e) { if (!if_block_4) { - if_block_4 = create_if_block_4(component, state); + if_block_4 = create_if_block_4(component, ctx); if_block_4.c(); if_block_4.m(if_block_4_anchor.parentNode, if_block_4_anchor); } @@ -137,7 +137,7 @@ function create_main_fragment(component, state) { } // (2:1) {#if a} -function create_if_block(component, state) { +function create_if_block(component, ctx) { var p; return { @@ -159,7 +159,7 @@ function create_if_block(component, state) { } // (8:1) {#if b} -function create_if_block_1(component, state) { +function create_if_block_1(component, ctx) { var p; return { @@ -181,7 +181,7 @@ function create_if_block_1(component, state) { } // (12:1) {#if c} -function create_if_block_2(component, state) { +function create_if_block_2(component, ctx) { var p; return { @@ -203,7 +203,7 @@ function create_if_block_2(component, state) { } // (18:1) {#if d} -function create_if_block_3(component, state) { +function create_if_block_3(component, ctx) { var p; return { @@ -225,7 +225,7 @@ function create_if_block_3(component, state) { } // (25:0) {#if e} -function create_if_block_4(component, state) { +function create_if_block_4(component, ctx) { var p; return { diff --git a/test/js/samples/window-binding-scroll/expected-bundle.js b/test/js/samples/window-binding-scroll/expected-bundle.js index 704146c5a9..ffc59dacc5 100644 --- a/test/js/samples/window-binding-scroll/expected-bundle.js +++ b/test/js/samples/window-binding-scroll/expected-bundle.js @@ -143,7 +143,7 @@ var proto = { /* generated by Svelte vX.Y.Z */ -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var window_updating = false, clear_window_updating = function() { window_updating = false; }, window_updating_timeout, p, text, text_1; function onwindowscroll(event) { @@ -170,7 +170,7 @@ function create_main_fragment(component, state) { c: function create() { p = createElement("p"); text = createText("scrolled to "); - text_1 = createText(state.y); + text_1 = createText(ctx.y); }, m: function mount(target, anchor) { @@ -179,9 +179,9 @@ function create_main_fragment(component, state) { appendNode(text_1, p); }, - p: function update(changed, state) { + p: function update(changed, ctx) { if (changed.y) { - text_1.data = state.y; + text_1.data = ctx.y; } }, diff --git a/test/js/samples/window-binding-scroll/expected.js b/test/js/samples/window-binding-scroll/expected.js index d18b35687e..d3f6718dd6 100644 --- a/test/js/samples/window-binding-scroll/expected.js +++ b/test/js/samples/window-binding-scroll/expected.js @@ -1,7 +1,7 @@ /* generated by Svelte vX.Y.Z */ import { appendNode, assign, createElement, createText, detachNode, init, insertNode, proto } from "svelte/shared.js"; -function create_main_fragment(component, state) { +function create_main_fragment(component, ctx) { var window_updating = false, clear_window_updating = function() { window_updating = false; }, window_updating_timeout, p, text, text_1; function onwindowscroll(event) { @@ -28,7 +28,7 @@ function create_main_fragment(component, state) { c: function create() { p = createElement("p"); text = createText("scrolled to "); - text_1 = createText(state.y); + text_1 = createText(ctx.y); }, m: function mount(target, anchor) { @@ -37,9 +37,9 @@ function create_main_fragment(component, state) { appendNode(text_1, p); }, - p: function update(changed, state) { + p: function update(changed, ctx) { if (changed.y) { - text_1.data = state.y; + text_1.data = ctx.y; } },