diff --git a/README.md b/README.md index ef6f27b9ca6b..7dd794a837c3 100644 --- a/README.md +++ b/README.md @@ -76,14 +76,11 @@ The Svelte compiler optionally takes a second argument, an object of configurati | | **Values** | **Description** | **Default** | |---|---|---|---| -| `generate` | `'dom'`, `'ssr'` | Whether to generate JavaScript code intended for use on the client (`'dom'`), or for use in server-side rendering (`'ssr'`). | `'dom'` | +| `generate` | `'dom'`, `'ssr'`, `false` | Whether to generate JavaScript code intended for use on the client (`'dom'`), or for use in server-side rendering (`'ssr'`). If `false`, component will be parsed and validated but no code will be emitted | `'dom'` | | `dev` | `true`, `false` | Whether to enable run-time checks in the compiled component. These are helpful during development, but slow your component down. | `false` | | `css` | `true`, `false` | Whether to include code to inject your component's styles into the DOM. | `true` | -| `store` | `true`, `false` | Whether to support store integration on the compiled component. | `false` | | `hydratable` | `true`, `false` | Whether to support hydration on the compiled component. | `false` | | `customElement` | `true`, `false`, `{ tag, props }` | Whether to compile this component to a custom element. If `tag`/`props` are passed, compiles to a custom element and overrides the values exported by the component. | `false` | -| `cascade` | `true`, `false` | Whether to cascade all of the component's styles to child components. If `false`, only selectors wrapped in `:global(...)` and keyframe IDs beginning with `-global-` are cascaded. | `true` | -| `parser` | `v2` | Opt in to [v2 syntax](https://github.com/sveltejs/svelte-upgrade#svelte-v2-syntax-changes). | `undefined` | | `bind` | `boolean` | If `false`, disallows `bind:` directives | `true` | | | | | | `shared` | `true`, `false`, `string` | Whether to import various helpers from a shared external library. When you have a project with multiple components, this reduces the overall size of your JavaScript bundle, at the expense of having immediately-usable component. You can pass a string of the module path to use, or `true` will import from `'svelte/shared.js'`. | `false` | @@ -94,7 +91,7 @@ The Svelte compiler optionally takes a second argument, an object of configurati | `filename` | `string` | The filename to use in sourcemaps and compiler error and warning messages. | `'SvelteComponent.html'` | | `amd`.`id` | `string` | The AMD module ID to use for the `'amd'` and `'umd'` output formats. | `undefined` | | `globals` | `object`, `function` | When outputting to the `'umd'`, `'iife'` or `'eval'` formats, an object or function mapping the names of imported dependencies to the names of global variables. | `{}` | -| `preserveComments` | `boolean` | Include comments in rendering. Currently, only applies to SSR rendering | `false` | +| `preserveComments` | `boolean` | Include comments in rendering. Currently, only applies to SSR rendering | `false` | | | | | | `onerror` | `function` | Specify a callback for when Svelte encounters an error while compiling the component. Passed two arguments: the error object, and another function that is Svelte's default onerror handling. | (exception is thrown) | | `onwarn` | `function` | Specify a callback for when Svelte encounters a non-fatal warning while compiling the component. Passed two arguments: the warning object, and another function that is Svelte's default onwarn handling. | (warning is logged to console) | diff --git a/package.json b/package.json index 866b3e4b0742..e643c6e29695 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "glob": "^7.1.1", "is-reference": "^1.1.0", "jsdom": "^11.6.1", - "locate-character": "^2.0.0", + "locate-character": "^2.0.5", "magic-string": "^0.22.3", "mocha": "^3.2.0", "nightmare": "^2.10.0", diff --git a/src/Stats.ts b/src/Stats.ts index 873ae15b460e..c1a4b9b64281 100644 --- a/src/Stats.ts +++ b/src/Stats.ts @@ -26,6 +26,8 @@ function collapseTimings(timings) { } export default class Stats { + onwarn: (warning: Warning) => void; + startTime: number; currentTiming: Timing; currentChildren: Timing[]; @@ -33,11 +35,15 @@ export default class Stats { stack: Timing[]; warnings: Warning[]; - constructor() { + constructor({ onwarn }: { + onwarn: (warning: Warning) => void + }) { this.startTime = now(); this.stack = []; this.currentChildren = this.timings = []; + this.onwarn = onwarn; + this.warnings = []; } @@ -99,4 +105,9 @@ export default class Stats { hooks }; } + + warn(warning) { + this.warnings.push(warning); + this.onwarn(warning); + } } \ No newline at end of file diff --git a/src/css/Stylesheet.ts b/src/css/Stylesheet.ts index 464dbd2500c6..4a3630f30044 100644 --- a/src/css/Stylesheet.ts +++ b/src/css/Stylesheet.ts @@ -31,18 +31,18 @@ class Rule { return this.selectors.some(s => s.used); } - minify(code: MagicString, cascade: boolean, dev: boolean) { + minify(code: MagicString, dev: boolean) { let c = this.node.start; let started = false; this.selectors.forEach((selector, i) => { - if (cascade || selector.used) { + if (selector.used) { const separator = started ? ',' : ''; if ((selector.node.start - c) > separator.length) { code.overwrite(c, selector.node.start, separator); } - if (!cascade) selector.minify(code); + selector.minify(code); c = selector.node.end; started = true; @@ -66,39 +66,12 @@ class Rule { code.remove(c, this.node.block.end - 1); } - transform(code: MagicString, id: string, keyframes: Map, cascade: boolean) { + transform(code: MagicString, id: string, keyframes: Map) { if (this.parent && this.parent.node.type === 'Atrule' && this.parent.node.name === 'keyframes') return true; const attr = `.${id}`; - if (cascade) { - this.selectors.forEach(selector => { - // TODO disable cascading (without :global(...)) in v2 - const { start, end, children } = selector.node; - - const css = code.original; - const selectorString = css.slice(start, end); - - const firstToken = children[0]; - - let transformed; - - if (firstToken.type === 'TypeSelector') { - const insert = firstToken.end; - const head = firstToken.name === '*' ? '' : css.slice(start, insert); - const tail = css.slice(insert, end); - - transformed = `${head}${attr}${tail},${attr} ${selectorString}`; - } else { - transformed = `${attr}${selectorString},${attr} ${selectorString}`; - } - - code.overwrite(start, end, transformed); - }); - } else { - this.selectors.forEach(selector => selector.transform(code, attr)); - } - + this.selectors.forEach(selector => selector.transform(code, attr)); this.declarations.forEach(declaration => declaration.transform(code, keyframes)); } @@ -182,7 +155,7 @@ class Atrule { return true; // TODO } - minify(code: MagicString, cascade: boolean, dev: boolean) { + minify(code: MagicString, dev: boolean) { if (this.node.name === 'media') { const expressionChar = code.original[this.node.expression.start]; let c = this.node.start + (expressionChar === '(' ? 6 : 7); @@ -215,9 +188,9 @@ class Atrule { let c = this.node.block.start + 1; this.children.forEach(child => { - if (cascade || child.isUsed(dev)) { + if (child.isUsed(dev)) { code.remove(c, child.node.start); - child.minify(code, cascade, dev); + child.minify(code, dev); c = child.node.end; } }); @@ -226,7 +199,7 @@ class Atrule { } } - transform(code: MagicString, id: string, keyframes: Map, cascade: boolean) { + transform(code: MagicString, id: string, keyframes: Map) { if (this.node.name === 'keyframes') { this.node.expression.children.forEach(({ type, name, start, end }: Node) => { if (type === 'Identifier') { @@ -240,7 +213,7 @@ class Atrule { } this.children.forEach(child => { - child.transform(code, id, keyframes, cascade); + child.transform(code, id, keyframes); }) } @@ -264,7 +237,6 @@ const keys = {}; export default class Stylesheet { source: string; parsed: Parsed; - cascade: boolean; filename: string; dev: boolean; @@ -276,10 +248,9 @@ export default class Stylesheet { nodesWithCssClass: Set; - constructor(source: string, parsed: Parsed, filename: string, cascade: boolean, dev: boolean) { + constructor(source: string, parsed: Parsed, filename: string, dev: boolean) { this.source = source; this.parsed = parsed; - this.cascade = cascade; this.filename = filename; this.dev = dev; @@ -356,11 +327,6 @@ export default class Stylesheet { if (parent.type === 'Element') stack.unshift(parent); } - if (this.cascade) { - if (stack.length === 0) this.nodesWithCssClass.add(node); - return; - } - for (let i = 0; i < this.children.length; i += 1) { const child = this.children[i]; child.apply(node, stack); @@ -389,15 +355,15 @@ export default class Stylesheet { if (shouldTransformSelectors) { this.children.forEach((child: (Atrule|Rule)) => { - child.transform(code, this.id, this.keyframes, this.cascade); + child.transform(code, this.id, this.keyframes); }); } let c = 0; this.children.forEach(child => { - if (this.cascade || child.isUsed(this.dev)) { + if (child.isUsed(this.dev)) { code.remove(c, child.node.start); - child.minify(code, this.cascade, this.dev); + child.minify(code, this.dev); c = child.node.end; } }); @@ -421,27 +387,27 @@ export default class Stylesheet { } warnOnUnusedSelectors(onwarn: (warning: Warning) => void) { - if (this.cascade) return; - let locator; const handler = (selector: Selector) => { const pos = selector.node.start; - if (!locator) locator = getLocator(this.source); - const { line, column } = locator(pos); + if (!locator) locator = getLocator(this.source, { offsetLine: 1 }); + const start = locator(pos); + const end = locator(selector.node.end); - const frame = getCodeFrame(this.source, line, column); + const frame = getCodeFrame(this.source, start.line - 1, start.column); const message = `Unused CSS selector`; onwarn({ code: `css-unused-selector`, message, frame, - loc: { line: line + 1, column }, + start, + end, pos, filename: this.filename, - toString: () => `${message} (${line + 1}:${column})\n${frame}`, + toString: () => `${message} (${start.line}:${start.column})\n${frame}`, }); }; diff --git a/src/generators/Generator.ts b/src/generators/Generator.ts index 474b32a9c0ab..0b9b2eee9a67 100644 --- a/src/generators/Generator.ts +++ b/src/generators/Generator.ts @@ -5,7 +5,6 @@ import { getLocator } from 'locate-character'; import Stats from '../Stats'; import deindent from '../utils/deindent'; import CodeBuilder from '../utils/CodeBuilder'; -import getCodeFrame from '../utils/getCodeFrame'; import flattenReference from '../utils/flattenReference'; import reservedNames from '../utils/reservedNames'; import namespaces from '../utils/namespaces'; @@ -84,7 +83,6 @@ export default class Generator { source: string; name: string; options: CompileOptions; - v2: boolean; customElement: CustomElementOptions; tag: string; @@ -95,6 +93,7 @@ export default class Generator { helpers: Set; components: Set; events: Set; + methods: Set; transitions: Set; actions: Set; importedComponents: Map; @@ -133,8 +132,6 @@ export default class Generator { stats.start('compile'); this.stats = stats; - this.v2 = options.parser === 'v2'; - this.ast = clone(parsed); this.parsed = parsed; @@ -145,6 +142,7 @@ export default class Generator { this.helpers = new Set(); this.components = new Set(); this.events = new Set(); + this.methods = new Set(); this.transitions = new Set(); this.actions = new Set(); this.importedComponents = new Map(); @@ -369,31 +367,13 @@ export default class Generator { }) }; - Object.getOwnPropertyNames(String.prototype).forEach(name => { - const descriptor = Object.getOwnPropertyDescriptor(String.prototype, name); - if (typeof descriptor.value === 'function') { - Object.defineProperty(css, name, { - value: (...args) => { - return css.code === null - ? null - : css.code[name].call(css.code, ...args); - } - }); - } - }); - this.stats.stop('compile'); return { ast: this.ast, js, css, - stats: this.stats.render(this), - - // TODO deprecate - code: js.code, - map: js.map, - cssMap: css.map + stats: this.stats.render(this) }; } @@ -441,6 +421,7 @@ export default class Generator { code, source, computations, + methods, templateProperties, imports } = this; @@ -578,9 +559,7 @@ export default class Generator { const key = getName(prop.key); const value = prop.value; - const deps = this.v2 - ? value.params[0].properties.map(prop => prop.key.name) - : value.params.map(param => param.type === 'AssignmentPattern' ? param.left.name : param.name); + const deps = value.params[0].properties.map(prop => prop.key.name); deps.forEach(dep => { this.expectedProperties.add(dep); @@ -632,6 +611,10 @@ export default class Generator { if (templateProperties.methods && dom) { addDeclaration('methods', templateProperties.methods.value); + + templateProperties.methods.value.properties.forEach(prop => { + this.methods.add(prop.key.name); + }); } if (templateProperties.namespace) { @@ -639,12 +622,10 @@ export default class Generator { this.namespace = namespaces[ns] || ns; } - if (templateProperties.onrender) templateProperties.oncreate = templateProperties.onrender; // remove after v2 if (templateProperties.oncreate && dom) { addDeclaration('oncreate', templateProperties.oncreate.value); } - if (templateProperties.onteardown) templateProperties.ondestroy = templateProperties.onteardown; // remove after v2 if (templateProperties.ondestroy && dom) { addDeclaration('ondestroy', templateProperties.ondestroy.value); } @@ -802,7 +783,7 @@ export default class Generator { node.generator = generator; - if (node.type === 'Element' && (node.name === ':Component' || node.name === ':Self' || node.name === 'svelte:component' || node.name === 'svelte:self' || generator.components.has(node.name))) { + if (node.type === 'Element' && (node.name === 'svelte:component' || node.name === 'svelte:self' || generator.components.has(node.name))) { node.type = 'Component'; Object.setPrototypeOf(node, nodes.Component.prototype); } else if (node.type === 'Element' && node.name === 'title' && parentIsHead(parent)) { // TODO do this in parse? @@ -886,7 +867,7 @@ export default class Generator { this.skip(); } - if (node.type === 'Component' && (node.name === ':Component' || node.name === 'svelte:component')) { + if (node.type === 'Component' && node.name === 'svelte:component') { node.metadata = contextualise(node.expression, contextDependencies, indexes, false); } diff --git a/src/generators/dom/index.ts b/src/generators/dom/index.ts index eb7533187c8e..9ae999d6695d 100644 --- a/src/generators/dom/index.ts +++ b/src/generators/dom/index.ts @@ -47,7 +47,7 @@ export class DomGenerator extends Generator { this.legacy = options.legacy; this.needsEncapsulateHelper = false; - // initial values for e.g. window.innerWidth, if there's a <:Window> meta tag + // initial values for e.g. window.innerWidth, if there's a meta tag this.metaBindings = []; } } @@ -89,7 +89,7 @@ export default function dom( }); if (generator.readonly.has(key)) { - // <:Window> bindings + // bindings throw new Error( `Cannot have a computed value '${key}' that clashes with a read-only property` ); @@ -99,11 +99,7 @@ export default function dom( const condition = `${deps.map(dep => `changed.${dep}`).join(' || ')}`; - const call = generator.v2 - ? `%computed-${key}(state)` - : `%computed-${key}(${deps.map(dep => `state.${dep}`).join(', ')})`; - - const statement = `if (this._differs(state.${key}, (state.${key} = ${call}))) changed.${key} = true;`; + const statement = `if (this._differs(state.${key}, (state.${key} = %computed-${key}(state)))) changed.${key} = true;`; computationBuilder.addConditional(condition, statement); }); @@ -143,8 +139,8 @@ export default function dom( ? `@proto` : deindent` { - ${['destroy', 'get', 'fire', 'observe', 'on', 'set', 'teardown', '_set', '_mount', '_unmount', '_differs'] - .map(n => `${n}: @${n === 'teardown' ? 'destroy' : n}`) + ${['destroy', 'get', 'fire', 'on', 'set', '_set', '_mount', '_unmount', '_differs'] + .map(n => `${n}: @${n}`) .join(',\n')} }`; @@ -153,7 +149,7 @@ export default function dom( // generate initial state object const expectedProperties = Array.from(generator.expectedProperties); const globals = expectedProperties.filter(prop => globalWhitelist.has(prop)); - const storeProps = options.store || templateProperties.store ? expectedProperties.filter(prop => prop[0] === '$') : []; + const storeProps = expectedProperties.filter(prop => prop[0] === '$'); const initialState = []; if (globals.length > 0) { @@ -294,7 +290,7 @@ export default function dom( ${props.map(prop => deindent` get ${prop}() { - return this.get('${prop}'); + return this.get().${prop}; } set ${prop}(value) { diff --git a/src/generators/nodes/Binding.ts b/src/generators/nodes/Binding.ts index f1725a6d731d..1ac182102b2e 100644 --- a/src/generators/nodes/Binding.ts +++ b/src/generators/nodes/Binding.ts @@ -159,12 +159,8 @@ function getEventHandler( dependencies: string[], value: string, ) { - let storeDependencies = []; - - if (generator.options.store) { - storeDependencies = dependencies.filter(prop => prop[0] === '$').map(prop => prop.slice(1)); - dependencies = dependencies.filter(prop => prop[0] !== '$'); - } + const storeDependencies = dependencies.filter(prop => prop[0] === '$').map(prop => prop.slice(1)); + dependencies = dependencies.filter(prop => prop[0] !== '$'); if (block.contexts.has(name)) { const tail = attribute.value.type === 'MemberExpression' @@ -207,7 +203,7 @@ function getEventHandler( let props; let storeProps; - if (generator.options.store && name[0] === '$') { + if (name[0] === '$') { props = []; storeProps = [`${name.slice(1)}: ${value}`]; } else { diff --git a/src/generators/nodes/Component.ts b/src/generators/nodes/Component.ts index 7f441c024f3f..d7bd3d442f94 100644 --- a/src/generators/nodes/Component.ts +++ b/src/generators/nodes/Component.ts @@ -45,8 +45,8 @@ export default class Component extends Node { this.var = block.getUniqueName( ( - (this.name === ':Self' || this.name === 'svelte:self') ? this.generator.name : - (this.name === ':Component' || this.name === 'svelte:component') ? 'switch_instance' : + this.name === 'svelte:self' ? this.generator.name : + this.name === 'svelte:component' ? 'switch_instance' : this.name ).toLowerCase() ); @@ -73,11 +73,11 @@ export default class Component extends Node { const componentInitProperties = [`root: #component.root`]; if (this.children.length > 0) { - const slots = Array.from(this._slots).map(name => `${quoteIfNecessary(name, generator.legacy)}: @createFragment()`); + const slots = Array.from(this._slots).map(name => `${quoteIfNecessary(name)}: @createFragment()`); componentInitProperties.push(`slots: { ${slots.join(', ')} }`); this.children.forEach((child: Node) => { - child.build(block, `${this.var}._slotted${generator.legacy ? `["default"]` : `.default`}`, 'nodes'); + child.build(block, `${this.var}._slotted.default`, 'nodes'); }); } @@ -139,7 +139,7 @@ export default class Component extends Node { const condition = dependencies && dependencies.map(d => `changed.${d}`).join(' || '); changes.push(condition ? `${condition} && ${value}` : value); } else { - const obj = `{ ${quoteIfNecessary(name, this.generator.legacy)}: ${value} }`; + const obj = `{ ${quoteIfNecessary(name)}: ${value} }`; initialProps.push(obj); const condition = dependencies && dependencies.map(d => `changed.${d}`).join(' || '); @@ -217,7 +217,7 @@ export default class Component extends Node { ${binding.dependencies .map((name: string) => { - const isStoreProp = generator.options.store && name[0] === '$'; + const isStoreProp = name[0] === '$'; const prop = isStoreProp ? name.slice(1) : name; const newState = isStoreProp ? 'newStoreState' : 'newState'; @@ -230,7 +230,7 @@ export default class Component extends Node { } else { - const isStoreProp = generator.options.store && key[0] === '$'; + const isStoreProp = key[0] === '$'; const prop = isStoreProp ? key.slice(1) : key; const newState = isStoreProp ? 'newStoreState' : 'newState'; @@ -293,7 +293,7 @@ export default class Component extends Node { `; } - if (this.name === ':Component' || this.name === 'svelte:component') { + if (this.name === 'svelte:component') { const switch_value = block.getUniqueName('switch_value'); const switch_props = block.getUniqueName('switch_props'); @@ -387,7 +387,7 @@ export default class Component extends Node { block.builders.destroy.addLine(`if (${name}) ${name}.destroy(false);`); } else { - const expression = (this.name === ':Self' || this.name === 'svelte:self') + const expression = this.name === 'svelte:self' ? generator.name : `%components-${this.name}`; @@ -440,7 +440,7 @@ export default class Component extends Node { } remount(name: string) { - return `${this.var}._mount(${name}._slotted${this.generator.legacy ? `["default"]` : `.default`}, null);`; + return `${this.var}._mount(${name}._slotted.default, null);`; } } diff --git a/src/generators/nodes/EachBlock.ts b/src/generators/nodes/EachBlock.ts index 71ca47aa7e74..e74b8a01c2da 100644 --- a/src/generators/nodes/EachBlock.ts +++ b/src/generators/nodes/EachBlock.ts @@ -455,6 +455,6 @@ export default class EachBlock extends Node { remount(name: string) { // TODO consider keyed blocks - return `for (var #i = 0; #i < ${this.iterations}.length; #i += 1) ${this.iterations}[#i].m(${name}._slotted${this.generator.legacy ? `["default"]` : `.default`}, null);`; + return `for (var #i = 0; #i < ${this.iterations}.length; #i += 1) ${this.iterations}[#i].m(${name}._slotted.default, null);`; } } diff --git a/src/generators/nodes/Element.ts b/src/generators/nodes/Element.ts index d9f4e8f97444..0bc180e8d1f2 100644 --- a/src/generators/nodes/Element.ts +++ b/src/generators/nodes/Element.ts @@ -461,7 +461,7 @@ export default class Element extends Node { if (attr.type === 'Attribute') { const { dynamic, value, dependencies } = mungeAttribute(attr, block); - const snippet = `{ ${quoteIfNecessary(attr.name, this.generator.legacy)}: ${value} }`; + const snippet = `{ ${quoteIfNecessary(attr.name)}: ${value} }`; initialProps.push(snippet); const condition = dependencies && dependencies.map(d => `changed.${d}`).join(' || '); @@ -519,10 +519,19 @@ export default class Element extends Node { if (!validCalleeObjects.has(flattened.name)) { // allow event.stopPropagation(), this.select() etc // TODO verify that it's a valid callee (i.e. built-in or declared method) - generator.code.prependRight( - attribute.expression.start, - `${block.alias('component')}.` - ); + if (flattened.name[0] === '$' && !generator.methods.has(flattened.name)) { + generator.code.overwrite( + attribute.expression.start, + attribute.expression.start + 1, + `${block.alias('component')}.store.` + ); + } else { + generator.code.prependRight( + attribute.expression.start, + `${block.alias('component')}.` + ); + } + if (shouldHoist) eventHandlerUsesComponent = true; // this feels a bit hacky but it works! } @@ -580,16 +589,8 @@ export default class Element extends Node { }); `); - if (generator.options.dev) { - block.builders.hydrate.addBlock(deindent` - if (${handlerName}.teardown) { - console.warn("Return 'destroy()' from custom event handlers. Returning 'teardown()' has been deprecated and will be unsupported in Svelte 2"); - } - `); - } - block.builders.destroy.addLine(deindent` - ${handlerName}[${handlerName}.destroy ? 'destroy' : 'teardown'](); + ${handlerName}.destroy(); `); } else { const handler = deindent` @@ -789,7 +790,7 @@ export default class Element extends Node { return `@appendNode(${this.var}, ${name}._slotted.${this.getStaticAttributeValue('slot')});`; } - return `@appendNode(${this.var}, ${name}._slotted${this.generator.legacy ? `["default"]` : `.default`});`; + return `@appendNode(${this.var}, ${name}._slotted.default);`; } addCssClass() { @@ -839,7 +840,7 @@ function getClaimStatement( ) { const attributes = node.attributes .filter((attr: Node) => attr.type === 'Attribute') - .map((attr: Node) => `${quoteProp(attr.name, generator.legacy)}: true`) + .map((attr: Node) => `${quoteIfNecessary(attr.name)}: true`) .join(', '); const name = namespace ? node.name : node.name.toUpperCase(); @@ -849,13 +850,6 @@ function getClaimStatement( : `{}`}, ${namespace === namespaces.svg ? true : false})`; } -function quoteProp(name: string, legacy: boolean) { - const isLegacyPropName = legacy && reservedNames.has(name); - - if (/[^a-zA-Z_$0-9]/.test(name) || isLegacyPropName) return `"${name}"`; - return name; -} - function stringifyAttributeValue(value: Node | true) { if (value === true) return ''; if (value.length === 0) return `=""`; diff --git a/src/generators/nodes/MustacheTag.ts b/src/generators/nodes/MustacheTag.ts index 7960f069490f..06c854813628 100644 --- a/src/generators/nodes/MustacheTag.ts +++ b/src/generators/nodes/MustacheTag.ts @@ -28,6 +28,6 @@ export default class MustacheTag extends Tag { } remount(name: string) { - return `@appendNode(${this.var}, ${name}._slotted${this.generator.legacy ? `["default"]` : `.default`});`; + return `@appendNode(${this.var}, ${name}._slotted.default);`; } } \ No newline at end of file diff --git a/src/generators/nodes/RawMustacheTag.ts b/src/generators/nodes/RawMustacheTag.ts index 0d01135fa744..0b7f13642692 100644 --- a/src/generators/nodes/RawMustacheTag.ts +++ b/src/generators/nodes/RawMustacheTag.ts @@ -91,6 +91,6 @@ export default class RawMustacheTag extends Tag { } remount(name: string) { - return `@appendNode(${this.var}, ${name}._slotted${this.generator.legacy ? `["default"]` : `.default`});`; + return `@appendNode(${this.var}, ${name}._slotted.default);`; } } \ No newline at end of file diff --git a/src/generators/nodes/Slot.ts b/src/generators/nodes/Slot.ts index dcb1f9ef8c2a..86b1625e69f4 100644 --- a/src/generators/nodes/Slot.ts +++ b/src/generators/nodes/Slot.ts @@ -37,7 +37,7 @@ export default class Slot extends Element { generator.slots.add(slotName); const content_name = block.getUniqueName(`slot_content_${slotName}`); - const prop = !isValidIdentifier(slotName) || (generator.legacy && reservedNames.has(slotName)) ? `["${slotName}"]` : `.${slotName}`; + const prop = !isValidIdentifier(slotName) ? `["${slotName}"]` : `.${slotName}`; block.addVariable(content_name, `#component._slotted${prop}`); const needsAnchorBefore = this.prev ? this.prev.type !== 'Element' : !parentNode; diff --git a/src/generators/nodes/Text.ts b/src/generators/nodes/Text.ts index c1e401a6653d..457c8538cab7 100644 --- a/src/generators/nodes/Text.ts +++ b/src/generators/nodes/Text.ts @@ -60,6 +60,6 @@ export default class Text extends Node { } remount(name: string) { - return `@appendNode(${this.var}, ${name}._slotted${this.generator.legacy ? `["default"]` : `.default`});`; + return `@appendNode(${this.var}, ${name}._slotted.default);`; } } \ No newline at end of file diff --git a/src/generators/nodes/Window.ts b/src/generators/nodes/Window.ts index 40138913e67c..38a38c10843f 100644 --- a/src/generators/nodes/Window.ts +++ b/src/generators/nodes/Window.ts @@ -86,16 +86,8 @@ export default class Window extends Node { }); `); - if (generator.options.dev) { - block.builders.hydrate.addBlock(deindent` - if (${handlerName}.teardown) { - console.warn("Return 'destroy()' from custom event handlers. Returning 'teardown()' has been deprecated and will be unsupported in Svelte 2"); - } - `); - } - block.builders.destroy.addLine(deindent` - ${handlerName}[${handlerName}.destroy ? 'destroy' : 'teardown'](); + ${handlerName}.destroy(); `); } else { block.builders.init.addBlock(deindent` @@ -180,41 +172,23 @@ export default class Window extends Node { }); // special case... might need to abstract this out if we add more special cases - if (bindings.scrollX && bindings.scrollY) { - const observerCallback = block.getUniqueName(`scrollobserver`); - - block.builders.init.addBlock(deindent` - function ${observerCallback}() { - ${lock} = true; - clearTimeout(${timeout}); - var x = ${bindings.scrollX - ? `#component.get("${bindings.scrollX}")` - : `window.pageXOffset`}; - var y = ${bindings.scrollY - ? `#component.get("${bindings.scrollY}")` - : `window.pageYOffset`}; - window.scrollTo(x, y); - ${timeout} = setTimeout(${clear}, 100); - } - `); - - if (bindings.scrollX) - block.builders.init.addLine( - `#component.observe("${bindings.scrollX}", ${observerCallback});` - ); - if (bindings.scrollY) - block.builders.init.addLine( - `#component.observe("${bindings.scrollY}", ${observerCallback});` - ); - } else if (bindings.scrollX || bindings.scrollY) { - const isX = !!bindings.scrollX; - + if (bindings.scrollX || bindings.scrollY) { block.builders.init.addBlock(deindent` - #component.observe("${bindings.scrollX || bindings.scrollY}", function(${isX ? 'x' : 'y'}) { - ${lock} = true; - clearTimeout(${timeout}); - window.scrollTo(${isX ? 'x, window.pageYOffset' : 'window.pageXOffset, y'}); - ${timeout} = setTimeout(${clear}, 100); + #component.on("state", ({ changed, current }) => { + if (${ + [bindings.scrollX, bindings.scrollY].map( + binding => binding && `changed["${binding}"]` + ).filter(Boolean).join(' || ') + }) { + ${lock} = true; + clearTimeout(${timeout}); + window.scrollTo(${ + bindings.scrollX ? `current["${bindings.scrollX}"]` : `window.pageXOffset` + }, ${ + bindings.scrollY ? `current["${bindings.scrollY}"]` : `window.pageYOffset` + }); + ${timeout} = setTimeout(${clear}, 100); + } }); `); } diff --git a/src/generators/nodes/shared/Node.ts b/src/generators/nodes/shared/Node.ts index 1dad9169831d..0d268f0c137f 100644 --- a/src/generators/nodes/shared/Node.ts +++ b/src/generators/nodes/shared/Node.ts @@ -58,7 +58,7 @@ export default class Node { if (child.type === 'Comment') return; // special case — this is an easy way to remove whitespace surrounding - // <:Window/>. lil hacky but it works + // . lil hacky but it works if (child.type === 'Window') { windowComponent = child; return; @@ -163,6 +163,6 @@ export default class Node { } remount(name: string) { - return `${this.var}.m(${name}._slotted${this.generator.legacy ? `["default"]` : `.default`}, null);`; + return `${this.var}.m(${name}._slotted.default, null);`; } } \ No newline at end of file diff --git a/src/generators/nodes/shared/mungeAttribute.ts b/src/generators/nodes/shared/mungeAttribute.ts index 1cf85de9b781..9609f58d4b4a 100644 --- a/src/generators/nodes/shared/mungeAttribute.ts +++ b/src/generators/nodes/shared/mungeAttribute.ts @@ -55,7 +55,7 @@ export default function mungeAttribute(attribute: Node, block: Block): MungedAtt return { spread: false, name: attribute.name, - value: isNaN(value.data) ? stringify(value.data) : value.data, + value: stringify(value.data), dynamic: false, dependencies: [] }; diff --git a/src/generators/server-side-rendering/index.ts b/src/generators/server-side-rendering/index.ts index 41d4ffda116c..a0eade1664c7 100644 --- a/src/generators/server-side-rendering/index.ts +++ b/src/generators/server-side-rendering/index.ts @@ -75,7 +75,7 @@ export default function ssr( // generate initial state object const expectedProperties = Array.from(generator.expectedProperties); const globals = expectedProperties.filter(prop => globalWhitelist.has(prop)); - const storeProps = options.store || templateProperties.store ? expectedProperties.filter(prop => prop[0] === '$') : []; + const storeProps = expectedProperties.filter(prop => prop[0] === '$'); const initialState = []; if (globals.length > 0) { @@ -84,9 +84,7 @@ export default function ssr( if (storeProps.length > 0) { const initialize = `_init([${storeProps.map(prop => `"${prop.slice(1)}"`)}])` - if (options.store || templateProperties.store) { - initialState.push(`options.store.${initialize}`); - } + initialState.push(`options.store.${initialize}`); } if (templateProperties.data) { @@ -139,7 +137,7 @@ export default function ssr( ${computations.map( ({ key, deps }) => - `state.${key} = %computed-${key}(${generator.v2 ? 'state' : deps.map(dep => `state.${dep}`).join(', ')});` + `state.${key} = %computed-${key}(state);` )} ${generator.bindings.length && @@ -163,47 +161,6 @@ export default function ssr( }; var warned = false; - ${name}.renderCss = function() { - if (!warned) { - console.error('Component.renderCss(...) is deprecated and will be removed in v2 — use Component.render(...).css instead'); - warned = true; - } - - var components = []; - - ${generator.stylesheet.hasStyles && - deindent` - components.push({ - filename: ${name}.filename, - css: ${name}.css && ${name}.css.code, - map: ${name}.css && ${name}.css.map - }); - `} - - ${templateProperties.components && - deindent` - var seen = {}; - - function addComponent(component) { - var result = component.renderCss(); - result.components.forEach(x => { - if (seen[x.filename]) return; - seen[x.filename] = true; - components.push(x); - }); - } - - ${templateProperties.components.value.properties.map((prop: Node) => { - return `addComponent(%components-${getName(prop.key)});`; - })} - `} - - return { - css: components.map(x => x.css).join('\\n'), - map: null, - components - }; - }; ${templateProperties.preload && `${name}.preload = %preload;`} diff --git a/src/generators/server-side-rendering/visitors/Component.ts b/src/generators/server-side-rendering/visitors/Component.ts index 9c7d7ce930a1..7ff696998393 100644 --- a/src/generators/server-side-rendering/visitors/Component.ts +++ b/src/generators/server-side-rendering/visitors/Component.ts @@ -57,7 +57,7 @@ export default function visitComponent( if (attribute.value.length === 1) { const chunk = attribute.value[0]; if (chunk.type === 'Text') { - return isNaN(chunk.data) ? stringify(chunk.data) : chunk.data; + return stringify(chunk.data); } block.contextualise(chunk.expression); @@ -87,11 +87,11 @@ export default function visitComponent( .concat(bindingProps) .join(', ')} }`; - const isDynamicComponent = node.name === ':Component' || node.name === 'svelte:component'; + const isDynamicComponent = node.name === 'svelte:component'; if (isDynamicComponent) block.contextualise(node.expression); const expression = ( - (node.name === ':Self' || node.name === 'svelte:self') ? generator.name : + node.name === 'svelte:self' ? generator.name : isDynamicComponent ? `((${node.metadata.snippet}) || __missingComponent)` : `%components-${node.name}` ); @@ -103,9 +103,7 @@ export default function visitComponent( let open = `\${${expression}._render(__result, ${props}`; const options = []; - if (generator.options.store) { - options.push(`store: options.store`); - } + options.push(`store: options.store`); if (node.children.length) { const appendTarget: AppendTarget = { diff --git a/src/index.ts b/src/index.ts index 16081ea8b4d3..a82cc48ffead 100644 --- a/src/index.ts +++ b/src/index.ts @@ -23,9 +23,9 @@ function normalizeOptions(options: CompileOptions): CompileOptions { } function defaultOnwarn(warning: Warning) { - if (warning.loc) { + if (warning.start) { console.warn( - `(${warning.loc.line}:${warning.loc.column}) – ${warning.message}` + `(${warning.start.line}:${warning.start.column}) – ${warning.message}` ); // eslint-disable-line no-console } else { console.warn(warning.message); // eslint-disable-line no-console @@ -106,11 +106,13 @@ export async function preprocess(source: string, options: PreprocessOptions) { }; } -export function compile(source: string, _options: CompileOptions) { +function compile(source: string, _options: CompileOptions) { const options = normalizeOptions(_options); let parsed: Parsed; - const stats = new Stats(); + const stats = new Stats({ + onwarn: options.onwarn + }); try { stats.start('parse'); @@ -122,37 +124,33 @@ export function compile(source: string, _options: CompileOptions) { } stats.start('stylesheet'); - const stylesheet = new Stylesheet(source, parsed, options.filename, options.cascade !== false, options.dev); + const stylesheet = new Stylesheet(source, parsed, options.filename, options.dev); stats.stop('stylesheet'); stats.start('validate'); - // TODO remove this when we remove svelte.validate from public API — we - // can use the stats object instead - const onwarn = options.onwarn; - options.onwarn = warning => { - stats.warnings.push(warning); - onwarn(warning); - }; - - validate(parsed, source, stylesheet, options); + validate(parsed, source, stylesheet, stats, options); stats.stop('validate'); + if (options.generate === false) { + return { ast: parsed, stats, js: null, css: null }; + } + const compiler = options.generate === 'ssr' ? generateSSR : generate; return compiler(parsed, source, stylesheet, options, stats); }; -export function create(source: string, _options: CompileOptions = {}) { +function create(source: string, _options: CompileOptions = {}) { _options.format = 'eval'; const compiled = compile(source, _options); - if (!compiled || !compiled.code) { + if (!compiled || !compiled.js.code) { return; } try { - return (0, eval)(compiled.code); + return (new Function(`return ${compiled.js.code}`))(); } catch (err) { if (_options.onerror) { _options.onerror(err); @@ -163,4 +161,4 @@ export function create(source: string, _options: CompileOptions = {}) { } } -export { parse, validate, Stylesheet, version as VERSION }; +export { parse, create, compile, version as VERSION }; diff --git a/src/interfaces.ts b/src/interfaces.ts index dfce819d5e1b..a2e25cb5e8c5 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -21,14 +21,13 @@ export interface Parser { } export interface Parsed { - hash: number; html: Node; css: Node; js: Node; } export interface Warning { - loc?: { line: number; column: number; pos?: number }; + start?: { line: number; column: number; pos?: number }; end?: { line: number; column: number; }; pos?: number; code: string; @@ -44,7 +43,7 @@ export interface CompileOptions { format?: ModuleFormat; name?: string; filename?: string; - generate?: string; + generate?: string | false; globals?: ((id: string) => string) | object; amd?: { id?: string; @@ -56,19 +55,15 @@ export interface CompileOptions { dev?: boolean; immutable?: boolean; shared?: boolean | string; - cascade?: boolean; hydratable?: boolean; legacy?: boolean; customElement?: CustomElementOptions | true; css?: boolean; - store?: boolean; preserveComments?: boolean | false; onerror?: (error: Error) => void; onwarn?: (warning: Warning) => void; - - parser?: 'v2'; } export interface GenerateOptions { diff --git a/src/parse/index.ts b/src/parse/index.ts index 9b3994c831ad..1bf3e2e58965 100644 --- a/src/parse/index.ts +++ b/src/parse/index.ts @@ -3,23 +3,19 @@ import { locate, Location } from 'locate-character'; import fragment from './state/fragment'; import { whitespace } from '../utils/patterns'; import { trimStart, trimEnd } from '../utils/trim'; -import getCodeFrame from '../utils/getCodeFrame'; import reservedNames from '../utils/reservedNames'; import fullCharCodeAt from '../utils/fullCharCodeAt'; -import hash from '../utils/hash'; import { Node, Parsed } from '../interfaces'; import error from '../utils/error'; interface ParserOptions { filename?: string; bind?: boolean; - parser?: 'v2'; } type ParserState = (parser: Parser) => (ParserState | void); export class Parser { - readonly v2: boolean; readonly template: string; readonly filename?: string; @@ -34,8 +30,6 @@ export class Parser { allowBindings: boolean; constructor(template: string, options: ParserOptions) { - this.v2 = options.parser === 'v2'; - if (typeof template !== 'string') { throw new TypeError('Template must be a string'); } @@ -229,7 +223,6 @@ export default function parse( ): Parsed { const parser = new Parser(template, options); return { - hash: hash(parser.template), html: parser.html, css: parser.css, js: parser.js, diff --git a/src/parse/read/directives.ts b/src/parse/read/directives.ts index 6d8fa70fc592..4fb093d13b3b 100644 --- a/src/parse/read/directives.ts +++ b/src/parse/read/directives.ts @@ -165,10 +165,10 @@ export function readDirective( // assume the mistake was wrapping the directive arguments. // this could yield false positives! but hopefully not too many let message = 'directive values should not be wrapped'; - const expressionEnd = parser.template.indexOf((parser.v2 ? '}' : '}}'), expressionStart); + const expressionEnd = parser.template.indexOf('}', expressionStart); if (expressionEnd !== -1) { - const value = parser.template.slice(expressionStart + (parser.v2 ? 1 : 2), expressionEnd); - message += ` — use '${value}', not '${parser.v2 ? `{${value}}` : `{{${value}}}`}'`; + const value = parser.template.slice(expressionStart + 1, expressionEnd); + message += ` — use '${value}', not '{${value}}'`; } parser.error({ code: `invalid-directive-value`, diff --git a/src/parse/read/expression.ts b/src/parse/read/expression.ts index 606f8f92a7c4..938009d81601 100644 --- a/src/parse/read/expression.ts +++ b/src/parse/read/expression.ts @@ -6,7 +6,7 @@ const literals = new Map([['true', true], ['false', false], ['null', null]]); export default function readExpression(parser: Parser) { const start = parser.index; - const name = parser.readUntil(parser.v2 ? /\s*}/ : /\s*}}/); + const name = parser.readUntil(/\s*}/); if (name && /^[a-z]+$/.test(name)) { const end = start + name.length; diff --git a/src/parse/state/fragment.ts b/src/parse/state/fragment.ts index b2e6cb4c32c9..41275a173880 100644 --- a/src/parse/state/fragment.ts +++ b/src/parse/state/fragment.ts @@ -8,7 +8,7 @@ export default function fragment(parser: Parser) { return tag; } - if (parser.match(parser.v2 ? '{' : '{{')) { + if (parser.match('{')) { return mustache; } diff --git a/src/parse/state/mustache.ts b/src/parse/state/mustache.ts index 922de7b53282..ed15da970279 100644 --- a/src/parse/state/mustache.ts +++ b/src/parse/state/mustache.ts @@ -32,7 +32,7 @@ function trimWhitespace(block: Node, trimBefore: boolean, trimAfter: boolean) { export default function mustache(parser: Parser) { const start = parser.index; - parser.index += parser.v2 ? 1 : 2; + parser.index += 1; parser.allowWhitespace(); @@ -64,7 +64,7 @@ export default function mustache(parser: Parser) { parser.eat(expected, true); parser.allowWhitespace(); - parser.eat(parser.v2 ? '}' : '}}', true); + parser.eat('}', true); while (block.elseif) { block.end = parser.index; @@ -86,7 +86,7 @@ export default function mustache(parser: Parser) { block.end = parser.index; parser.stack.pop(); - } else if (parser.eat(parser.v2 ? ':elseif' : 'elseif')) { + } else if (parser.eat(':elseif')) { const block = parser.current(); if (block.type !== 'IfBlock') parser.error({ @@ -99,7 +99,7 @@ export default function mustache(parser: Parser) { const expression = readExpression(parser); parser.allowWhitespace(); - parser.eat(parser.v2 ? '}' : '}}', true); + parser.eat('}', true); block.else = { start: parser.index, @@ -118,7 +118,7 @@ export default function mustache(parser: Parser) { }; parser.stack.push(block.else.children[0]); - } else if (parser.eat(parser.v2 ? ':else' : 'else')) { + } else if (parser.eat(':else')) { const block = parser.current(); if (block.type !== 'IfBlock' && block.type !== 'EachBlock') { parser.error({ @@ -128,7 +128,7 @@ export default function mustache(parser: Parser) { } parser.allowWhitespace(); - parser.eat(parser.v2 ? '}' : '}}', true); + parser.eat('}', true); block.else = { start: parser.index, @@ -138,7 +138,7 @@ export default function mustache(parser: Parser) { }; parser.stack.push(block.else); - } else if (parser.eat(parser.v2 ? ':then' : 'then')) { + } else if (parser.eat(':then')) { // TODO DRY out this and the next section const pendingBlock = parser.current(); if (pendingBlock.type === 'PendingBlock') { @@ -150,7 +150,7 @@ export default function mustache(parser: Parser) { awaitBlock.value = parser.readIdentifier(); parser.allowWhitespace(); - parser.eat(parser.v2 ? '}' : '}}', true); + parser.eat('}', true); const thenBlock: Node = { start, @@ -162,7 +162,7 @@ export default function mustache(parser: Parser) { awaitBlock.then = thenBlock; parser.stack.push(thenBlock); } - } else if (parser.eat(parser.v2 ? ':catch' : 'catch')) { + } else if (parser.eat(':catch')) { const thenBlock = parser.current(); if (thenBlock.type === 'ThenBlock') { thenBlock.end = start; @@ -173,7 +173,7 @@ export default function mustache(parser: Parser) { awaitBlock.error = parser.readIdentifier(); parser.allowWhitespace(); - parser.eat(parser.v2 ? '}' : '}}', true); + parser.eat('}', true); const catchBlock: Node = { start, @@ -336,7 +336,7 @@ export default function mustache(parser: Parser) { parser.allowWhitespace(); } - parser.eat(parser.v2 ? '}' : '}}', true); + parser.eat('}', true); parser.current().children.push(block); parser.stack.push(block); @@ -346,44 +346,12 @@ export default function mustache(parser: Parser) { childBlock.start = parser.index; parser.stack.push(childBlock); } - } else if (parser.eat('yield')) { - // {{yield}} - // TODO deprecate - parser.allowWhitespace(); - - if (parser.v2) { - const expressionEnd = parser.index; - - parser.eat('}', true); - parser.current().children.push({ - start, - end: parser.index, - type: 'MustacheTag', - expression: { - start: expressionEnd - 5, - end: expressionEnd, - type: 'Identifier', - name: 'yield' - } - }); - } else { - parser.eat('}}', true); - - parser.current().children.push({ - start, - end: parser.index, - type: 'Element', - name: 'slot', - attributes: [], - children: [] - }); - } - } else if (parser.eat(parser.v2 ? '@html' : '{')) { + } else if (parser.eat('@html')) { // {{{raw}}} mustache const expression = readExpression(parser); parser.allowWhitespace(); - parser.eat(parser.v2 ? '}' : '}}}', true); + parser.eat('}', true); parser.current().children.push({ start, @@ -395,7 +363,7 @@ export default function mustache(parser: Parser) { const expression = readExpression(parser); parser.allowWhitespace(); - parser.eat(parser.v2 ? '}' : '}}', true); + parser.eat('}', true); parser.current().children.push({ start, diff --git a/src/parse/state/tag.ts b/src/parse/state/tag.ts index 27b180195d25..cf0267c2402f 100644 --- a/src/parse/state/tag.ts +++ b/src/parse/state/tag.ts @@ -11,8 +11,6 @@ import { Node } from '../../interfaces'; const validTagName = /^\!?[a-zA-Z]{1,}:?[a-zA-Z0-9\-]*/; const metaTags = new Map([ - [':Window', 'Window'], - [':Head', 'Head'], ['svelte:window', 'Window'], ['svelte:head', 'Head'] ]); @@ -34,6 +32,9 @@ const specials = new Map([ ], ]); +const SELF = 'svelte:self'; +const COMPONENT = 'svelte:component'; + // based on http://developers.whatwg.org/syntax.html#syntax-tag-omission const disallowedContents = new Map([ ['li', new Set(['li'])], @@ -85,7 +86,7 @@ export default function tag(parser: Parser) { if (metaTags.has(name)) { const slug = metaTags.get(name).toLowerCase(); if (isClosingTag) { - if ((name === ':Window' || name === 'svelte:window') && parser.current().children.length) { + if (name === 'svelte:window' && parser.current().children.length) { parser.error({ code: `invalid-window-content`, message: `<${name}> cannot have children` @@ -175,14 +176,6 @@ export default function tag(parser: Parser) { } } - if (name === ':Component') { - parser.eat('{', true); - element.expression = readExpression(parser); - parser.allowWhitespace(); - parser.eat('}', true); - parser.allowWhitespace(); - } - const uniqueNames = new Set(); let attribute; @@ -198,7 +191,7 @@ export default function tag(parser: Parser) { parser.allowWhitespace(); } - if (parser.v2 && name === 'svelte:component') { + if (name === 'svelte:component') { // TODO post v2, treat this just as any other attribute const index = element.attributes.findIndex(attr => attr.name === 'this'); if (!~index) { @@ -264,21 +257,11 @@ export default function tag(parser: Parser) { element.end = parser.index; } else if (name === 'style') { // special case - if (parser.v2) { - const start = parser.index; - const data = parser.readUntil(/<\/style>/); - const end = parser.index; - element.children.push({ start, end, type: 'Text', data }); - parser.eat('', true); - } else { - element.children = readSequence( - parser, - () => - parser.template.slice(parser.index, parser.index + 8) === '' - ); - parser.read(/<\/style>/); - element.end = parser.index; - } + const start = parser.index; + const data = parser.readUntil(/<\/style>/); + const end = parser.index; + element.children.push({ start, end, type: 'Text', data }); + parser.eat('', true); } else { parser.stack.push(element); } @@ -287,10 +270,6 @@ export default function tag(parser: Parser) { function readTagName(parser: Parser) { const start = parser.index; - // TODO hoist these back to the top, post-v2 - const SELF = parser.v2 ? 'svelte:self' : ':Self'; - const COMPONENT = parser.v2 ? 'svelte:component' : ':Component'; - if (parser.eat(SELF)) { // check we're inside a block, otherwise this // will cause infinite recursion @@ -334,14 +313,14 @@ function readTagName(parser: Parser) { function readAttribute(parser: Parser, uniqueNames: Set) { const start = parser.index; - if (parser.eat(parser.v2 ? '{' : '{{')) { + if (parser.eat('{')) { parser.allowWhitespace(); if (parser.eat('...')) { const expression = readExpression(parser); parser.allowWhitespace(); - parser.eat(parser.v2 ? '}' : '}}', true); + parser.eat('}', true); return { start, @@ -350,13 +329,6 @@ function readAttribute(parser: Parser, uniqueNames: Set) { expression }; } else { - if (!parser.v2) { - parser.error({ - code: `expected-spread`, - message: 'Expected spread operator (...)' - }); - } - const valueStart = parser.index; const name = parser.readIdentifier(); @@ -449,7 +421,7 @@ function readSequence(parser: Parser, done: () => boolean) { }); return chunks; - } else if (parser.eat(parser.v2 ? '{' : '{{')) { + } else if (parser.eat('{')) { if (currentChunk.data) { currentChunk.end = index; chunks.push(currentChunk); @@ -457,7 +429,7 @@ function readSequence(parser: Parser, done: () => boolean) { const expression = readExpression(parser); parser.allowWhitespace(); - parser.eat(parser.v2 ? '}' : '}}', true); + parser.eat('}', true); chunks.push({ start: index, diff --git a/src/parse/state/text.ts b/src/parse/state/text.ts index 29da8f928a6b..72fea496ce89 100644 --- a/src/parse/state/text.ts +++ b/src/parse/state/text.ts @@ -9,7 +9,7 @@ export default function text(parser: Parser) { while ( parser.index < parser.template.length && !parser.match('<') && - !parser.match(parser.v2 ? '{' : '{{') + !parser.match('{') ) { data += parser.template[parser.index++]; } diff --git a/src/server-side-rendering/register.js b/src/server-side-rendering/register.js index 7940a2c4875f..fe1fe74c5f0e 100644 --- a/src/server-side-rendering/register.js +++ b/src/server-side-rendering/register.js @@ -2,29 +2,28 @@ import * as fs from 'fs'; import * as path from 'path'; import { compile } from '../index.ts'; -let compileOptions = {}; +let compileOptions = { + extensions: ['.html'] +}; function capitalise(name) { return name[0].toUpperCase() + name.slice(1); } export default function register(options) { - const { extensions } = options; - - if (extensions) { - _deregister('.html'); - extensions.forEach(_register); + if (options.extensions) { + compileOptions.extensions.forEach(deregisterExtension); + options.extensions.forEach(registerExtension); } - // TODO make this the default and remove in v2 - if (options) compileOptions = options; + compileOptions = options; } -function _deregister(extension) { +function deregisterExtension(extension) { delete require.extensions[extension]; } -function _register(extension) { +function registerExtension(extension) { require.extensions[extension] = function(module, filename) { const name = path.basename(filename) .slice(0, -path.extname(filename).length) @@ -37,10 +36,10 @@ function _register(extension) { generate: 'ssr' }); - const {code} = compile(fs.readFileSync(filename, 'utf-8'), options); + const { js } = compile(fs.readFileSync(filename, 'utf-8'), options); - return module._compile(code, filename); + return module._compile(js.code, filename); }; } -_register('.html'); +registerExtension('.html'); \ No newline at end of file diff --git a/src/shared/.eslintrc.json b/src/shared/.eslintrc.json index 46f19570776a..cd108372cebd 100644 --- a/src/shared/.eslintrc.json +++ b/src/shared/.eslintrc.json @@ -29,7 +29,7 @@ "plugin:import/warnings" ], "parserOptions": { - "ecmaVersion": 6, + "ecmaVersion": 9, "sourceType": "module" }, "settings": { diff --git a/src/shared/_build.js b/src/shared/_build.js index 3cc523e7cd1e..72bd5ab2a880 100644 --- a/src/shared/_build.js +++ b/src/shared/_build.js @@ -9,18 +9,13 @@ fs.readdirSync(__dirname).forEach(file => { const source = fs.readFileSync(path.join(__dirname, file), 'utf-8'); const ast = acorn.parse(source, { - ecmaVersion: 6, + ecmaVersion: 9, sourceType: 'module' }); ast.body.forEach(node => { if (node.type !== 'ExportNamedDeclaration') return; - // check no ES6+ slipped in - acorn.parse(source.slice(node.declaration.start, node.end), { - ecmaVersion: 5 - }); - const declaration = node.declaration; if (!declaration) return; diff --git a/src/shared/index.js b/src/shared/index.js index 5ec905d29bd8..0d7cb43bddbb 100644 --- a/src/shared/index.js +++ b/src/shared/index.js @@ -51,13 +51,8 @@ export function fire(eventName, data) { } } -export function getDev(key) { - if (key) console.warn("`let x = component.get('x')` is deprecated. Use `let { x } = component.get()` instead"); - return get.call(this, key); -} - -export function get(key) { - return key ? this._state[key] : this._state; +export function get() { + return this._state; } export function init(component, options) { @@ -69,37 +64,7 @@ export function init(component, options) { component.store = component.root.store || options.store; } -export function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -export function observeDev(key, callback, options) { - console.warn("this.observe(key, (newValue, oldValue) => {...}) is deprecated. Use\n\n // runs before DOM updates\n this.on('state', ({ changed, current, previous }) => {...});\n\n // runs after DOM updates\n this.on('update', ...);\n\n...or add the observe method from the svelte-extras package"); - - var c = (key = '' + key).search(/[.[]/); - if (c > -1) { - var message = - 'The first argument to component.observe(...) must be the name of a top-level property'; - if (c > 0) - message += ", i.e. '" + key.slice(0, c) + "' rather than '" + key + "'"; - - throw new Error(message); - } - - return observe.call(this, key, callback, options); -} - export function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); @@ -111,17 +76,6 @@ export function on(eventName, handler) { }; } -export function onDev(eventName, handler) { - if (eventName === 'teardown') { - console.warn( - "Use component.on('destroy', ...) instead of component.on('teardown', ...) which has been deprecated and will be unsupported in Svelte 2" - ); - return this.on('destroy', handler); - } - - return on.call(this, eventName, handler); -} - export function run(fn) { fn(); } @@ -193,31 +147,27 @@ export function removeFromStore() { } export var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; export var protoDev = { destroy: destroyDev, - get: getDev, - fire: fire, - observe: observeDev, - on: onDev, + get, + fire, + on, set: setDev, - teardown: destroyDev, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; diff --git a/src/utils/error.ts b/src/utils/error.ts index 35daba2c80b0..acaab3711719 100644 --- a/src/utils/error.ts +++ b/src/utils/error.ts @@ -3,14 +3,14 @@ import getCodeFrame from '../utils/getCodeFrame'; class CompileError extends Error { code: string; - loc: { line: number, column: number }; + start: { line: number, column: number }; end: { line: number, column: number }; pos: number; filename: string; frame: string; toString() { - return `${this.message} (${this.loc.line}:${this.loc.column})\n${this.frame}`; + return `${this.message} (${this.start.line}:${this.start.column})\n${this.frame}`; } } @@ -25,16 +25,16 @@ export default function error(message: string, props: { const error = new CompileError(message); error.name = props.name; - const start = locate(props.source, props.start); - const end = locate(props.source, props.end || props.start); + const start = locate(props.source, props.start, { offsetLine: 1 }); + const end = locate(props.source, props.end || props.start, { offsetLine: 1 }); error.code = props.code; - error.loc = { line: start.line + 1, column: start.column }; - error.end = { line: end.line + 1, column: end.column }; + error.start = start; + error.end = end; error.pos = props.start; error.filename = props.filename; - error.frame = getCodeFrame(props.source, start.line, start.column); + error.frame = getCodeFrame(props.source, start.line - 1, start.column); throw error; } \ No newline at end of file diff --git a/src/utils/quoteIfNecessary.ts b/src/utils/quoteIfNecessary.ts index 82a7901a7fe6..118c4909d753 100644 --- a/src/utils/quoteIfNecessary.ts +++ b/src/utils/quoteIfNecessary.ts @@ -1,7 +1,7 @@ import isValidIdentifier from './isValidIdentifier'; import reservedNames from './reservedNames'; -export default function quoteIfNecessary(name: string, legacy?: boolean) { - if (!isValidIdentifier(name) || (legacy && reservedNames.has(name))) return `"${name}"`; +export default function quoteIfNecessary(name) { + if (!isValidIdentifier(name)) return `"${name}"`; return name; } \ No newline at end of file diff --git a/src/validate/html/index.ts b/src/validate/html/index.ts index f543ebd27e63..e471ff6b4135 100644 --- a/src/validate/html/index.ts +++ b/src/validate/html/index.ts @@ -31,8 +31,6 @@ export default function validateHtml(validator: Validator, html: Node) { else if (node.type === 'Element') { const isComponent = - node.name === ':Self' || - node.name === ':Component' || node.name === 'svelte:self' || node.name === 'svelte:component' || validator.components.has(node.name); diff --git a/src/validate/html/validateElement.ts b/src/validate/html/validateElement.ts index 820de23ea1d3..2a327697971a 100644 --- a/src/validate/html/validateElement.ts +++ b/src/validate/html/validateElement.ts @@ -19,8 +19,7 @@ export default function validateElement( } if (!isComponent && /^[A-Z]/.test(node.name[0])) { - // TODO upgrade to validator.error in v2 - validator.warn(node, { + validator.error(node, { code: `missing-component`, message: `${node.name} component is not defined` }); @@ -298,7 +297,7 @@ function checkSlotAttribute(validator: Validator, node: Node, attribute: Node, s const parent = stack[i]; if (parent.type === 'Element') { // if we're inside a component or a custom element, gravy - if (parent.name === ':Self' || parent.name === ':Component' || parent.name === 'svelte:self' || parent.name === 'svelte:component' || validator.components.has(parent.name)) return; + if (parent.name === 'svelte:self' || parent.name === 'svelte:component' || validator.components.has(parent.name)) return; if (/-/.test(parent.name)) return; } diff --git a/src/validate/html/validateEventHandler.ts b/src/validate/html/validateEventHandler.ts index 086ae2f7b611..1b33b3e78666 100644 --- a/src/validate/html/validateEventHandler.ts +++ b/src/validate/html/validateEventHandler.ts @@ -31,35 +31,33 @@ export default function validateEventHandlerCallee( return; } - if (name === 'store' && attribute.expression.callee.type === 'MemberExpression') { - if (!validator.options.store) { - validator.warn(attribute.expression, { - code: `options-missing-store`, - message: 'compile with `store: true` in order to call store methods' - }); - } - return; - } - if ( (callee.type === 'Identifier' && validBuiltins.has(callee.name)) || validator.methods.has(callee.name) - ) + ) { + return; + } + + if (name[0] === '$') { + // assume it's a store method return; + } const validCallees = ['this.*', 'event.*', 'options.*', 'console.*'].concat( - validator.options.store ? 'store.*' : [], Array.from(validBuiltins), Array.from(validator.methods.keys()) ); - let message = `'${validator.source.slice( - callee.start, - callee.end - )}' is an invalid callee (should be one of ${list(validCallees)})`; + let message = `'${validator.source.slice(callee.start, callee.end)}' is an invalid callee ` ; - if (callee.type === 'Identifier' && validator.helpers.has(callee.name)) { - message += `. '${callee.name}' exists on 'helpers', did you put it in the wrong place?`; + if (name === 'store') { + message += `(did you mean '$${validator.source.slice(callee.start + 6, callee.end)}(...)'?)`; + } else { + message += `(should be one of ${list(validCallees)})`; + + if (callee.type === 'Identifier' && validator.helpers.has(callee.name)) { + message += `. '${callee.name}' exists on 'helpers', did you put it in the wrong place?`; + } } validator.warn(attribute.expression, { diff --git a/src/validate/html/validateHead.ts b/src/validate/html/validateHead.ts index 48756f91507b..aca0fd87ad0c 100644 --- a/src/validate/html/validateHead.ts +++ b/src/validate/html/validateHead.ts @@ -6,7 +6,7 @@ export default function validateHead(validator: Validator, node: Node, refs: Map if (node.attributes.length) { validator.error(node.attributes[0], { code: `invalid-attribute`, - message: `<:Head> should not have any attributes or directives` + message: ` should not have any attributes or directives` }); } diff --git a/src/validate/html/validateWindow.ts b/src/validate/html/validateWindow.ts index 29b5f2a7dfa1..6f312e0407ee 100644 --- a/src/validate/html/validateWindow.ts +++ b/src/validate/html/validateWindow.ts @@ -23,7 +23,7 @@ export default function validateWindow(validator: Validator, node: Node, refs: M validator.error(attribute.value, { code: `invalid-binding`, - message: `Bindings on <:Window/> must be to top-level properties, e.g. '${parts[parts.length - 1]}' rather than '${parts.join('.')}'` + message: `Bindings on must be to top-level properties, e.g. '${parts[parts.length - 1]}' rather than '${parts.join('.')}'` }); } @@ -34,7 +34,7 @@ export default function validateWindow(validator: Validator, node: Node, refs: M ? 'innerHeight' : fuzzymatch(attribute.name, validBindings); - const message = `'${attribute.name}' is not a valid binding on <:Window>`; + const message = `'${attribute.name}' is not a valid binding on `; if (match) { validator.error(attribute, { diff --git a/src/validate/index.ts b/src/validate/index.ts index f5bb2d30ef7b..b79a93a0cebc 100644 --- a/src/validate/index.ts +++ b/src/validate/index.ts @@ -5,15 +5,15 @@ import getCodeFrame from '../utils/getCodeFrame'; import Stats from '../Stats'; import error from '../utils/error'; import Stylesheet from '../css/Stylesheet'; +import Stats from '../Stats'; import { Node, Parsed, CompileOptions, Warning } from '../interfaces'; export class Validator { readonly source: string; readonly filename: string; - readonly v2: boolean; + readonly stats: Stats; options: CompileOptions; - onwarn: ({}) => void; locator?: (pos: number) => Location; namespace: string; @@ -34,12 +34,12 @@ export class Validator { actions: Set; }; - constructor(parsed: Parsed, source: string, options: CompileOptions) { + constructor(parsed: Parsed, source: string, stats: Stats, options: CompileOptions) { this.source = source; + this.stats = stats; + this.filename = options.filename; - this.onwarn = options.onwarn; this.options = options; - this.v2 = options.parser === 'v2'; this.namespace = null; this.defaultExport = null; @@ -73,18 +73,18 @@ export class Validator { } warn(pos: { start: number, end: number }, { code, message }: { code: string, message: string }) { - if (!this.locator) this.locator = getLocator(this.source); + if (!this.locator) this.locator = getLocator(this.source, { offsetLine: 1 }); const start = this.locator(pos.start); const end = this.locator(pos.end); - const frame = getCodeFrame(this.source, start.line, start.column); + const frame = getCodeFrame(this.source, start.line - 1, start.column); - this.onwarn({ + this.stats.warn({ code, message, frame, - loc: { line: start.line + 1, column: start.column }, - end: { line: end.line + 1, column: end.column }, + start, + end, pos: pos.start, filename: this.filename, toString: () => `${message} (${start.line + 1}:${start.column})\n${frame}`, @@ -96,9 +96,10 @@ export default function validate( parsed: Parsed, source: string, stylesheet: Stylesheet, + stats: Stats, options: CompileOptions ) { - const { onwarn, onerror, name, filename, store, dev, parser } = options; + const { onerror, name, filename, dev, parser } = options; try { if (name && !/^[a-zA-Z_$][a-zA-Z_$0-9]*$/.test(name)) { @@ -108,7 +109,7 @@ export default function validate( if (name && /^[a-z]/.test(name)) { const message = `options.name should be capitalised`; - onwarn({ + stats.warn({ code: `options-lowercase-name`, message, filename, @@ -116,11 +117,9 @@ export default function validate( }); } - const validator = new Validator(parsed, source, { - onwarn, + const validator = new Validator(parsed, source, stats, { name, filename, - store, dev, parser }); diff --git a/src/validate/js/propValidators/components.ts b/src/validate/js/propValidators/components.ts index 10a528b53b72..758b84e86fbf 100644 --- a/src/validate/js/propValidators/components.ts +++ b/src/validate/js/propValidators/components.ts @@ -27,9 +27,9 @@ export default function components(validator: Validator, prop: Node) { } if (!/^[A-Z]/.test(name)) { - validator.warn(component, { + validator.error(component, { code: `component-lowercase`, - message: `Component names should be capitalised` + message: `Component names must be capitalised` }); } }); diff --git a/src/validate/js/propValidators/computed.ts b/src/validate/js/propValidators/computed.ts index e81341fab8d6..d918fe3e8b22 100644 --- a/src/validate/js/propValidators/computed.ts +++ b/src/validate/js/propValidators/computed.ts @@ -30,14 +30,14 @@ export default function computed(validator: Validator, prop: Node) { if (!isValidIdentifier(name)) { const suggestion = name.replace(/[^_$a-z0-9]/ig, '_').replace(/^\d/, '_$&'); - validator.error(computation, { + validator.error(computation.key, { code: `invalid-computed-name`, message: `Computed property name '${name}' is invalid — must be a valid identifier such as ${suggestion}` }); } if (reservedNames.has(name)) { - validator.error(computation, { + validator.error(computation.key, { code: `invalid-computed-name`, message: `Computed property name '${name}' is invalid — cannot be a JavaScript reserved word` }); @@ -75,36 +75,19 @@ export default function computed(validator: Validator, prop: Node) { }); } - if (validator.v2) { - if (params.length > 1) { - validator.error(computation.value, { - code: `invalid-computed-arguments`, - message: `Computed properties must take a single argument` - }); - } - - const param = params[0]; - if (param.type !== 'ObjectPattern') { - // TODO in v2, allow the entire object to be passed in - validator.error(computation.value, { - code: `invalid-computed-argument`, - message: `Computed property argument must be a destructured object pattern` - }); - } - } else { - params.forEach((param: Node) => { - const valid = - param.type === 'Identifier' || - (param.type === 'AssignmentPattern' && - param.left.type === 'Identifier'); + if (params.length > 1) { + validator.error(computation.value, { + code: `invalid-computed-arguments`, + message: `Computed properties must take a single argument` + }); + } - if (!valid) { - // TODO change this for v2 - validator.error(param, { - code: `invalid-computed-arguments`, - message: `Computed properties cannot use destructuring in function parameters` - }); - } + const param = params[0]; + if (param.type !== 'ObjectPattern') { + // TODO post-v2, allow the entire object to be passed in + validator.error(computation.value, { + code: `invalid-computed-argument`, + message: `Computed property argument must be a destructured object pattern` }); } }); diff --git a/store.js b/store.js index 7aef7b2046b4..42f17c9bb87b 100644 --- a/store.js +++ b/store.js @@ -4,13 +4,11 @@ import { _differs, _differsImmutable, get, - observe, on, fire } from './shared.js'; function Store(state, options) { - this._observers = { pre: blankObject(), post: blankObject() }; this._handlers = {}; this._dependents = []; @@ -110,20 +108,8 @@ assign(Store.prototype, { get: get, - // TODO remove this method - observe: observe, - on: on, - onchange: function(callback) { - // TODO remove this method - console.warn("store.onchange is deprecated in favour of store.on('state', event => {...})"); - - return this.on('state', function(event) { - callback(event.current, event.changed); - }); - }, - set: function(newState) { var oldState = this._state, changed = this._changed = {}, diff --git a/test/create/index.js b/test/create/index.js index 3c2387d737e2..cb4beb623ac4 100644 --- a/test/create/index.js +++ b/test/create/index.js @@ -4,7 +4,7 @@ import { svelte, deindent } from "../helpers.js"; describe("create", () => { it("should return a component constructor", () => { const source = deindent` -
{{prop}}
+
{prop}
`; const component = svelte.create(source); @@ -13,7 +13,7 @@ describe("create", () => { it("should throw error when source is invalid ", done => { const source = deindent` -
{{prop}
+
{prop
`; const component = svelte.create(source, { @@ -27,7 +27,7 @@ describe("create", () => { it("should return undefined when source is invalid ", () => { const source = deindent` -
{{prop}
+
{prop
`; const component = svelte.create(source, { diff --git a/test/css/index.js b/test/css/index.js index a59f13266054..8af76f61c130 100644 --- a/test/css/index.js +++ b/test/css/index.js @@ -78,10 +78,10 @@ describe('css', () => { ); // check the code is valid - checkCodeIsValid(dom.code); - checkCodeIsValid(ssr.code); + checkCodeIsValid(dom.js.code); + checkCodeIsValid(ssr.js.code); - assert.equal(dom.css.toString(), ssr.css.toString()); + assert.equal(dom.css.code, ssr.css.code); assert.deepEqual( domWarnings.map(normalizeWarning), @@ -89,13 +89,13 @@ describe('css', () => { ); assert.deepEqual(domWarnings.map(normalizeWarning), expectedWarnings); - fs.writeFileSync(`test/css/samples/${dir}/_actual.css`, dom.css); + fs.writeFileSync(`test/css/samples/${dir}/_actual.css`, dom.css.code); const expected = { html: read(`test/css/samples/${dir}/expected.html`), css: read(`test/css/samples/${dir}/expected.css`) }; - assert.equal(dom.css.replace(/svelte(-ref)?-[a-z0-9]+/g, (m, $1) => $1 ? m : 'svelte-xyz'), expected.css); + assert.equal(dom.css.code.replace(/svelte(-ref)?-[a-z0-9]+/g, (m, $1) => $1 ? m : 'svelte-xyz'), expected.css); // verify that the right elements have scoping selectors if (expected.html !== null) { @@ -104,7 +104,7 @@ describe('css', () => { // dom try { const Component = eval( - `(function () { ${dom.code}; return SvelteComponent; }())` + `(function () { ${dom.js.code}; return SvelteComponent; }())` ); const target = window.document.querySelector('main'); @@ -120,14 +120,14 @@ describe('css', () => { window.document.head.innerHTML = ''; // remove added styles } catch (err) { - console.log(dom.code); + console.log(dom.js.code); throw err; } // ssr try { const component = eval( - `(function () { ${ssr.code}; return SvelteComponent; }())` + `(function () { ${ssr.js.code}; return SvelteComponent; }())` ); assert.equal( @@ -138,7 +138,7 @@ describe('css', () => { normalizeHtml(window, expected.html) ); } catch (err) { - console.log(ssr.code); + console.log(ssr.js.code); throw err; } } diff --git a/test/css/samples/attribute-selector-only-name/_config.js b/test/css/samples/attribute-selector-only-name/_config.js deleted file mode 100644 index b37866f9b61a..000000000000 --- a/test/css/samples/attribute-selector-only-name/_config.js +++ /dev/null @@ -1,3 +0,0 @@ -export default { - cascade: false -}; \ No newline at end of file diff --git a/test/css/samples/attribute-selector-unquoted/_config.js b/test/css/samples/attribute-selector-unquoted/_config.js deleted file mode 100644 index b37866f9b61a..000000000000 --- a/test/css/samples/attribute-selector-unquoted/_config.js +++ /dev/null @@ -1,3 +0,0 @@ -export default { - cascade: false -}; \ No newline at end of file diff --git a/test/css/samples/basic/expected.css b/test/css/samples/basic/expected.css index 49670b1fd540..d466e8df9658 100644 --- a/test/css/samples/basic/expected.css +++ b/test/css/samples/basic/expected.css @@ -1 +1 @@ -div.svelte-xyz,.svelte-xyz div{color:red} \ No newline at end of file +div.svelte-xyz{color:red} \ No newline at end of file diff --git a/test/css/samples/cascade-false-empty-rule/_config.js b/test/css/samples/cascade-false-empty-rule/_config.js deleted file mode 100644 index b37866f9b61a..000000000000 --- a/test/css/samples/cascade-false-empty-rule/_config.js +++ /dev/null @@ -1,3 +0,0 @@ -export default { - cascade: false -}; \ No newline at end of file diff --git a/test/css/samples/cascade-false-global-keyframes/_config.js b/test/css/samples/cascade-false-global-keyframes/_config.js deleted file mode 100644 index b37866f9b61a..000000000000 --- a/test/css/samples/cascade-false-global-keyframes/_config.js +++ /dev/null @@ -1,3 +0,0 @@ -export default { - cascade: false -}; \ No newline at end of file diff --git a/test/css/samples/cascade-false-global/_config.js b/test/css/samples/cascade-false-global/_config.js deleted file mode 100644 index b37866f9b61a..000000000000 --- a/test/css/samples/cascade-false-global/_config.js +++ /dev/null @@ -1,3 +0,0 @@ -export default { - cascade: false -}; \ No newline at end of file diff --git a/test/css/samples/cascade-false-keyframes-from-to/_config.js b/test/css/samples/cascade-false-keyframes-from-to/_config.js deleted file mode 100644 index b37866f9b61a..000000000000 --- a/test/css/samples/cascade-false-keyframes-from-to/_config.js +++ /dev/null @@ -1,3 +0,0 @@ -export default { - cascade: false -}; \ No newline at end of file diff --git a/test/css/samples/cascade-false-keyframes/_config.js b/test/css/samples/cascade-false-keyframes/_config.js deleted file mode 100644 index b37866f9b61a..000000000000 --- a/test/css/samples/cascade-false-keyframes/_config.js +++ /dev/null @@ -1,3 +0,0 @@ -export default { - cascade: false -}; \ No newline at end of file diff --git a/test/css/samples/cascade-false-keyframes/expected.css b/test/css/samples/cascade-false-keyframes/expected.css deleted file mode 100644 index a6a1176dae46..000000000000 --- a/test/css/samples/cascade-false-keyframes/expected.css +++ /dev/null @@ -1 +0,0 @@ -@keyframes svelte-xyz-why{0%{color:red}100%{color:blue}}.animated.svelte-xyz{animation:svelte-xyz-why 2s}.also-animated.svelte-xyz{animation:not-defined-here 2s} \ No newline at end of file diff --git a/test/css/samples/cascade-false-keyframes/input.html b/test/css/samples/cascade-false-keyframes/input.html deleted file mode 100644 index ba220a5e22ce..000000000000 --- a/test/css/samples/cascade-false-keyframes/input.html +++ /dev/null @@ -1,17 +0,0 @@ -
animated
-
also animated
- - \ No newline at end of file diff --git a/test/css/samples/cascade-false-pseudo-element/_config.js b/test/css/samples/cascade-false-pseudo-element/_config.js deleted file mode 100644 index b37866f9b61a..000000000000 --- a/test/css/samples/cascade-false-pseudo-element/_config.js +++ /dev/null @@ -1,3 +0,0 @@ -export default { - cascade: false -}; \ No newline at end of file diff --git a/test/css/samples/cascade-false-universal-selector/_config.js b/test/css/samples/cascade-false-universal-selector/_config.js deleted file mode 100644 index b37866f9b61a..000000000000 --- a/test/css/samples/cascade-false-universal-selector/_config.js +++ /dev/null @@ -1,3 +0,0 @@ -export default { - cascade: false -}; \ No newline at end of file diff --git a/test/css/samples/cascade-false-universal-selector/expected.css b/test/css/samples/cascade-false-universal-selector/expected.css deleted file mode 100644 index 3eda95e44618..000000000000 --- a/test/css/samples/cascade-false-universal-selector/expected.css +++ /dev/null @@ -1 +0,0 @@ -.svelte-xyz{color:red} \ No newline at end of file diff --git a/test/css/samples/cascade-false-universal-selector/expected.html b/test/css/samples/cascade-false-universal-selector/expected.html deleted file mode 100644 index be0c65091616..000000000000 --- a/test/css/samples/cascade-false-universal-selector/expected.html +++ /dev/null @@ -1 +0,0 @@ -
\ No newline at end of file diff --git a/test/css/samples/cascade-false-universal-selector/input.html b/test/css/samples/cascade-false-universal-selector/input.html deleted file mode 100644 index 36a65e23e6fa..000000000000 --- a/test/css/samples/cascade-false-universal-selector/input.html +++ /dev/null @@ -1,7 +0,0 @@ -
- - \ No newline at end of file diff --git a/test/css/samples/cascade-false/_config.js b/test/css/samples/cascade-false/_config.js deleted file mode 100644 index b37866f9b61a..000000000000 --- a/test/css/samples/cascade-false/_config.js +++ /dev/null @@ -1,3 +0,0 @@ -export default { - cascade: false -}; \ No newline at end of file diff --git a/test/css/samples/cascade-false/expected.css b/test/css/samples/cascade-false/expected.css deleted file mode 100644 index 797d245dde88..000000000000 --- a/test/css/samples/cascade-false/expected.css +++ /dev/null @@ -1 +0,0 @@ -div.svelte-xyz{color:red}div.foo.svelte-xyz{color:blue}.foo.svelte-xyz{font-weight:bold} \ No newline at end of file diff --git a/test/css/samples/cascade-false/input.html b/test/css/samples/cascade-false/input.html deleted file mode 100644 index f56b586ef8b2..000000000000 --- a/test/css/samples/cascade-false/input.html +++ /dev/null @@ -1,16 +0,0 @@ -
red
-
bold/blue
- - \ No newline at end of file diff --git a/test/css/samples/combinator-child/_config.js b/test/css/samples/combinator-child/_config.js deleted file mode 100644 index b37866f9b61a..000000000000 --- a/test/css/samples/combinator-child/_config.js +++ /dev/null @@ -1,3 +0,0 @@ -export default { - cascade: false -}; \ No newline at end of file diff --git a/test/css/samples/css-vars/expected.css b/test/css/samples/css-vars/expected.css index 1b3a42567a63..ccb7a3ec4818 100644 --- a/test/css/samples/css-vars/expected.css +++ b/test/css/samples/css-vars/expected.css @@ -1 +1 @@ -div.svelte-xyz,.svelte-xyz div{--test:10} \ No newline at end of file +div.svelte-xyz{--test:10} \ No newline at end of file diff --git a/test/css/samples/descendant-selector-non-top-level-outer/_config.js b/test/css/samples/descendant-selector-non-top-level-outer/_config.js deleted file mode 100644 index b37866f9b61a..000000000000 --- a/test/css/samples/descendant-selector-non-top-level-outer/_config.js +++ /dev/null @@ -1,3 +0,0 @@ -export default { - cascade: false -}; \ No newline at end of file diff --git a/test/css/samples/empty-class/_config.js b/test/css/samples/empty-class/_config.js index e4953939ae83..fb1565c7bc39 100644 --- a/test/css/samples/empty-class/_config.js +++ b/test/css/samples/empty-class/_config.js @@ -1,13 +1,17 @@ export default { - cascade: false, - warnings: [{ filename: "SvelteComponent.html", code: `css-unused-selector`, message: "Unused CSS selector", - loc: { + start: { line: 4, - column: 1 + column: 1, + character: 31 + }, + end: { + line: 4, + column: 3, + character: 33 }, pos: 31, frame: ` diff --git a/test/css/samples/cascade-false-empty-rule-dev/_config.js b/test/css/samples/empty-rule-dev/_config.js similarity index 63% rename from test/css/samples/cascade-false-empty-rule-dev/_config.js rename to test/css/samples/empty-rule-dev/_config.js index 8b2e3aa34128..e26996239d88 100644 --- a/test/css/samples/cascade-false-empty-rule-dev/_config.js +++ b/test/css/samples/empty-rule-dev/_config.js @@ -1,4 +1,3 @@ export default { - cascade: false, dev: true }; \ No newline at end of file diff --git a/test/css/samples/cascade-false-empty-rule-dev/expected.css b/test/css/samples/empty-rule-dev/expected.css similarity index 100% rename from test/css/samples/cascade-false-empty-rule-dev/expected.css rename to test/css/samples/empty-rule-dev/expected.css diff --git a/test/css/samples/cascade-false-empty-rule-dev/input.html b/test/css/samples/empty-rule-dev/input.html similarity index 100% rename from test/css/samples/cascade-false-empty-rule-dev/input.html rename to test/css/samples/empty-rule-dev/input.html diff --git a/test/css/samples/cascade-false-empty-rule/expected.css b/test/css/samples/empty-rule/expected.css similarity index 100% rename from test/css/samples/cascade-false-empty-rule/expected.css rename to test/css/samples/empty-rule/expected.css diff --git a/test/css/samples/cascade-false-empty-rule/input.html b/test/css/samples/empty-rule/input.html similarity index 100% rename from test/css/samples/cascade-false-empty-rule/input.html rename to test/css/samples/empty-rule/input.html diff --git a/test/css/samples/cascade-false-global-keyframes/expected.css b/test/css/samples/global-keyframes/expected.css similarity index 100% rename from test/css/samples/cascade-false-global-keyframes/expected.css rename to test/css/samples/global-keyframes/expected.css diff --git a/test/css/samples/cascade-false-global-keyframes/input.html b/test/css/samples/global-keyframes/input.html similarity index 100% rename from test/css/samples/cascade-false-global-keyframes/input.html rename to test/css/samples/global-keyframes/input.html diff --git a/test/css/samples/cascade-false-global/expected.css b/test/css/samples/global/expected.css similarity index 100% rename from test/css/samples/cascade-false-global/expected.css rename to test/css/samples/global/expected.css diff --git a/test/css/samples/cascade-false-global/input.html b/test/css/samples/global/input.html similarity index 100% rename from test/css/samples/cascade-false-global/input.html rename to test/css/samples/global/input.html diff --git a/test/css/samples/cascade-false-keyframes-from-to/expected.css b/test/css/samples/keyframes-from-to/expected.css similarity index 100% rename from test/css/samples/cascade-false-keyframes-from-to/expected.css rename to test/css/samples/keyframes-from-to/expected.css diff --git a/test/css/samples/cascade-false-keyframes-from-to/input.html b/test/css/samples/keyframes-from-to/input.html similarity index 100% rename from test/css/samples/cascade-false-keyframes-from-to/input.html rename to test/css/samples/keyframes-from-to/input.html diff --git a/test/css/samples/keyframes/expected.css b/test/css/samples/keyframes/expected.css index 810ba8775131..a6a1176dae46 100644 --- a/test/css/samples/keyframes/expected.css +++ b/test/css/samples/keyframes/expected.css @@ -1 +1 @@ -@keyframes svelte-xyz-why{0%{color:red}100%{color:blue}}.svelte-xyz.animated,.svelte-xyz .animated{animation:svelte-xyz-why 2s} \ No newline at end of file +@keyframes svelte-xyz-why{0%{color:red}100%{color:blue}}.animated.svelte-xyz{animation:svelte-xyz-why 2s}.also-animated.svelte-xyz{animation:not-defined-here 2s} \ No newline at end of file diff --git a/test/css/samples/keyframes/input.html b/test/css/samples/keyframes/input.html index b4d120f34f16..ba220a5e22ce 100644 --- a/test/css/samples/keyframes/input.html +++ b/test/css/samples/keyframes/input.html @@ -1,4 +1,5 @@
animated
+
also animated
\ No newline at end of file diff --git a/test/css/samples/media-query-word/expected.css b/test/css/samples/media-query-word/expected.css index 592ba7e61ddb..d2a288ed7278 100644 --- a/test/css/samples/media-query-word/expected.css +++ b/test/css/samples/media-query-word/expected.css @@ -1 +1 @@ -@media only screen and (min-width: 400px){div.svelte-xyz,.svelte-xyz div{color:red}} \ No newline at end of file +@media only screen and (min-width: 400px){div.svelte-xyz{color:red}} \ No newline at end of file diff --git a/test/css/samples/media-query/expected.css b/test/css/samples/media-query/expected.css index 689161de04c3..8ea74bf3b1a4 100644 --- a/test/css/samples/media-query/expected.css +++ b/test/css/samples/media-query/expected.css @@ -1 +1 @@ -@media(min-width: 400px){.svelte-xyz.large-screen,.svelte-xyz .large-screen{display:block}} \ No newline at end of file +@media(min-width: 400px){.large-screen.svelte-xyz{display:block}} \ No newline at end of file diff --git a/test/css/samples/cascade-false-nested/_config.js b/test/css/samples/nested/_config.js similarity index 71% rename from test/css/samples/cascade-false-nested/_config.js rename to test/css/samples/nested/_config.js index b19fe39d2303..7cf5c058a6b8 100644 --- a/test/css/samples/cascade-false-nested/_config.js +++ b/test/css/samples/nested/_config.js @@ -1,6 +1,4 @@ export default { - cascade: false, - data: { dynamic: 'x' } diff --git a/test/css/samples/cascade-false-nested/expected.css b/test/css/samples/nested/expected.css similarity index 100% rename from test/css/samples/cascade-false-nested/expected.css rename to test/css/samples/nested/expected.css diff --git a/test/css/samples/cascade-false-nested/expected.html b/test/css/samples/nested/expected.html similarity index 100% rename from test/css/samples/cascade-false-nested/expected.html rename to test/css/samples/nested/expected.html diff --git a/test/css/samples/cascade-false-nested/input.html b/test/css/samples/nested/input.html similarity index 80% rename from test/css/samples/cascade-false-nested/input.html rename to test/css/samples/nested/input.html index a71a9a497c14..525860acbe62 100644 --- a/test/css/samples/cascade-false-nested/input.html +++ b/test/css/samples/nested/input.html @@ -3,7 +3,7 @@ - {{dynamic}} + {dynamic} \ No newline at end of file diff --git a/test/css/samples/cascade-false-pseudo-element/expected.css b/test/css/samples/pseudo-element/expected.css similarity index 100% rename from test/css/samples/cascade-false-pseudo-element/expected.css rename to test/css/samples/pseudo-element/expected.css diff --git a/test/css/samples/cascade-false-pseudo-element/input.html b/test/css/samples/pseudo-element/input.html similarity index 100% rename from test/css/samples/cascade-false-pseudo-element/input.html rename to test/css/samples/pseudo-element/input.html diff --git a/test/css/samples/refs-qualified/_config.js b/test/css/samples/refs-qualified/_config.js index b525fd8f5855..dbc3ac2b4ef1 100644 --- a/test/css/samples/refs-qualified/_config.js +++ b/test/css/samples/refs-qualified/_config.js @@ -1,6 +1,4 @@ export default { - cascade: false, - data: { active: true }, @@ -8,11 +6,17 @@ export default { warnings: [{ code: `css-unused-selector`, message: 'Unused CSS selector', - loc: { + start: { column: 1, - line: 12 + line: 12, + character: 169 + }, + end: { + column: 20, + line: 12, + character: 188 }, - pos: 174, + pos: 169, frame: ` 10: } 11: diff --git a/test/css/samples/refs-qualified/input.html b/test/css/samples/refs-qualified/input.html index 44ff33a3ce5e..f23a4f184540 100644 --- a/test/css/samples/refs-qualified/input.html +++ b/test/css/samples/refs-qualified/input.html @@ -1,8 +1,8 @@ -{{#if active}} +{#if active} -{{else}} +{:else} -{{/if}} +{/if} - - - - - - - - \ No newline at end of file diff --git a/test/js/samples/collapses-text-around-comments/input.html b/test/js/samples/collapses-text-around-comments/input.html index a6c1ae40f7fb..54c15b792200 100644 --- a/test/js/samples/collapses-text-around-comments/input.html +++ b/test/js/samples/collapses-text-around-comments/input.html @@ -3,7 +3,7 @@ -

{{foo}}

+

{foo}

diff --git a/test/js/samples/component-static-immutable/expected-bundle.js b/test/js/samples/component-static-immutable/expected-bundle.js index 27aa216840e0..235f57755d3a 100644 --- a/test/js/samples/component-static-immutable/expected-bundle.js +++ b/test/js/samples/component-static-immutable/expected-bundle.js @@ -43,8 +43,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -56,21 +56,7 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); @@ -126,18 +112,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/component-static-immutable2/expected-bundle.js b/test/js/samples/component-static-immutable2/expected-bundle.js index 27aa216840e0..235f57755d3a 100644 --- a/test/js/samples/component-static-immutable2/expected-bundle.js +++ b/test/js/samples/component-static-immutable2/expected-bundle.js @@ -43,8 +43,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -56,21 +56,7 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); @@ -126,18 +112,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/component-static/expected-bundle.js b/test/js/samples/component-static/expected-bundle.js index 91fb33207b16..dc4f6dbf0dd9 100644 --- a/test/js/samples/component-static/expected-bundle.js +++ b/test/js/samples/component-static/expected-bundle.js @@ -39,8 +39,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -52,21 +52,7 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); @@ -122,18 +108,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/computed-collapsed-if/expected-bundle.js b/test/js/samples/computed-collapsed-if/expected-bundle.js index 95e448f87489..8cd4bf0011db 100644 --- a/test/js/samples/computed-collapsed-if/expected-bundle.js +++ b/test/js/samples/computed-collapsed-if/expected-bundle.js @@ -39,8 +39,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -52,21 +52,7 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); @@ -122,27 +108,25 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ -function a(x) { +function a({ x }) { return x * 2; } -function b(x) { +function b({ x }) { return x * 3; } @@ -178,8 +162,8 @@ assign(SvelteComponent.prototype, proto); SvelteComponent.prototype._recompute = function _recompute(changed, state) { if (changed.x) { - if (this._differs(state.a, (state.a = a(state.x)))) changed.a = true; - if (this._differs(state.b, (state.b = b(state.x)))) changed.b = true; + if (this._differs(state.a, (state.a = a(state)))) changed.a = true; + if (this._differs(state.b, (state.b = b(state)))) changed.b = true; } }; diff --git a/test/js/samples/computed-collapsed-if/expected.js b/test/js/samples/computed-collapsed-if/expected.js index 2398f4bdee14..f1228ca0b698 100644 --- a/test/js/samples/computed-collapsed-if/expected.js +++ b/test/js/samples/computed-collapsed-if/expected.js @@ -1,11 +1,11 @@ /* generated by Svelte vX.Y.Z */ import { assign, init, noop, proto } from "svelte/shared.js"; -function a(x) { +function a({ x }) { return x * 2; } -function b(x) { +function b({ x }) { return x * 3; } @@ -41,8 +41,8 @@ assign(SvelteComponent.prototype, proto); SvelteComponent.prototype._recompute = function _recompute(changed, state) { if (changed.x) { - if (this._differs(state.a, (state.a = a(state.x)))) changed.a = true; - if (this._differs(state.b, (state.b = b(state.x)))) changed.b = true; + if (this._differs(state.a, (state.a = a(state)))) changed.a = true; + if (this._differs(state.b, (state.b = b(state)))) changed.b = true; } } export default SvelteComponent; \ No newline at end of file diff --git a/test/js/samples/computed-collapsed-if/input.html b/test/js/samples/computed-collapsed-if/input.html index a68513b860fe..c7280e5ef8bb 100644 --- a/test/js/samples/computed-collapsed-if/input.html +++ b/test/js/samples/computed-collapsed-if/input.html @@ -1,8 +1,8 @@ \ No newline at end of file diff --git a/test/js/samples/css-media-query/expected-bundle.js b/test/js/samples/css-media-query/expected-bundle.js index 79e3e3e456b6..6b1455f9c6ae 100644 --- a/test/js/samples/css-media-query/expected-bundle.js +++ b/test/js/samples/css-media-query/expected-bundle.js @@ -55,8 +55,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -68,21 +68,7 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); @@ -138,18 +124,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ @@ -157,7 +141,7 @@ var proto = { function add_css() { var style = createElement("style"); style.id = 'svelte-1slhpfn-style'; - style.textContent = "@media(min-width: 1px){div.svelte-1slhpfn,.svelte-1slhpfn div{color:red}}"; + style.textContent = "@media(min-width: 1px){div.svelte-1slhpfn{color:red}}"; appendNode(style, document.head); } diff --git a/test/js/samples/css-media-query/expected.js b/test/js/samples/css-media-query/expected.js index b5c91f76a9e4..893af2303512 100644 --- a/test/js/samples/css-media-query/expected.js +++ b/test/js/samples/css-media-query/expected.js @@ -4,7 +4,7 @@ import { appendNode, assign, createElement, detachNode, init, insertNode, noop, function add_css() { var style = createElement("style"); style.id = 'svelte-1slhpfn-style'; - style.textContent = "@media(min-width: 1px){div.svelte-1slhpfn,.svelte-1slhpfn div{color:red}}"; + style.textContent = "@media(min-width: 1px){div.svelte-1slhpfn{color:red}}"; appendNode(style, document.head); } 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 e320ba4218b5..c2f35f7b986e 100644 --- a/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js +++ b/test/js/samples/css-shadow-dom-keyframes/expected-bundle.js @@ -51,8 +51,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -64,21 +64,7 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); @@ -134,18 +120,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/deconflict-builtins/_actual-bundle-v2.js b/test/js/samples/deconflict-builtins/_actual-bundle-v2.js deleted file mode 100644 index a8dcb7e5f464..000000000000 --- a/test/js/samples/deconflict-builtins/_actual-bundle-v2.js +++ /dev/null @@ -1,292 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function appendNode(node, target) { - target.appendChild(node); -} - -function insertNode(node, target, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function destroyEach(iterations) { - for (var i = 0; i < iterations.length; i += 1) { - if (iterations[i]) iterations[i].d(); - } -} - -function createElement(name) { - return document.createElement(name); -} - -function createText(data) { - return document.createTextNode(data); -} - -function createComment() { - return document.createComment(''); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get(key) { - return key ? this._state[key] : this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, - _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var each_anchor; - - var each_value = state.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_value: each_value, - node: each_value[i], - node_index: i - })); - } - - return { - c: function create() { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].c(); - } - - each_anchor = createComment(); - }, - - m: function mount(target, anchor) { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].m(target, anchor); - } - - insertNode(each_anchor, target, anchor); - }, - - p: function update(changed, state) { - var each_value = state.createElement; - - if (changed.createElement) { - for (var i = 0; i < each_value.length; i += 1) { - var each_context = assign(assign({}, state), { - each_value: each_value, - node: each_value[i], - node_index: i - }); - - if (each_blocks[i]) { - each_blocks[i].p(changed, each_context); - } else { - each_blocks[i] = create_each_block(component, each_context); - each_blocks[i].c(); - each_blocks[i].m(each_anchor.parentNode, each_anchor); - } - } - - for (; i < each_blocks.length; i += 1) { - each_blocks[i].u(); - each_blocks[i].d(); - } - each_blocks.length = each_value.length; - } - }, - - u: function unmount() { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].u(); - } - - detachNode(each_anchor); - }, - - d: function destroy$$1() { - destroyEach(each_blocks); - } - }; -} - -// (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; - - return { - c: function create() { - span = createElement("span"); - text = createText(text_value); - }, - - m: function mount(target, anchor) { - insertNode(span, target, anchor); - 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)) { - text.data = text_value; - } - }, - - u: function unmount() { - detachNode(span); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/deconflict-builtins/expected-bundle-v2.js b/test/js/samples/deconflict-builtins/expected-bundle-v2.js deleted file mode 100644 index a8dcb7e5f464..000000000000 --- a/test/js/samples/deconflict-builtins/expected-bundle-v2.js +++ /dev/null @@ -1,292 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function appendNode(node, target) { - target.appendChild(node); -} - -function insertNode(node, target, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function destroyEach(iterations) { - for (var i = 0; i < iterations.length; i += 1) { - if (iterations[i]) iterations[i].d(); - } -} - -function createElement(name) { - return document.createElement(name); -} - -function createText(data) { - return document.createTextNode(data); -} - -function createComment() { - return document.createComment(''); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get(key) { - return key ? this._state[key] : this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, - _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var each_anchor; - - var each_value = state.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_value: each_value, - node: each_value[i], - node_index: i - })); - } - - return { - c: function create() { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].c(); - } - - each_anchor = createComment(); - }, - - m: function mount(target, anchor) { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].m(target, anchor); - } - - insertNode(each_anchor, target, anchor); - }, - - p: function update(changed, state) { - var each_value = state.createElement; - - if (changed.createElement) { - for (var i = 0; i < each_value.length; i += 1) { - var each_context = assign(assign({}, state), { - each_value: each_value, - node: each_value[i], - node_index: i - }); - - if (each_blocks[i]) { - each_blocks[i].p(changed, each_context); - } else { - each_blocks[i] = create_each_block(component, each_context); - each_blocks[i].c(); - each_blocks[i].m(each_anchor.parentNode, each_anchor); - } - } - - for (; i < each_blocks.length; i += 1) { - each_blocks[i].u(); - each_blocks[i].d(); - } - each_blocks.length = each_value.length; - } - }, - - u: function unmount() { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].u(); - } - - detachNode(each_anchor); - }, - - d: function destroy$$1() { - destroyEach(each_blocks); - } - }; -} - -// (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; - - return { - c: function create() { - span = createElement("span"); - text = createText(text_value); - }, - - m: function mount(target, anchor) { - insertNode(span, target, anchor); - 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)) { - text.data = text_value; - } - }, - - u: function unmount() { - detachNode(span); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/deconflict-builtins/expected-bundle.js b/test/js/samples/deconflict-builtins/expected-bundle.js index ee08884e3d1b..2f9dd2db1d49 100644 --- a/test/js/samples/deconflict-builtins/expected-bundle.js +++ b/test/js/samples/deconflict-builtins/expected-bundle.js @@ -69,8 +69,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -82,21 +82,7 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); @@ -152,18 +138,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ @@ -242,7 +226,7 @@ function create_main_fragment(component, state) { }; } -// (1:0) {{#each createElement as node}} +// (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; diff --git a/test/js/samples/deconflict-builtins/expected-v2.js b/test/js/samples/deconflict-builtins/expected-v2.js deleted file mode 100644 index f6861d255714..000000000000 --- a/test/js/samples/deconflict-builtins/expected-v2.js +++ /dev/null @@ -1,124 +0,0 @@ -/* 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) { - var each_anchor; - - var each_value = state.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_value: each_value, - node: each_value[i], - node_index: i - })); - } - - return { - c: function create() { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].c(); - } - - each_anchor = createComment(); - }, - - m: function mount(target, anchor) { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].m(target, anchor); - } - - insertNode(each_anchor, target, anchor); - }, - - p: function update(changed, state) { - var each_value = state.createElement; - - if (changed.createElement) { - for (var i = 0; i < each_value.length; i += 1) { - var each_context = assign(assign({}, state), { - each_value: each_value, - node: each_value[i], - node_index: i - }); - - if (each_blocks[i]) { - each_blocks[i].p(changed, each_context); - } else { - each_blocks[i] = create_each_block(component, each_context); - each_blocks[i].c(); - each_blocks[i].m(each_anchor.parentNode, each_anchor); - } - } - - for (; i < each_blocks.length; i += 1) { - each_blocks[i].u(); - each_blocks[i].d(); - } - each_blocks.length = each_value.length; - } - }, - - u: function unmount() { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].u(); - } - - detachNode(each_anchor); - }, - - d: function destroy() { - destroyEach(each_blocks); - } - }; -} - -// (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; - - return { - c: function create() { - span = createElement("span"); - text = createText(text_value); - }, - - m: function mount(target, anchor) { - insertNode(span, target, anchor); - 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)) { - text.data = text_value; - } - }, - - u: function unmount() { - detachNode(span); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); -export default SvelteComponent; \ No newline at end of file diff --git a/test/js/samples/deconflict-builtins/expected.js b/test/js/samples/deconflict-builtins/expected.js index e81e05fd32a6..f6861d255714 100644 --- a/test/js/samples/deconflict-builtins/expected.js +++ b/test/js/samples/deconflict-builtins/expected.js @@ -75,7 +75,7 @@ function create_main_fragment(component, state) { }; } -// (1:0) {{#each createElement as node}} +// (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; diff --git a/test/js/samples/deconflict-builtins/input-v2.html b/test/js/samples/deconflict-builtins/input-v2.html deleted file mode 100644 index 48a413b32353..000000000000 --- a/test/js/samples/deconflict-builtins/input-v2.html +++ /dev/null @@ -1,3 +0,0 @@ -{#each createElement as node} - {node} -{/each} \ No newline at end of file diff --git a/test/js/samples/deconflict-builtins/input.html b/test/js/samples/deconflict-builtins/input.html index a6556d00c557..48a413b32353 100644 --- a/test/js/samples/deconflict-builtins/input.html +++ b/test/js/samples/deconflict-builtins/input.html @@ -1,3 +1,3 @@ -{{#each createElement as node}} - {{node}} -{{/each}} \ No newline at end of file +{#each createElement as node} + {node} +{/each} \ No newline at end of file diff --git a/test/js/samples/deconflict-globals/expected-bundle.js b/test/js/samples/deconflict-globals/expected-bundle.js index 17898cf41485..214eed957865 100644 --- a/test/js/samples/deconflict-globals/expected-bundle.js +++ b/test/js/samples/deconflict-globals/expected-bundle.js @@ -39,8 +39,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -52,21 +52,7 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); @@ -122,18 +108,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/dev-warning-missing-data-computed/_actual-bundle-v2.js b/test/js/samples/dev-warning-missing-data-computed/_actual-bundle-v2.js deleted file mode 100644 index 69a58fa93330..000000000000 --- a/test/js/samples/dev-warning-missing-data-computed/_actual-bundle-v2.js +++ /dev/null @@ -1,280 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function appendNode(node, target) { - target.appendChild(node); -} - -function insertNode(node, target, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function createText(data) { - return document.createTextNode(data); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -function destroyDev(detach) { - destroy.call(this, detach); - this.destroy = function() { - console.warn('Component was already destroyed'); - }; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function getDev(key) { - if (key) console.warn("`let x = component.get('x')` is deprecated. Use `let { x } = component.get()` instead"); - return get.call(this, key); -} - -function get(key) { - return key ? this._state[key] : this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function observeDev(key, callback, options) { - console.warn("this.observe(key, (newValue, oldValue) => {...}) is deprecated. Use\n\n // runs before DOM updates\n this.on('state', ({ changed, current, previous }) => {...});\n\n // runs after DOM updates\n this.on('update', ...);\n\n...or add the observe method from the svelte-extras package"); - - var c = (key = '' + key).search(/[.[]/); - if (c > -1) { - var message = - 'The first argument to component.observe(...) must be the name of a top-level property'; - if (c > 0) - message += ", i.e. '" + key.slice(0, c) + "' rather than '" + key + "'"; - - throw new Error(message); - } - - return observe.call(this, key, callback, options); -} - -function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function onDev(eventName, handler) { - if (eventName === 'teardown') { - console.warn( - "Use component.on('destroy', ...) instead of component.on('teardown', ...) which has been deprecated and will be unsupported in Svelte 2" - ); - return this.on('destroy', handler); - } - - return on.call(this, eventName, handler); -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function setDev(newState) { - if (typeof newState !== 'object') { - throw new Error( - this._debugName + '.set was called without an object of data key-values to update.' - ); - } - - this._checkReadOnly(newState); - set.call(this, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var protoDev = { - destroy: destroyDev, - get: getDev, - fire: fire, - observe: observeDev, - on: onDev, - set: setDev, - teardown: destroyDev, - _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs -}; - -/* generated by Svelte vX.Y.Z */ - -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; - - return { - c: function create() { - p = createElement("p"); - text = createText(text_value); - text_1 = createText("\n\t"); - text_2 = createText(state.bar); - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - appendNode(text, p); - appendNode(text_1, p); - appendNode(text_2, p); - }, - - p: function update(changed, state) { - if ((changed.Math || changed.foo) && text_value !== (text_value = state.Math.max(0, state.foo))) { - text.data = text_value; - } - - if (changed.bar) { - text_2.data = state.bar; - } - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - this._debugName = ''; - if (!options || (!options.target && !options.root)) throw new Error("'target' is a required option"); - init(this, options); - this._state = assign({ Math : Math }, options.data); - this._recompute({ foo: 1 }, this._state); - if (!('foo' in this._state)) console.warn(" was created without expected data property 'foo'"); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - if (options.hydrate) throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option"); - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, protoDev); - -SvelteComponent.prototype._checkReadOnly = function _checkReadOnly(newState) { - if ('bar' in newState && !this._updatingReadonlyProperty) throw new Error(": Cannot set read-only property 'bar'"); -}; - -SvelteComponent.prototype._recompute = function _recompute(changed, state) { - if (changed.foo) { - if (this._differs(state.bar, (state.bar = bar(state)))) changed.bar = true; - } -}; - -export default SvelteComponent; diff --git a/test/js/samples/dev-warning-missing-data-computed/expected-bundle-v2.js b/test/js/samples/dev-warning-missing-data-computed/expected-bundle-v2.js deleted file mode 100644 index 69a58fa93330..000000000000 --- a/test/js/samples/dev-warning-missing-data-computed/expected-bundle-v2.js +++ /dev/null @@ -1,280 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function appendNode(node, target) { - target.appendChild(node); -} - -function insertNode(node, target, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function createText(data) { - return document.createTextNode(data); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -function destroyDev(detach) { - destroy.call(this, detach); - this.destroy = function() { - console.warn('Component was already destroyed'); - }; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function getDev(key) { - if (key) console.warn("`let x = component.get('x')` is deprecated. Use `let { x } = component.get()` instead"); - return get.call(this, key); -} - -function get(key) { - return key ? this._state[key] : this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function observeDev(key, callback, options) { - console.warn("this.observe(key, (newValue, oldValue) => {...}) is deprecated. Use\n\n // runs before DOM updates\n this.on('state', ({ changed, current, previous }) => {...});\n\n // runs after DOM updates\n this.on('update', ...);\n\n...or add the observe method from the svelte-extras package"); - - var c = (key = '' + key).search(/[.[]/); - if (c > -1) { - var message = - 'The first argument to component.observe(...) must be the name of a top-level property'; - if (c > 0) - message += ", i.e. '" + key.slice(0, c) + "' rather than '" + key + "'"; - - throw new Error(message); - } - - return observe.call(this, key, callback, options); -} - -function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function onDev(eventName, handler) { - if (eventName === 'teardown') { - console.warn( - "Use component.on('destroy', ...) instead of component.on('teardown', ...) which has been deprecated and will be unsupported in Svelte 2" - ); - return this.on('destroy', handler); - } - - return on.call(this, eventName, handler); -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function setDev(newState) { - if (typeof newState !== 'object') { - throw new Error( - this._debugName + '.set was called without an object of data key-values to update.' - ); - } - - this._checkReadOnly(newState); - set.call(this, newState); -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var protoDev = { - destroy: destroyDev, - get: getDev, - fire: fire, - observe: observeDev, - on: onDev, - set: setDev, - teardown: destroyDev, - _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs -}; - -/* generated by Svelte vX.Y.Z */ - -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; - - return { - c: function create() { - p = createElement("p"); - text = createText(text_value); - text_1 = createText("\n\t"); - text_2 = createText(state.bar); - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - appendNode(text, p); - appendNode(text_1, p); - appendNode(text_2, p); - }, - - p: function update(changed, state) { - if ((changed.Math || changed.foo) && text_value !== (text_value = state.Math.max(0, state.foo))) { - text.data = text_value; - } - - if (changed.bar) { - text_2.data = state.bar; - } - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - this._debugName = ''; - if (!options || (!options.target && !options.root)) throw new Error("'target' is a required option"); - init(this, options); - this._state = assign({ Math : Math }, options.data); - this._recompute({ foo: 1 }, this._state); - if (!('foo' in this._state)) console.warn(" was created without expected data property 'foo'"); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - if (options.hydrate) throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option"); - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, protoDev); - -SvelteComponent.prototype._checkReadOnly = function _checkReadOnly(newState) { - if ('bar' in newState && !this._updatingReadonlyProperty) throw new Error(": Cannot set read-only property 'bar'"); -}; - -SvelteComponent.prototype._recompute = function _recompute(changed, state) { - if (changed.foo) { - if (this._differs(state.bar, (state.bar = bar(state)))) changed.bar = true; - } -}; - -export default SvelteComponent; 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 caaf43221f89..e0ff6a11717d 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 @@ -66,13 +66,8 @@ function fire(eventName, data) { } } -function getDev(key) { - if (key) console.warn("`let x = component.get('x')` is deprecated. Use `let { x } = component.get()` instead"); - return get.call(this, key); -} - -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -84,37 +79,7 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function observeDev(key, callback, options) { - console.warn("this.observe(key, (newValue, oldValue) => {...}) is deprecated. Use\n\n // runs before DOM updates\n this.on('state', ({ changed, current, previous }) => {...});\n\n // runs after DOM updates\n this.on('update', ...);\n\n...or add the observe method from the svelte-extras package"); - - var c = (key = '' + key).search(/[.[]/); - if (c > -1) { - var message = - 'The first argument to component.observe(...) must be the name of a top-level property'; - if (c > 0) - message += ", i.e. '" + key.slice(0, c) + "' rather than '" + key + "'"; - - throw new Error(message); - } - - return observe.call(this, key, callback, options); -} - function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); @@ -126,17 +91,6 @@ function on(eventName, handler) { }; } -function onDev(eventName, handler) { - if (eventName === 'teardown') { - console.warn( - "Use component.on('destroy', ...) instead of component.on('teardown', ...) which has been deprecated and will be unsupported in Svelte 2" - ); - return this.on('destroy', handler); - } - - return on.call(this, eventName, handler); -} - function set(newState) { this._set(assign({}, newState)); if (this.root._lock) return; @@ -193,22 +147,20 @@ function _unmount() { var protoDev = { destroy: destroyDev, - get: getDev, - fire: fire, - observe: observeDev, - on: onDev, + get, + fire, + on, set: setDev, - teardown: destroyDev, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ -function bar(foo) { +function bar({ foo }) { return foo * 2; } @@ -273,7 +225,7 @@ SvelteComponent.prototype._checkReadOnly = function _checkReadOnly(newState) { SvelteComponent.prototype._recompute = function _recompute(changed, state) { if (changed.foo) { - if (this._differs(state.bar, (state.bar = bar(state.foo)))) changed.bar = true; + if (this._differs(state.bar, (state.bar = bar(state)))) changed.bar = true; } }; diff --git a/test/js/samples/dev-warning-missing-data-computed/expected-v2.js b/test/js/samples/dev-warning-missing-data-computed/expected-v2.js deleted file mode 100644 index 52dee37250c4..000000000000 --- a/test/js/samples/dev-warning-missing-data-computed/expected-v2.js +++ /dev/null @@ -1,72 +0,0 @@ -/* generated by Svelte vX.Y.Z */ -import { appendNode, assign, createElement, createText, detachNode, init, insertNode, noop, protoDev } from "svelte/shared.js"; - -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; - - return { - c: function create() { - p = createElement("p"); - text = createText(text_value); - text_1 = createText("\n\t"); - text_2 = createText(state.bar); - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - appendNode(text, p); - appendNode(text_1, p); - appendNode(text_2, p); - }, - - p: function update(changed, state) { - if ((changed.Math || changed.foo) && text_value !== (text_value = state.Math.max(0, state.foo))) { - text.data = text_value; - } - - if (changed.bar) { - text_2.data = state.bar; - } - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - this._debugName = ''; - if (!options || (!options.target && !options.root)) throw new Error("'target' is a required option"); - init(this, options); - this._state = assign({ Math : Math }, options.data); - this._recompute({ foo: 1 }, this._state); - if (!('foo' in this._state)) console.warn(" was created without expected data property 'foo'"); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - if (options.hydrate) throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option"); - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, protoDev); - -SvelteComponent.prototype._checkReadOnly = function _checkReadOnly(newState) { - if ('bar' in newState && !this._updatingReadonlyProperty) throw new Error(": Cannot set read-only property 'bar'"); -}; - -SvelteComponent.prototype._recompute = function _recompute(changed, state) { - if (changed.foo) { - if (this._differs(state.bar, (state.bar = bar(state)))) changed.bar = true; - } -} -export default SvelteComponent; \ No newline at end of file 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 edf4331457b6..52dee37250c4 100644 --- a/test/js/samples/dev-warning-missing-data-computed/expected.js +++ b/test/js/samples/dev-warning-missing-data-computed/expected.js @@ -1,7 +1,7 @@ /* generated by Svelte vX.Y.Z */ import { appendNode, assign, createElement, createText, detachNode, init, insertNode, noop, protoDev } from "svelte/shared.js"; -function bar(foo) { +function bar({ foo }) { return foo * 2; } @@ -66,7 +66,7 @@ SvelteComponent.prototype._checkReadOnly = function _checkReadOnly(newState) { SvelteComponent.prototype._recompute = function _recompute(changed, state) { if (changed.foo) { - if (this._differs(state.bar, (state.bar = bar(state.foo)))) changed.bar = true; + if (this._differs(state.bar, (state.bar = bar(state)))) changed.bar = true; } } export default SvelteComponent; \ No newline at end of file diff --git a/test/js/samples/dev-warning-missing-data-computed/input-v2.html b/test/js/samples/dev-warning-missing-data-computed/input-v2.html deleted file mode 100644 index 06eb210493b0..000000000000 --- a/test/js/samples/dev-warning-missing-data-computed/input-v2.html +++ /dev/null @@ -1,12 +0,0 @@ -

- {Math.max(0, foo)} - {bar} -

- - \ No newline at end of file diff --git a/test/js/samples/dev-warning-missing-data-computed/input.html b/test/js/samples/dev-warning-missing-data-computed/input.html index f497b6e82491..06eb210493b0 100644 --- a/test/js/samples/dev-warning-missing-data-computed/input.html +++ b/test/js/samples/dev-warning-missing-data-computed/input.html @@ -1,12 +1,12 @@

- {{Math.max(0, foo)}} - {{bar}} + {Math.max(0, foo)} + {bar}

\ No newline at end of file diff --git a/test/js/samples/do-use-dataset/_actual-bundle-v2.js b/test/js/samples/do-use-dataset/_actual-bundle-v2.js deleted file mode 100644 index 37bc15d30240..000000000000 --- a/test/js/samples/do-use-dataset/_actual-bundle-v2.js +++ /dev/null @@ -1,209 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insertNode(node, target, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function createText(data) { - return document.createTextNode(data); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get(key) { - return key ? this._state[key] : this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, - _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var div, text, div_1; - - return { - c: function create() { - div = createElement("div"); - text = createText("\n"); - div_1 = createElement("div"); - this.h(); - }, - - h: function hydrate() { - div.dataset.foo = "bar"; - div_1.dataset.foo = state.bar; - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - insertNode(text, target, anchor); - insertNode(div_1, target, anchor); - }, - - p: function update(changed, state) { - if (changed.bar) { - div_1.dataset.foo = state.bar; - } - }, - - u: function unmount() { - detachNode(div); - detachNode(text); - detachNode(div_1); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/do-use-dataset/expected-bundle-v2.js b/test/js/samples/do-use-dataset/expected-bundle-v2.js deleted file mode 100644 index 37bc15d30240..000000000000 --- a/test/js/samples/do-use-dataset/expected-bundle-v2.js +++ /dev/null @@ -1,209 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insertNode(node, target, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function createText(data) { - return document.createTextNode(data); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get(key) { - return key ? this._state[key] : this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, - _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var div, text, div_1; - - return { - c: function create() { - div = createElement("div"); - text = createText("\n"); - div_1 = createElement("div"); - this.h(); - }, - - h: function hydrate() { - div.dataset.foo = "bar"; - div_1.dataset.foo = state.bar; - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - insertNode(text, target, anchor); - insertNode(div_1, target, anchor); - }, - - p: function update(changed, state) { - if (changed.bar) { - div_1.dataset.foo = state.bar; - } - }, - - u: function unmount() { - detachNode(div); - detachNode(text); - detachNode(div_1); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/do-use-dataset/expected-bundle.js b/test/js/samples/do-use-dataset/expected-bundle.js index 37bc15d30240..32af7494c3df 100644 --- a/test/js/samples/do-use-dataset/expected-bundle.js +++ b/test/js/samples/do-use-dataset/expected-bundle.js @@ -55,8 +55,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -68,21 +68,7 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); @@ -138,18 +124,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/do-use-dataset/expected-v2.js b/test/js/samples/do-use-dataset/expected-v2.js deleted file mode 100644 index b88636a606d5..000000000000 --- a/test/js/samples/do-use-dataset/expected-v2.js +++ /dev/null @@ -1,55 +0,0 @@ -/* 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) { - var div, text, div_1; - - return { - c: function create() { - div = createElement("div"); - text = createText("\n"); - div_1 = createElement("div"); - this.h(); - }, - - h: function hydrate() { - div.dataset.foo = "bar"; - div_1.dataset.foo = state.bar; - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - insertNode(text, target, anchor); - insertNode(div_1, target, anchor); - }, - - p: function update(changed, state) { - if (changed.bar) { - div_1.dataset.foo = state.bar; - } - }, - - u: function unmount() { - detachNode(div); - detachNode(text); - detachNode(div_1); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); -export default SvelteComponent; \ No newline at end of file diff --git a/test/js/samples/do-use-dataset/input-v2.html b/test/js/samples/do-use-dataset/input-v2.html deleted file mode 100644 index fcd821731e49..000000000000 --- a/test/js/samples/do-use-dataset/input-v2.html +++ /dev/null @@ -1,2 +0,0 @@ -
-
diff --git a/test/js/samples/do-use-dataset/input.html b/test/js/samples/do-use-dataset/input.html index acd9d623b44b..fcd821731e49 100644 --- a/test/js/samples/do-use-dataset/input.html +++ b/test/js/samples/do-use-dataset/input.html @@ -1,2 +1,2 @@
-
+
diff --git a/test/js/samples/dont-use-dataset-in-legacy/_actual-bundle-v2.js b/test/js/samples/dont-use-dataset-in-legacy/_actual-bundle-v2.js deleted file mode 100644 index be43fd0e9b4d..000000000000 --- a/test/js/samples/dont-use-dataset-in-legacy/_actual-bundle-v2.js +++ /dev/null @@ -1,213 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insertNode(node, target, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function createText(data) { - return document.createTextNode(data); -} - -function setAttribute(node, attribute, value) { - node.setAttribute(attribute, value); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get(key) { - return key ? this._state[key] : this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, - _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var div, text, div_1; - - return { - c: function create() { - div = createElement("div"); - text = createText("\n"); - div_1 = createElement("div"); - this.h(); - }, - - h: function hydrate() { - setAttribute(div, "data-foo", "bar"); - setAttribute(div_1, "data-foo", state.bar); - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - insertNode(text, target, anchor); - insertNode(div_1, target, anchor); - }, - - p: function update(changed, state) { - if (changed.bar) { - setAttribute(div_1, "data-foo", state.bar); - } - }, - - u: function unmount() { - detachNode(div); - detachNode(text); - detachNode(div_1); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/dont-use-dataset-in-legacy/expected-bundle-v2.js b/test/js/samples/dont-use-dataset-in-legacy/expected-bundle-v2.js deleted file mode 100644 index be43fd0e9b4d..000000000000 --- a/test/js/samples/dont-use-dataset-in-legacy/expected-bundle-v2.js +++ /dev/null @@ -1,213 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insertNode(node, target, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function createText(data) { - return document.createTextNode(data); -} - -function setAttribute(node, attribute, value) { - node.setAttribute(attribute, value); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get(key) { - return key ? this._state[key] : this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, - _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var div, text, div_1; - - return { - c: function create() { - div = createElement("div"); - text = createText("\n"); - div_1 = createElement("div"); - this.h(); - }, - - h: function hydrate() { - setAttribute(div, "data-foo", "bar"); - setAttribute(div_1, "data-foo", state.bar); - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - insertNode(text, target, anchor); - insertNode(div_1, target, anchor); - }, - - p: function update(changed, state) { - if (changed.bar) { - setAttribute(div_1, "data-foo", state.bar); - } - }, - - u: function unmount() { - detachNode(div); - detachNode(text); - detachNode(div_1); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; 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 be43fd0e9b4d..5e9def191391 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 @@ -59,8 +59,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -72,21 +72,7 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); @@ -142,18 +128,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/dont-use-dataset-in-legacy/expected-v2.js b/test/js/samples/dont-use-dataset-in-legacy/expected-v2.js deleted file mode 100644 index 699da1270b87..000000000000 --- a/test/js/samples/dont-use-dataset-in-legacy/expected-v2.js +++ /dev/null @@ -1,55 +0,0 @@ -/* 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) { - var div, text, div_1; - - return { - c: function create() { - div = createElement("div"); - text = createText("\n"); - div_1 = createElement("div"); - this.h(); - }, - - h: function hydrate() { - setAttribute(div, "data-foo", "bar"); - setAttribute(div_1, "data-foo", state.bar); - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - insertNode(text, target, anchor); - insertNode(div_1, target, anchor); - }, - - p: function update(changed, state) { - if (changed.bar) { - setAttribute(div_1, "data-foo", state.bar); - } - }, - - u: function unmount() { - detachNode(div); - detachNode(text); - detachNode(div_1); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); -export default SvelteComponent; \ No newline at end of file diff --git a/test/js/samples/dont-use-dataset-in-legacy/input-v2.html b/test/js/samples/dont-use-dataset-in-legacy/input-v2.html deleted file mode 100644 index fcd821731e49..000000000000 --- a/test/js/samples/dont-use-dataset-in-legacy/input-v2.html +++ /dev/null @@ -1,2 +0,0 @@ -
-
diff --git a/test/js/samples/dont-use-dataset-in-legacy/input.html b/test/js/samples/dont-use-dataset-in-legacy/input.html index acd9d623b44b..fcd821731e49 100644 --- a/test/js/samples/dont-use-dataset-in-legacy/input.html +++ b/test/js/samples/dont-use-dataset-in-legacy/input.html @@ -1,2 +1,2 @@
-
+
diff --git a/test/js/samples/dont-use-dataset-in-svg/_actual-bundle-v2.js b/test/js/samples/dont-use-dataset-in-svg/_actual-bundle-v2.js deleted file mode 100644 index 1092b9ab86de..000000000000 --- a/test/js/samples/dont-use-dataset-in-svg/_actual-bundle-v2.js +++ /dev/null @@ -1,211 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function appendNode(node, target) { - target.appendChild(node); -} - -function insertNode(node, target, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createSvgElement(name) { - return document.createElementNS('http://www.w3.org/2000/svg', name); -} - -function setAttribute(node, attribute, value) { - node.setAttribute(attribute, value); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get(key) { - return key ? this._state[key] : this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, - _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var svg, g, g_1; - - return { - c: function create() { - svg = createSvgElement("svg"); - g = createSvgElement("g"); - g_1 = createSvgElement("g"); - this.h(); - }, - - h: function hydrate() { - setAttribute(g, "data-foo", "bar"); - setAttribute(g_1, "data-foo", state.bar); - }, - - m: function mount(target, anchor) { - insertNode(svg, target, anchor); - appendNode(g, svg); - appendNode(g_1, svg); - }, - - p: function update(changed, state) { - if (changed.bar) { - setAttribute(g_1, "data-foo", state.bar); - } - }, - - u: function unmount() { - detachNode(svg); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/dont-use-dataset-in-svg/expected-bundle-v2.js b/test/js/samples/dont-use-dataset-in-svg/expected-bundle-v2.js deleted file mode 100644 index 1092b9ab86de..000000000000 --- a/test/js/samples/dont-use-dataset-in-svg/expected-bundle-v2.js +++ /dev/null @@ -1,211 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function appendNode(node, target) { - target.appendChild(node); -} - -function insertNode(node, target, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createSvgElement(name) { - return document.createElementNS('http://www.w3.org/2000/svg', name); -} - -function setAttribute(node, attribute, value) { - node.setAttribute(attribute, value); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get(key) { - return key ? this._state[key] : this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, - _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var svg, g, g_1; - - return { - c: function create() { - svg = createSvgElement("svg"); - g = createSvgElement("g"); - g_1 = createSvgElement("g"); - this.h(); - }, - - h: function hydrate() { - setAttribute(g, "data-foo", "bar"); - setAttribute(g_1, "data-foo", state.bar); - }, - - m: function mount(target, anchor) { - insertNode(svg, target, anchor); - appendNode(g, svg); - appendNode(g_1, svg); - }, - - p: function update(changed, state) { - if (changed.bar) { - setAttribute(g_1, "data-foo", state.bar); - } - }, - - u: function unmount() { - detachNode(svg); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; 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 1092b9ab86de..54b8382a2db9 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 @@ -59,8 +59,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -72,21 +72,7 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); @@ -142,18 +128,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/dont-use-dataset-in-svg/expected-v2.js b/test/js/samples/dont-use-dataset-in-svg/expected-v2.js deleted file mode 100644 index 42693672549b..000000000000 --- a/test/js/samples/dont-use-dataset-in-svg/expected-v2.js +++ /dev/null @@ -1,53 +0,0 @@ -/* 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) { - var svg, g, g_1; - - return { - c: function create() { - svg = createSvgElement("svg"); - g = createSvgElement("g"); - g_1 = createSvgElement("g"); - this.h(); - }, - - h: function hydrate() { - setAttribute(g, "data-foo", "bar"); - setAttribute(g_1, "data-foo", state.bar); - }, - - m: function mount(target, anchor) { - insertNode(svg, target, anchor); - appendNode(g, svg); - appendNode(g_1, svg); - }, - - p: function update(changed, state) { - if (changed.bar) { - setAttribute(g_1, "data-foo", state.bar); - } - }, - - u: function unmount() { - detachNode(svg); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); -export default SvelteComponent; \ No newline at end of file diff --git a/test/js/samples/dont-use-dataset-in-svg/input-v2.html b/test/js/samples/dont-use-dataset-in-svg/input-v2.html deleted file mode 100644 index 3032322b8010..000000000000 --- a/test/js/samples/dont-use-dataset-in-svg/input-v2.html +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/test/js/samples/dont-use-dataset-in-svg/input.html b/test/js/samples/dont-use-dataset-in-svg/input.html index c351e2dc18e4..3032322b8010 100644 --- a/test/js/samples/dont-use-dataset-in-svg/input.html +++ b/test/js/samples/dont-use-dataset-in-svg/input.html @@ -1,4 +1,4 @@ - + diff --git a/test/js/samples/each-block-changed-check/_actual-bundle-v2.js b/test/js/samples/each-block-changed-check/_actual-bundle-v2.js deleted file mode 100644 index f7d0080cbdac..000000000000 --- a/test/js/samples/each-block-changed-check/_actual-bundle-v2.js +++ /dev/null @@ -1,339 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function appendNode(node, target) { - target.appendChild(node); -} - -function insertNode(node, target, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function detachAfter(before) { - while (before.nextSibling) { - before.parentNode.removeChild(before.nextSibling); - } -} - -function destroyEach(iterations) { - for (var i = 0; i < iterations.length; i += 1) { - if (iterations[i]) iterations[i].d(); - } -} - -function createElement(name) { - return document.createElement(name); -} - -function createText(data) { - return document.createTextNode(data); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get(key) { - return key ? this._state[key] : this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, - _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var text, p, text_1; - - var each_value = state.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_value: each_value, - comment: each_value[i], - i: i - })); - } - - return { - c: function create() { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].c(); - } - - text = createText("\n\n"); - p = createElement("p"); - text_1 = createText(state.foo); - }, - - m: function mount(target, anchor) { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].m(target, anchor); - } - - insertNode(text, target, anchor); - insertNode(p, target, anchor); - appendNode(text_1, p); - }, - - p: function update(changed, state) { - var each_value = state.comments; - - if (changed.comments || changed.elapsed || changed.time) { - for (var i = 0; i < each_value.length; i += 1) { - var each_context = assign(assign({}, state), { - each_value: each_value, - comment: each_value[i], - i: i - }); - - if (each_blocks[i]) { - each_blocks[i].p(changed, each_context); - } else { - each_blocks[i] = create_each_block(component, each_context); - each_blocks[i].c(); - each_blocks[i].m(text.parentNode, text); - } - } - - for (; i < each_blocks.length; i += 1) { - each_blocks[i].u(); - each_blocks[i].d(); - } - each_blocks.length = each_value.length; - } - - if (changed.foo) { - text_1.data = state.foo; - } - }, - - u: function unmount() { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].u(); - } - - detachNode(text); - detachNode(p); - }, - - d: function destroy$$1() { - destroyEach(each_blocks); - } - }; -} - -// (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; - - return { - c: function create() { - div = createElement("div"); - strong = createElement("strong"); - text = createText(i); - text_1 = createText("\n\n\t\t"); - span = createElement("span"); - text_2 = createText(text_2_value); - text_3 = createText(" wrote "); - text_4 = createText(text_4_value); - text_5 = createText(" ago:"); - text_6 = createText("\n\n\t\t"); - raw_before = createElement('noscript'); - this.h(); - }, - - h: function hydrate() { - span.className = "meta"; - div.className = "comment"; - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - appendNode(strong, div); - appendNode(text, strong); - appendNode(text_1, div); - appendNode(span, div); - appendNode(text_2, span); - appendNode(text_3, span); - appendNode(text_4, span); - appendNode(text_5, span); - appendNode(text_6, div); - appendNode(raw_before, div); - 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)) { - 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))) { - text_4.data = text_4_value; - } - - if ((changed.comments) && raw_value !== (raw_value = comment.html)) { - detachAfter(raw_before); - raw_before.insertAdjacentHTML("afterend", raw_value); - } - }, - - u: function unmount() { - detachAfter(raw_before); - - detachNode(div); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/each-block-changed-check/expected-bundle-v2.js b/test/js/samples/each-block-changed-check/expected-bundle-v2.js deleted file mode 100644 index f7d0080cbdac..000000000000 --- a/test/js/samples/each-block-changed-check/expected-bundle-v2.js +++ /dev/null @@ -1,339 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function appendNode(node, target) { - target.appendChild(node); -} - -function insertNode(node, target, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function detachAfter(before) { - while (before.nextSibling) { - before.parentNode.removeChild(before.nextSibling); - } -} - -function destroyEach(iterations) { - for (var i = 0; i < iterations.length; i += 1) { - if (iterations[i]) iterations[i].d(); - } -} - -function createElement(name) { - return document.createElement(name); -} - -function createText(data) { - return document.createTextNode(data); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get(key) { - return key ? this._state[key] : this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, - _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var text, p, text_1; - - var each_value = state.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_value: each_value, - comment: each_value[i], - i: i - })); - } - - return { - c: function create() { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].c(); - } - - text = createText("\n\n"); - p = createElement("p"); - text_1 = createText(state.foo); - }, - - m: function mount(target, anchor) { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].m(target, anchor); - } - - insertNode(text, target, anchor); - insertNode(p, target, anchor); - appendNode(text_1, p); - }, - - p: function update(changed, state) { - var each_value = state.comments; - - if (changed.comments || changed.elapsed || changed.time) { - for (var i = 0; i < each_value.length; i += 1) { - var each_context = assign(assign({}, state), { - each_value: each_value, - comment: each_value[i], - i: i - }); - - if (each_blocks[i]) { - each_blocks[i].p(changed, each_context); - } else { - each_blocks[i] = create_each_block(component, each_context); - each_blocks[i].c(); - each_blocks[i].m(text.parentNode, text); - } - } - - for (; i < each_blocks.length; i += 1) { - each_blocks[i].u(); - each_blocks[i].d(); - } - each_blocks.length = each_value.length; - } - - if (changed.foo) { - text_1.data = state.foo; - } - }, - - u: function unmount() { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].u(); - } - - detachNode(text); - detachNode(p); - }, - - d: function destroy$$1() { - destroyEach(each_blocks); - } - }; -} - -// (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; - - return { - c: function create() { - div = createElement("div"); - strong = createElement("strong"); - text = createText(i); - text_1 = createText("\n\n\t\t"); - span = createElement("span"); - text_2 = createText(text_2_value); - text_3 = createText(" wrote "); - text_4 = createText(text_4_value); - text_5 = createText(" ago:"); - text_6 = createText("\n\n\t\t"); - raw_before = createElement('noscript'); - this.h(); - }, - - h: function hydrate() { - span.className = "meta"; - div.className = "comment"; - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - appendNode(strong, div); - appendNode(text, strong); - appendNode(text_1, div); - appendNode(span, div); - appendNode(text_2, span); - appendNode(text_3, span); - appendNode(text_4, span); - appendNode(text_5, span); - appendNode(text_6, div); - appendNode(raw_before, div); - 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)) { - 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))) { - text_4.data = text_4_value; - } - - if ((changed.comments) && raw_value !== (raw_value = comment.html)) { - detachAfter(raw_before); - raw_before.insertAdjacentHTML("afterend", raw_value); - } - }, - - u: function unmount() { - detachAfter(raw_before); - - detachNode(div); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; 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 a3023dc6b1b6..89c3cab24320 100644 --- a/test/js/samples/each-block-changed-check/expected-bundle.js +++ b/test/js/samples/each-block-changed-check/expected-bundle.js @@ -71,8 +71,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -84,21 +84,7 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); @@ -154,18 +140,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ @@ -253,7 +237,7 @@ function create_main_fragment(component, state) { }; } -// (1:0) {{#each comments as comment, i}} +// (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; diff --git a/test/js/samples/each-block-changed-check/expected-v2.js b/test/js/samples/each-block-changed-check/expected-v2.js deleted file mode 100644 index e7e0ccca306f..000000000000 --- a/test/js/samples/each-block-changed-check/expected-v2.js +++ /dev/null @@ -1,169 +0,0 @@ -/* 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) { - var text, p, text_1; - - var each_value = state.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_value: each_value, - comment: each_value[i], - i: i - })); - } - - return { - c: function create() { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].c(); - } - - text = createText("\n\n"); - p = createElement("p"); - text_1 = createText(state.foo); - }, - - m: function mount(target, anchor) { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].m(target, anchor); - } - - insertNode(text, target, anchor); - insertNode(p, target, anchor); - appendNode(text_1, p); - }, - - p: function update(changed, state) { - var each_value = state.comments; - - if (changed.comments || changed.elapsed || changed.time) { - for (var i = 0; i < each_value.length; i += 1) { - var each_context = assign(assign({}, state), { - each_value: each_value, - comment: each_value[i], - i: i - }); - - if (each_blocks[i]) { - each_blocks[i].p(changed, each_context); - } else { - each_blocks[i] = create_each_block(component, each_context); - each_blocks[i].c(); - each_blocks[i].m(text.parentNode, text); - } - } - - for (; i < each_blocks.length; i += 1) { - each_blocks[i].u(); - each_blocks[i].d(); - } - each_blocks.length = each_value.length; - } - - if (changed.foo) { - text_1.data = state.foo; - } - }, - - u: function unmount() { - for (var i = 0; i < each_blocks.length; i += 1) { - each_blocks[i].u(); - } - - detachNode(text); - detachNode(p); - }, - - d: function destroy() { - destroyEach(each_blocks); - } - }; -} - -// (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; - - return { - c: function create() { - div = createElement("div"); - strong = createElement("strong"); - text = createText(i); - text_1 = createText("\n\n\t\t"); - span = createElement("span"); - text_2 = createText(text_2_value); - text_3 = createText(" wrote "); - text_4 = createText(text_4_value); - text_5 = createText(" ago:"); - text_6 = createText("\n\n\t\t"); - raw_before = createElement('noscript'); - this.h(); - }, - - h: function hydrate() { - span.className = "meta"; - div.className = "comment"; - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - appendNode(strong, div); - appendNode(text, strong); - appendNode(text_1, div); - appendNode(span, div); - appendNode(text_2, span); - appendNode(text_3, span); - appendNode(text_4, span); - appendNode(text_5, span); - appendNode(text_6, div); - appendNode(raw_before, div); - 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)) { - 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))) { - text_4.data = text_4_value; - } - - if ((changed.comments) && raw_value !== (raw_value = comment.html)) { - detachAfter(raw_before); - raw_before.insertAdjacentHTML("afterend", raw_value); - } - }, - - u: function unmount() { - detachAfter(raw_before); - - detachNode(div); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); -export default SvelteComponent; \ No newline at end of file diff --git a/test/js/samples/each-block-changed-check/expected.js b/test/js/samples/each-block-changed-check/expected.js index cefd0a133859..e7e0ccca306f 100644 --- a/test/js/samples/each-block-changed-check/expected.js +++ b/test/js/samples/each-block-changed-check/expected.js @@ -84,7 +84,7 @@ function create_main_fragment(component, state) { }; } -// (1:0) {{#each comments as comment, i}} +// (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; diff --git a/test/js/samples/each-block-changed-check/input-v2.html b/test/js/samples/each-block-changed-check/input-v2.html deleted file mode 100644 index b5b5703857c4..000000000000 --- a/test/js/samples/each-block-changed-check/input-v2.html +++ /dev/null @@ -1,13 +0,0 @@ -{#each comments as comment, i} -
- {i} - - - {comment.author} wrote {elapsed(comment.time, time)} ago: - - - {@html comment.html} -
-{/each} - -

{foo}

\ No newline at end of file diff --git a/test/js/samples/each-block-changed-check/input.html b/test/js/samples/each-block-changed-check/input.html index 5a80a1a6c17c..b5b5703857c4 100644 --- a/test/js/samples/each-block-changed-check/input.html +++ b/test/js/samples/each-block-changed-check/input.html @@ -1,13 +1,13 @@ -{{#each comments as comment, i}} +{#each comments as comment, i}
- {{i}} + {i} - {{comment.author}} wrote {{elapsed(comment.time, time)}} ago: + {comment.author} wrote {elapsed(comment.time, time)} ago: - {{{comment.html}}} + {@html comment.html}
-{{/each}} +{/each} -

{{foo}}

\ No newline at end of file +

{foo}

\ No newline at end of file diff --git a/test/js/samples/event-handlers-custom/expected-bundle.js b/test/js/samples/event-handlers-custom/expected-bundle.js index 861a3afc78bd..5d85e177e1b4 100644 --- a/test/js/samples/event-handlers-custom/expected-bundle.js +++ b/test/js/samples/event-handlers-custom/expected-bundle.js @@ -51,8 +51,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -64,21 +64,7 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); @@ -134,18 +120,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ @@ -187,7 +171,7 @@ function create_main_fragment(component, state) { }, d: function destroy$$1() { - foo_handler[foo_handler.destroy ? 'destroy' : 'teardown'](); + foo_handler.destroy(); } }; } diff --git a/test/js/samples/event-handlers-custom/expected.js b/test/js/samples/event-handlers-custom/expected.js index bfec4474065d..3975641534d1 100644 --- a/test/js/samples/event-handlers-custom/expected.js +++ b/test/js/samples/event-handlers-custom/expected.js @@ -39,7 +39,7 @@ function create_main_fragment(component, state) { }, d: function destroy() { - foo_handler[foo_handler.destroy ? 'destroy' : 'teardown'](); + foo_handler.destroy(); } }; } diff --git a/test/js/samples/head-no-whitespace/_actual-bundle-v2.js b/test/js/samples/head-no-whitespace/_actual-bundle-v2.js deleted file mode 100644 index e17d8ede6182..000000000000 --- a/test/js/samples/head-no-whitespace/_actual-bundle-v2.js +++ /dev/null @@ -1,200 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function appendNode(node, target) { - target.appendChild(node); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get(key) { - return key ? this._state[key] : this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, - _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var meta, meta_1; - - return { - c: function create() { - meta = createElement("meta"); - meta_1 = createElement("meta"); - this.h(); - }, - - h: function hydrate() { - meta.name = "twitter:creator"; - meta.content = "@sveltejs"; - meta_1.name = "twitter:title"; - meta_1.content = "Svelte"; - }, - - m: function mount(target, anchor) { - appendNode(meta, document.head); - appendNode(meta_1, document.head); - }, - - p: noop, - - u: function unmount() { - detachNode(meta); - detachNode(meta_1); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/head-no-whitespace/expected-bundle-v2.js b/test/js/samples/head-no-whitespace/expected-bundle-v2.js deleted file mode 100644 index e17d8ede6182..000000000000 --- a/test/js/samples/head-no-whitespace/expected-bundle-v2.js +++ /dev/null @@ -1,200 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function appendNode(node, target) { - target.appendChild(node); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get(key) { - return key ? this._state[key] : this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, - _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var meta, meta_1; - - return { - c: function create() { - meta = createElement("meta"); - meta_1 = createElement("meta"); - this.h(); - }, - - h: function hydrate() { - meta.name = "twitter:creator"; - meta.content = "@sveltejs"; - meta_1.name = "twitter:title"; - meta_1.content = "Svelte"; - }, - - m: function mount(target, anchor) { - appendNode(meta, document.head); - appendNode(meta_1, document.head); - }, - - p: noop, - - u: function unmount() { - detachNode(meta); - detachNode(meta_1); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/head-no-whitespace/expected-bundle.js b/test/js/samples/head-no-whitespace/expected-bundle.js index e17d8ede6182..7f88574b70f6 100644 --- a/test/js/samples/head-no-whitespace/expected-bundle.js +++ b/test/js/samples/head-no-whitespace/expected-bundle.js @@ -51,8 +51,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -64,21 +64,7 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); @@ -134,18 +120,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/head-no-whitespace/expected-v2.js b/test/js/samples/head-no-whitespace/expected-v2.js deleted file mode 100644 index 9818f4211658..000000000000 --- a/test/js/samples/head-no-whitespace/expected-v2.js +++ /dev/null @@ -1,50 +0,0 @@ -/* generated by Svelte vX.Y.Z */ -import { appendNode, assign, createElement, detachNode, init, noop, proto } from "svelte/shared.js"; - -function create_main_fragment(component, state) { - var meta, meta_1; - - return { - c: function create() { - meta = createElement("meta"); - meta_1 = createElement("meta"); - this.h(); - }, - - h: function hydrate() { - meta.name = "twitter:creator"; - meta.content = "@sveltejs"; - meta_1.name = "twitter:title"; - meta_1.content = "Svelte"; - }, - - m: function mount(target, anchor) { - appendNode(meta, document.head); - appendNode(meta_1, document.head); - }, - - p: noop, - - u: function unmount() { - detachNode(meta); - detachNode(meta_1); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); -export default SvelteComponent; \ No newline at end of file diff --git a/test/js/samples/head-no-whitespace/input-v2.html b/test/js/samples/head-no-whitespace/input-v2.html deleted file mode 100644 index 000b643abeb6..000000000000 --- a/test/js/samples/head-no-whitespace/input-v2.html +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/test/js/samples/head-no-whitespace/input.html b/test/js/samples/head-no-whitespace/input.html index 37c387083d39..000b643abeb6 100644 --- a/test/js/samples/head-no-whitespace/input.html +++ b/test/js/samples/head-no-whitespace/input.html @@ -1,4 +1,4 @@ -<:Head> + - \ No newline at end of file + \ No newline at end of file diff --git a/test/js/samples/if-block-no-update/_actual-bundle-v2.js b/test/js/samples/if-block-no-update/_actual-bundle-v2.js deleted file mode 100644 index 5569d332f8a6..000000000000 --- a/test/js/samples/if-block-no-update/_actual-bundle-v2.js +++ /dev/null @@ -1,258 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insertNode(node, target, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function createComment() { - return document.createComment(''); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get(key) { - return key ? this._state[key] : this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, - _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var if_block_anchor; - - function select_block_type(state) { - if (state.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); - - return { - c: function create() { - if_block.c(); - if_block_anchor = createComment(); - }, - - m: function mount(target, anchor) { - if_block.m(target, anchor); - insertNode(if_block_anchor, target, anchor); - }, - - p: function update(changed, state) { - if (current_block_type !== (current_block_type = select_block_type(state))) { - if_block.u(); - if_block.d(); - if_block = current_block_type(component, state); - if_block.c(); - if_block.m(if_block_anchor.parentNode, if_block_anchor); - } - }, - - u: function unmount() { - if_block.u(); - detachNode(if_block_anchor); - }, - - d: function destroy$$1() { - if_block.d(); - } - }; -} - -// (1:0) {#if foo} -function create_if_block(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "foo!"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -// (3:0) {:else} -function create_if_block_1(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "not foo!"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/if-block-no-update/expected-bundle-v2.js b/test/js/samples/if-block-no-update/expected-bundle-v2.js deleted file mode 100644 index 5569d332f8a6..000000000000 --- a/test/js/samples/if-block-no-update/expected-bundle-v2.js +++ /dev/null @@ -1,258 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insertNode(node, target, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function createComment() { - return document.createComment(''); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get(key) { - return key ? this._state[key] : this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, - _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var if_block_anchor; - - function select_block_type(state) { - if (state.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); - - return { - c: function create() { - if_block.c(); - if_block_anchor = createComment(); - }, - - m: function mount(target, anchor) { - if_block.m(target, anchor); - insertNode(if_block_anchor, target, anchor); - }, - - p: function update(changed, state) { - if (current_block_type !== (current_block_type = select_block_type(state))) { - if_block.u(); - if_block.d(); - if_block = current_block_type(component, state); - if_block.c(); - if_block.m(if_block_anchor.parentNode, if_block_anchor); - } - }, - - u: function unmount() { - if_block.u(); - detachNode(if_block_anchor); - }, - - d: function destroy$$1() { - if_block.d(); - } - }; -} - -// (1:0) {#if foo} -function create_if_block(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "foo!"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -// (3:0) {:else} -function create_if_block_1(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "not foo!"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; 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 c48994fc3bac..1760a2ca607f 100644 --- a/test/js/samples/if-block-no-update/expected-bundle.js +++ b/test/js/samples/if-block-no-update/expected-bundle.js @@ -55,8 +55,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -68,21 +68,7 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); @@ -138,18 +124,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ @@ -197,7 +181,7 @@ function create_main_fragment(component, state) { }; } -// (1:0) {{#if foo}} +// (1:0) {#if foo} function create_if_block(component, state) { var p; @@ -219,7 +203,7 @@ function create_if_block(component, state) { }; } -// (3:0) {{else}} +// (3:0) {:else} function create_if_block_1(component, state) { var p; diff --git a/test/js/samples/if-block-no-update/expected-v2.js b/test/js/samples/if-block-no-update/expected-v2.js deleted file mode 100644 index c06ff6ee679a..000000000000 --- a/test/js/samples/if-block-no-update/expected-v2.js +++ /dev/null @@ -1,104 +0,0 @@ -/* 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) { - var if_block_anchor; - - function select_block_type(state) { - if (state.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); - - return { - c: function create() { - if_block.c(); - if_block_anchor = createComment(); - }, - - m: function mount(target, anchor) { - if_block.m(target, anchor); - insertNode(if_block_anchor, target, anchor); - }, - - p: function update(changed, state) { - if (current_block_type !== (current_block_type = select_block_type(state))) { - if_block.u(); - if_block.d(); - if_block = current_block_type(component, state); - if_block.c(); - if_block.m(if_block_anchor.parentNode, if_block_anchor); - } - }, - - u: function unmount() { - if_block.u(); - detachNode(if_block_anchor); - }, - - d: function destroy() { - if_block.d(); - } - }; -} - -// (1:0) {#if foo} -function create_if_block(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "foo!"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -// (3:0) {:else} -function create_if_block_1(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "not foo!"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); -export default SvelteComponent; \ No newline at end of file diff --git a/test/js/samples/if-block-no-update/expected.js b/test/js/samples/if-block-no-update/expected.js index af8b381ba422..c06ff6ee679a 100644 --- a/test/js/samples/if-block-no-update/expected.js +++ b/test/js/samples/if-block-no-update/expected.js @@ -44,7 +44,7 @@ function create_main_fragment(component, state) { }; } -// (1:0) {{#if foo}} +// (1:0) {#if foo} function create_if_block(component, state) { var p; @@ -66,7 +66,7 @@ function create_if_block(component, state) { }; } -// (3:0) {{else}} +// (3:0) {:else} function create_if_block_1(component, state) { var p; diff --git a/test/js/samples/if-block-no-update/input-v2.html b/test/js/samples/if-block-no-update/input-v2.html deleted file mode 100644 index 57de21915969..000000000000 --- a/test/js/samples/if-block-no-update/input-v2.html +++ /dev/null @@ -1,5 +0,0 @@ -{#if foo} -

foo!

-{:else} -

not foo!

-{/if} \ No newline at end of file diff --git a/test/js/samples/if-block-no-update/input.html b/test/js/samples/if-block-no-update/input.html index c73bfc624277..57de21915969 100644 --- a/test/js/samples/if-block-no-update/input.html +++ b/test/js/samples/if-block-no-update/input.html @@ -1,5 +1,5 @@ -{{#if foo}} +{#if foo}

foo!

-{{else}} +{:else}

not foo!

-{{/if}} \ No newline at end of file +{/if} \ No newline at end of file diff --git a/test/js/samples/if-block-simple/_actual-bundle-v2.js b/test/js/samples/if-block-simple/_actual-bundle-v2.js deleted file mode 100644 index 336cd0bc5d15..000000000000 --- a/test/js/samples/if-block-simple/_actual-bundle-v2.js +++ /dev/null @@ -1,234 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insertNode(node, target, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function createComment() { - return document.createComment(''); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get(key) { - return key ? this._state[key] : this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, - _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var if_block_anchor; - - var if_block = (state.foo) && create_if_block(component, state); - - return { - c: function create() { - if (if_block) if_block.c(); - if_block_anchor = createComment(); - }, - - m: function mount(target, anchor) { - if (if_block) if_block.m(target, anchor); - insertNode(if_block_anchor, target, anchor); - }, - - p: function update(changed, state) { - if (state.foo) { - if (!if_block) { - if_block = create_if_block(component, state); - if_block.c(); - if_block.m(if_block_anchor.parentNode, if_block_anchor); - } - } else if (if_block) { - if_block.u(); - if_block.d(); - if_block = null; - } - }, - - u: function unmount() { - if (if_block) if_block.u(); - detachNode(if_block_anchor); - }, - - d: function destroy$$1() { - if (if_block) if_block.d(); - } - }; -} - -// (1:0) {#if foo} -function create_if_block(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "foo!"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/if-block-simple/expected-bundle-v2.js b/test/js/samples/if-block-simple/expected-bundle-v2.js deleted file mode 100644 index 336cd0bc5d15..000000000000 --- a/test/js/samples/if-block-simple/expected-bundle-v2.js +++ /dev/null @@ -1,234 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insertNode(node, target, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function createComment() { - return document.createComment(''); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get(key) { - return key ? this._state[key] : this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, - _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var if_block_anchor; - - var if_block = (state.foo) && create_if_block(component, state); - - return { - c: function create() { - if (if_block) if_block.c(); - if_block_anchor = createComment(); - }, - - m: function mount(target, anchor) { - if (if_block) if_block.m(target, anchor); - insertNode(if_block_anchor, target, anchor); - }, - - p: function update(changed, state) { - if (state.foo) { - if (!if_block) { - if_block = create_if_block(component, state); - if_block.c(); - if_block.m(if_block_anchor.parentNode, if_block_anchor); - } - } else if (if_block) { - if_block.u(); - if_block.d(); - if_block = null; - } - }, - - u: function unmount() { - if (if_block) if_block.u(); - detachNode(if_block_anchor); - }, - - d: function destroy$$1() { - if (if_block) if_block.d(); - } - }; -} - -// (1:0) {#if foo} -function create_if_block(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "foo!"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/if-block-simple/expected-bundle.js b/test/js/samples/if-block-simple/expected-bundle.js index 47065fea5866..f71aafff9415 100644 --- a/test/js/samples/if-block-simple/expected-bundle.js +++ b/test/js/samples/if-block-simple/expected-bundle.js @@ -55,8 +55,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -68,21 +68,7 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); @@ -138,18 +124,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ @@ -195,7 +179,7 @@ function create_main_fragment(component, state) { }; } -// (1:0) {{#if foo}} +// (1:0) {#if foo} function create_if_block(component, state) { var p; diff --git a/test/js/samples/if-block-simple/expected-v2.js b/test/js/samples/if-block-simple/expected-v2.js deleted file mode 100644 index b3447471d31e..000000000000 --- a/test/js/samples/if-block-simple/expected-v2.js +++ /dev/null @@ -1,80 +0,0 @@ -/* 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) { - var if_block_anchor; - - var if_block = (state.foo) && create_if_block(component, state); - - return { - c: function create() { - if (if_block) if_block.c(); - if_block_anchor = createComment(); - }, - - m: function mount(target, anchor) { - if (if_block) if_block.m(target, anchor); - insertNode(if_block_anchor, target, anchor); - }, - - p: function update(changed, state) { - if (state.foo) { - if (!if_block) { - if_block = create_if_block(component, state); - if_block.c(); - if_block.m(if_block_anchor.parentNode, if_block_anchor); - } - } else if (if_block) { - if_block.u(); - if_block.d(); - if_block = null; - } - }, - - u: function unmount() { - if (if_block) if_block.u(); - detachNode(if_block_anchor); - }, - - d: function destroy() { - if (if_block) if_block.d(); - } - }; -} - -// (1:0) {#if foo} -function create_if_block(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "foo!"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); -export default SvelteComponent; \ No newline at end of file diff --git a/test/js/samples/if-block-simple/expected.js b/test/js/samples/if-block-simple/expected.js index 11d3ccbdc645..b3447471d31e 100644 --- a/test/js/samples/if-block-simple/expected.js +++ b/test/js/samples/if-block-simple/expected.js @@ -42,7 +42,7 @@ function create_main_fragment(component, state) { }; } -// (1:0) {{#if foo}} +// (1:0) {#if foo} function create_if_block(component, state) { var p; diff --git a/test/js/samples/if-block-simple/input-v2.html b/test/js/samples/if-block-simple/input-v2.html deleted file mode 100644 index e36517e10c2d..000000000000 --- a/test/js/samples/if-block-simple/input-v2.html +++ /dev/null @@ -1,3 +0,0 @@ -{#if foo} -

foo!

-{/if} \ No newline at end of file diff --git a/test/js/samples/if-block-simple/input.html b/test/js/samples/if-block-simple/input.html index 050095b913a8..e36517e10c2d 100644 --- a/test/js/samples/if-block-simple/input.html +++ b/test/js/samples/if-block-simple/input.html @@ -1,3 +1,3 @@ -{{#if foo}} +{#if foo}

foo!

-{{/if}} \ No newline at end of file +{/if} \ No newline at end of file diff --git a/test/js/samples/inline-style-optimized-multiple/_actual-bundle-v2.js b/test/js/samples/inline-style-optimized-multiple/_actual-bundle-v2.js deleted file mode 100644 index 035b3d9414a6..000000000000 --- a/test/js/samples/inline-style-optimized-multiple/_actual-bundle-v2.js +++ /dev/null @@ -1,207 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insertNode(node, target, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function setStyle(node, key, value) { - node.style.setProperty(key, value); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get(key) { - return key ? this._state[key] : this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, - _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var div; - - return { - c: function create() { - div = createElement("div"); - this.h(); - }, - - h: function hydrate() { - setStyle(div, "color", state.color); - setStyle(div, "transform", "translate(" + state.x + "px," + state.y + "px)"); - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - }, - - p: function update(changed, state) { - if (changed.color) { - setStyle(div, "color", state.color); - } - - if (changed.x || changed.y) { - setStyle(div, "transform", "translate(" + state.x + "px," + state.y + "px)"); - } - }, - - u: function unmount() { - detachNode(div); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/inline-style-optimized-multiple/expected-bundle-v2.js b/test/js/samples/inline-style-optimized-multiple/expected-bundle-v2.js deleted file mode 100644 index 035b3d9414a6..000000000000 --- a/test/js/samples/inline-style-optimized-multiple/expected-bundle-v2.js +++ /dev/null @@ -1,207 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insertNode(node, target, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function setStyle(node, key, value) { - node.style.setProperty(key, value); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get(key) { - return key ? this._state[key] : this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, - _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var div; - - return { - c: function create() { - div = createElement("div"); - this.h(); - }, - - h: function hydrate() { - setStyle(div, "color", state.color); - setStyle(div, "transform", "translate(" + state.x + "px," + state.y + "px)"); - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - }, - - p: function update(changed, state) { - if (changed.color) { - setStyle(div, "color", state.color); - } - - if (changed.x || changed.y) { - setStyle(div, "transform", "translate(" + state.x + "px," + state.y + "px)"); - } - }, - - u: function unmount() { - detachNode(div); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; 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 035b3d9414a6..bd3bacfac27a 100644 --- a/test/js/samples/inline-style-optimized-multiple/expected-bundle.js +++ b/test/js/samples/inline-style-optimized-multiple/expected-bundle.js @@ -55,8 +55,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -68,21 +68,7 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); @@ -138,18 +124,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/inline-style-optimized-multiple/expected-v2.js b/test/js/samples/inline-style-optimized-multiple/expected-v2.js deleted file mode 100644 index 7a94993b690c..000000000000 --- a/test/js/samples/inline-style-optimized-multiple/expected-v2.js +++ /dev/null @@ -1,53 +0,0 @@ -/* 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) { - var div; - - return { - c: function create() { - div = createElement("div"); - this.h(); - }, - - h: function hydrate() { - setStyle(div, "color", state.color); - setStyle(div, "transform", "translate(" + state.x + "px," + state.y + "px)"); - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - }, - - p: function update(changed, state) { - if (changed.color) { - setStyle(div, "color", state.color); - } - - if (changed.x || changed.y) { - setStyle(div, "transform", "translate(" + state.x + "px," + state.y + "px)"); - } - }, - - u: function unmount() { - detachNode(div); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); -export default SvelteComponent; \ No newline at end of file diff --git a/test/js/samples/inline-style-optimized-multiple/input-v2.html b/test/js/samples/inline-style-optimized-multiple/input-v2.html deleted file mode 100644 index d9448e0ab06d..000000000000 --- a/test/js/samples/inline-style-optimized-multiple/input-v2.html +++ /dev/null @@ -1 +0,0 @@ -
\ No newline at end of file diff --git a/test/js/samples/inline-style-optimized-multiple/input.html b/test/js/samples/inline-style-optimized-multiple/input.html index 92d9cb805d72..d9448e0ab06d 100644 --- a/test/js/samples/inline-style-optimized-multiple/input.html +++ b/test/js/samples/inline-style-optimized-multiple/input.html @@ -1 +1 @@ -
\ No newline at end of file +
\ No newline at end of file diff --git a/test/js/samples/inline-style-optimized-url/_actual-bundle-v2.js b/test/js/samples/inline-style-optimized-url/_actual-bundle-v2.js deleted file mode 100644 index b08091489f6e..000000000000 --- a/test/js/samples/inline-style-optimized-url/_actual-bundle-v2.js +++ /dev/null @@ -1,202 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insertNode(node, target, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function setStyle(node, key, value) { - node.style.setProperty(key, value); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get(key) { - return key ? this._state[key] : this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, - _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var div; - - return { - c: function create() { - div = createElement("div"); - this.h(); - }, - - h: function hydrate() { - setStyle(div, "background", "url(data:image/png;base64," + state.data + ")"); - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - }, - - p: function update(changed, state) { - if (changed.data) { - setStyle(div, "background", "url(data:image/png;base64," + state.data + ")"); - } - }, - - u: function unmount() { - detachNode(div); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/inline-style-optimized-url/expected-bundle-v2.js b/test/js/samples/inline-style-optimized-url/expected-bundle-v2.js deleted file mode 100644 index b08091489f6e..000000000000 --- a/test/js/samples/inline-style-optimized-url/expected-bundle-v2.js +++ /dev/null @@ -1,202 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insertNode(node, target, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function setStyle(node, key, value) { - node.style.setProperty(key, value); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get(key) { - return key ? this._state[key] : this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, - _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var div; - - return { - c: function create() { - div = createElement("div"); - this.h(); - }, - - h: function hydrate() { - setStyle(div, "background", "url(data:image/png;base64," + state.data + ")"); - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - }, - - p: function update(changed, state) { - if (changed.data) { - setStyle(div, "background", "url(data:image/png;base64," + state.data + ")"); - } - }, - - u: function unmount() { - detachNode(div); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; 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 b08091489f6e..411990568209 100644 --- a/test/js/samples/inline-style-optimized-url/expected-bundle.js +++ b/test/js/samples/inline-style-optimized-url/expected-bundle.js @@ -55,8 +55,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -68,21 +68,7 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); @@ -138,18 +124,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/inline-style-optimized-url/expected-v2.js b/test/js/samples/inline-style-optimized-url/expected-v2.js deleted file mode 100644 index 5a27ecfa4948..000000000000 --- a/test/js/samples/inline-style-optimized-url/expected-v2.js +++ /dev/null @@ -1,48 +0,0 @@ -/* 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) { - var div; - - return { - c: function create() { - div = createElement("div"); - this.h(); - }, - - h: function hydrate() { - setStyle(div, "background", "url(data:image/png;base64," + state.data + ")"); - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - }, - - p: function update(changed, state) { - if (changed.data) { - setStyle(div, "background", "url(data:image/png;base64," + state.data + ")"); - } - }, - - u: function unmount() { - detachNode(div); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); -export default SvelteComponent; \ No newline at end of file diff --git a/test/js/samples/inline-style-optimized-url/input-v2.html b/test/js/samples/inline-style-optimized-url/input-v2.html deleted file mode 100644 index 677da52c30f4..000000000000 --- a/test/js/samples/inline-style-optimized-url/input-v2.html +++ /dev/null @@ -1 +0,0 @@ -
\ No newline at end of file diff --git a/test/js/samples/inline-style-optimized-url/input.html b/test/js/samples/inline-style-optimized-url/input.html index 7e3b2928eb23..677da52c30f4 100644 --- a/test/js/samples/inline-style-optimized-url/input.html +++ b/test/js/samples/inline-style-optimized-url/input.html @@ -1 +1 @@ -
\ No newline at end of file +
\ No newline at end of file diff --git a/test/js/samples/inline-style-optimized/_actual-bundle-v2.js b/test/js/samples/inline-style-optimized/_actual-bundle-v2.js deleted file mode 100644 index fcd458c35683..000000000000 --- a/test/js/samples/inline-style-optimized/_actual-bundle-v2.js +++ /dev/null @@ -1,202 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insertNode(node, target, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function setStyle(node, key, value) { - node.style.setProperty(key, value); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get(key) { - return key ? this._state[key] : this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, - _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var div; - - return { - c: function create() { - div = createElement("div"); - this.h(); - }, - - h: function hydrate() { - setStyle(div, "color", state.color); - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - }, - - p: function update(changed, state) { - if (changed.color) { - setStyle(div, "color", state.color); - } - }, - - u: function unmount() { - detachNode(div); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/inline-style-optimized/expected-bundle-v2.js b/test/js/samples/inline-style-optimized/expected-bundle-v2.js deleted file mode 100644 index fcd458c35683..000000000000 --- a/test/js/samples/inline-style-optimized/expected-bundle-v2.js +++ /dev/null @@ -1,202 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insertNode(node, target, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function setStyle(node, key, value) { - node.style.setProperty(key, value); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get(key) { - return key ? this._state[key] : this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, - _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var div; - - return { - c: function create() { - div = createElement("div"); - this.h(); - }, - - h: function hydrate() { - setStyle(div, "color", state.color); - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - }, - - p: function update(changed, state) { - if (changed.color) { - setStyle(div, "color", state.color); - } - }, - - u: function unmount() { - detachNode(div); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/inline-style-optimized/expected-bundle.js b/test/js/samples/inline-style-optimized/expected-bundle.js index fcd458c35683..7643ee066d12 100644 --- a/test/js/samples/inline-style-optimized/expected-bundle.js +++ b/test/js/samples/inline-style-optimized/expected-bundle.js @@ -55,8 +55,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -68,21 +68,7 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); @@ -138,18 +124,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/inline-style-optimized/expected-v2.js b/test/js/samples/inline-style-optimized/expected-v2.js deleted file mode 100644 index 86dabe8d21e1..000000000000 --- a/test/js/samples/inline-style-optimized/expected-v2.js +++ /dev/null @@ -1,48 +0,0 @@ -/* 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) { - var div; - - return { - c: function create() { - div = createElement("div"); - this.h(); - }, - - h: function hydrate() { - setStyle(div, "color", state.color); - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - }, - - p: function update(changed, state) { - if (changed.color) { - setStyle(div, "color", state.color); - } - }, - - u: function unmount() { - detachNode(div); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); -export default SvelteComponent; \ No newline at end of file diff --git a/test/js/samples/inline-style-optimized/input-v2.html b/test/js/samples/inline-style-optimized/input-v2.html deleted file mode 100644 index 004fd595c94f..000000000000 --- a/test/js/samples/inline-style-optimized/input-v2.html +++ /dev/null @@ -1 +0,0 @@ -
\ No newline at end of file diff --git a/test/js/samples/inline-style-optimized/input.html b/test/js/samples/inline-style-optimized/input.html index ff7d95fb6efa..004fd595c94f 100644 --- a/test/js/samples/inline-style-optimized/input.html +++ b/test/js/samples/inline-style-optimized/input.html @@ -1 +1 @@ -
\ No newline at end of file +
\ No newline at end of file diff --git a/test/js/samples/inline-style-unoptimized/_actual-bundle-v2.js b/test/js/samples/inline-style-unoptimized/_actual-bundle-v2.js deleted file mode 100644 index f7034d900720..000000000000 --- a/test/js/samples/inline-style-unoptimized/_actual-bundle-v2.js +++ /dev/null @@ -1,213 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insertNode(node, target, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function createText(data) { - return document.createTextNode(data); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get(key) { - return key ? this._state[key] : this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, - _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var div, text, div_1, div_1_style_value; - - return { - c: function create() { - div = createElement("div"); - text = createText("\n"); - div_1 = createElement("div"); - this.h(); - }, - - h: function hydrate() { - div.style.cssText = state.style; - div_1.style.cssText = div_1_style_value = "" + state.key + ": " + state.value; - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - insertNode(text, target, anchor); - insertNode(div_1, target, anchor); - }, - - p: function update(changed, state) { - if (changed.style) { - div.style.cssText = state.style; - } - - if ((changed.key || changed.value) && div_1_style_value !== (div_1_style_value = "" + state.key + ": " + state.value)) { - div_1.style.cssText = div_1_style_value; - } - }, - - u: function unmount() { - detachNode(div); - detachNode(text); - detachNode(div_1); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/inline-style-unoptimized/expected-bundle-v2.js b/test/js/samples/inline-style-unoptimized/expected-bundle-v2.js deleted file mode 100644 index f7034d900720..000000000000 --- a/test/js/samples/inline-style-unoptimized/expected-bundle-v2.js +++ /dev/null @@ -1,213 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insertNode(node, target, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function createText(data) { - return document.createTextNode(data); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get(key) { - return key ? this._state[key] : this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, - _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var div, text, div_1, div_1_style_value; - - return { - c: function create() { - div = createElement("div"); - text = createText("\n"); - div_1 = createElement("div"); - this.h(); - }, - - h: function hydrate() { - div.style.cssText = state.style; - div_1.style.cssText = div_1_style_value = "" + state.key + ": " + state.value; - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - insertNode(text, target, anchor); - insertNode(div_1, target, anchor); - }, - - p: function update(changed, state) { - if (changed.style) { - div.style.cssText = state.style; - } - - if ((changed.key || changed.value) && div_1_style_value !== (div_1_style_value = "" + state.key + ": " + state.value)) { - div_1.style.cssText = div_1_style_value; - } - }, - - u: function unmount() { - detachNode(div); - detachNode(text); - detachNode(div_1); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/inline-style-unoptimized/expected-bundle.js b/test/js/samples/inline-style-unoptimized/expected-bundle.js index f7034d900720..67b27347432a 100644 --- a/test/js/samples/inline-style-unoptimized/expected-bundle.js +++ b/test/js/samples/inline-style-unoptimized/expected-bundle.js @@ -55,8 +55,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -68,21 +68,7 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); @@ -138,18 +124,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/inline-style-unoptimized/expected-v2.js b/test/js/samples/inline-style-unoptimized/expected-v2.js deleted file mode 100644 index 7d7e933c1226..000000000000 --- a/test/js/samples/inline-style-unoptimized/expected-v2.js +++ /dev/null @@ -1,59 +0,0 @@ -/* 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) { - var div, text, div_1, div_1_style_value; - - return { - c: function create() { - div = createElement("div"); - text = createText("\n"); - div_1 = createElement("div"); - this.h(); - }, - - h: function hydrate() { - div.style.cssText = state.style; - div_1.style.cssText = div_1_style_value = "" + state.key + ": " + state.value; - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - insertNode(text, target, anchor); - insertNode(div_1, target, anchor); - }, - - p: function update(changed, state) { - if (changed.style) { - div.style.cssText = state.style; - } - - if ((changed.key || changed.value) && div_1_style_value !== (div_1_style_value = "" + state.key + ": " + state.value)) { - div_1.style.cssText = div_1_style_value; - } - }, - - u: function unmount() { - detachNode(div); - detachNode(text); - detachNode(div_1); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); -export default SvelteComponent; \ No newline at end of file diff --git a/test/js/samples/inline-style-unoptimized/input-v2.html b/test/js/samples/inline-style-unoptimized/input-v2.html deleted file mode 100644 index eac76d5b6ede..000000000000 --- a/test/js/samples/inline-style-unoptimized/input-v2.html +++ /dev/null @@ -1,2 +0,0 @@ -
-
\ No newline at end of file diff --git a/test/js/samples/inline-style-unoptimized/input.html b/test/js/samples/inline-style-unoptimized/input.html index 87e4592bfd90..eac76d5b6ede 100644 --- a/test/js/samples/inline-style-unoptimized/input.html +++ b/test/js/samples/inline-style-unoptimized/input.html @@ -1,2 +1,2 @@ -
-
\ No newline at end of file +
+
\ No newline at end of file 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 4b8909150b99..e881aa6de460 100644 --- a/test/js/samples/input-without-blowback-guard/expected-bundle.js +++ b/test/js/samples/input-without-blowback-guard/expected-bundle.js @@ -63,8 +63,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -76,21 +76,7 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); @@ -146,18 +132,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/legacy-default/_config.js b/test/js/samples/legacy-default/_config.js deleted file mode 100644 index b5141be9ab42..000000000000 --- a/test/js/samples/legacy-default/_config.js +++ /dev/null @@ -1,5 +0,0 @@ -export default { - options: { - legacy: true - } -}; \ No newline at end of file diff --git a/test/js/samples/legacy-default/expected-bundle.js b/test/js/samples/legacy-default/expected-bundle.js deleted file mode 100644 index b400d303d7c7..000000000000 --- a/test/js/samples/legacy-default/expected-bundle.js +++ /dev/null @@ -1,257 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function appendNode(node, target) { - target.appendChild(node); -} - -function insertNode(node, target, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function reinsertBetween(before, after, target) { - while (before.nextSibling && before.nextSibling !== after) { - target.appendChild(before.parentNode.removeChild(before.nextSibling)); - } -} - -function createFragment() { - return document.createDocumentFragment(); -} - -function createElement(name) { - return document.createElement(name); -} - -function createText(data) { - return document.createTextNode(data); -} - -function createComment() { - return document.createComment(''); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get(key) { - return key ? this._state[key] : this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, - _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var text, p, text_1, text_2, text_3, slot_content_default = component._slotted["default"], slot_content_default_before, slot_content_default_after; - - var foo = new Foo({ - root: component.root, - slots: { "default": createFragment() } - }); - - return { - c: function create() { - text = createText("\n\t"); - p = createElement("p"); - text_1 = createText("some default slotted content"); - text_2 = createText("\n"); - foo._fragment.c(); - text_3 = createText("\n\n"); - }, - - m: function mount(target, anchor) { - appendNode(text, foo._slotted["default"]); - appendNode(p, foo._slotted["default"]); - appendNode(text_1, p); - appendNode(text_2, foo._slotted["default"]); - foo._mount(target, anchor); - insertNode(text_3, target, anchor); - - if (slot_content_default) { - insertNode(slot_content_default_before || (slot_content_default_before = createComment()), target, anchor); - insertNode(slot_content_default, target, anchor); - insertNode(slot_content_default_after || (slot_content_default_after = createComment()), target, anchor); - } - }, - - p: noop, - - u: function unmount() { - foo._unmount(); - detachNode(text_3); - - if (slot_content_default) { - reinsertBetween(slot_content_default_before, slot_content_default_after, slot_content_default); - detachNode(slot_content_default_before); - detachNode(slot_content_default_after); - } - }, - - d: function destroy$$1() { - foo.destroy(false); - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._slotted = options.slots || {}; - - if (!options.root) { - this._oncreate = []; - this._beforecreate = []; - this._aftercreate = []; - } - - this.slots = {}; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - - this._lock = true; - callAll(this._beforecreate); - callAll(this._oncreate); - callAll(this._aftercreate); - this._lock = false; - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/legacy-default/expected.js b/test/js/samples/legacy-default/expected.js deleted file mode 100644 index 64dc4121c042..000000000000 --- a/test/js/samples/legacy-default/expected.js +++ /dev/null @@ -1,85 +0,0 @@ -/* generated by Svelte vX.Y.Z */ -import { appendNode, assign, callAll, createComment, createElement, createFragment, createText, detachNode, init, insertNode, noop, proto, reinsertBetween } from "svelte/shared.js"; - -function create_main_fragment(component, state) { - var text, p, text_1, text_2, text_3, slot_content_default = component._slotted["default"], slot_content_default_before, slot_content_default_after; - - var foo = new Foo({ - root: component.root, - slots: { "default": createFragment() } - }); - - return { - c: function create() { - text = createText("\n\t"); - p = createElement("p"); - text_1 = createText("some default slotted content"); - text_2 = createText("\n"); - foo._fragment.c(); - text_3 = createText("\n\n"); - }, - - m: function mount(target, anchor) { - appendNode(text, foo._slotted["default"]); - appendNode(p, foo._slotted["default"]); - appendNode(text_1, p); - appendNode(text_2, foo._slotted["default"]); - foo._mount(target, anchor); - insertNode(text_3, target, anchor); - - if (slot_content_default) { - insertNode(slot_content_default_before || (slot_content_default_before = createComment()), target, anchor); - insertNode(slot_content_default, target, anchor); - insertNode(slot_content_default_after || (slot_content_default_after = createComment()), target, anchor); - } - }, - - p: noop, - - u: function unmount() { - foo._unmount(); - detachNode(text_3); - - if (slot_content_default) { - reinsertBetween(slot_content_default_before, slot_content_default_after, slot_content_default); - detachNode(slot_content_default_before); - detachNode(slot_content_default_after); - } - }, - - d: function destroy() { - foo.destroy(false); - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._slotted = options.slots || {}; - - if (!options.root) { - this._oncreate = []; - this._beforecreate = []; - this._aftercreate = []; - } - - this.slots = {}; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - - this._lock = true; - callAll(this._beforecreate); - callAll(this._oncreate); - callAll(this._aftercreate); - this._lock = false; - } -} - -assign(SvelteComponent.prototype, proto); -export default SvelteComponent; \ No newline at end of file diff --git a/test/js/samples/legacy-default/input.html b/test/js/samples/legacy-default/input.html deleted file mode 100644 index b0d6cbf18141..000000000000 --- a/test/js/samples/legacy-default/input.html +++ /dev/null @@ -1,11 +0,0 @@ - -

some default slotted content

-
- - - - \ No newline at end of file diff --git a/test/js/samples/legacy-input-type/expected-bundle.js b/test/js/samples/legacy-input-type/expected-bundle.js index ff4b0b5e2b23..1119454b3db6 100644 --- a/test/js/samples/legacy-input-type/expected-bundle.js +++ b/test/js/samples/legacy-input-type/expected-bundle.js @@ -57,8 +57,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -70,21 +70,7 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); @@ -140,18 +126,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/legacy-quote-class/_config.js b/test/js/samples/legacy-quote-class/_config.js deleted file mode 100644 index 838683ae37a2..000000000000 --- a/test/js/samples/legacy-quote-class/_config.js +++ /dev/null @@ -1,6 +0,0 @@ -export default { - options: { - hydratable: true, - legacy: true - } -}; \ No newline at end of file diff --git a/test/js/samples/legacy-quote-class/expected-bundle.js b/test/js/samples/legacy-quote-class/expected-bundle.js deleted file mode 100644 index fc088bf34a55..000000000000 --- a/test/js/samples/legacy-quote-class/expected-bundle.js +++ /dev/null @@ -1,227 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function insertNode(node, target, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function createSvgElement(name) { - return document.createElementNS('http://www.w3.org/2000/svg', name); -} - -function children (element) { - return Array.from(element.childNodes); -} - -function claimElement (nodes, name, attributes, svg) { - for (var i = 0; i < nodes.length; i += 1) { - var node = nodes[i]; - if (node.nodeName === name) { - for (var j = 0; j < node.attributes.length; j += 1) { - var attribute = node.attributes[j]; - if (!attributes[attribute.name]) node.removeAttribute(attribute.name); - } - return nodes.splice(i, 1)[0]; // TODO strip unwanted attributes - } - } - - return svg ? createSvgElement(name) : createElement(name); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get(key) { - return key ? this._state[key] : this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, - _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var div; - - return { - c: function create() { - div = createElement("div"); - this.h(); - }, - - l: function claim(nodes) { - div = claimElement(nodes, "DIV", { "class": true }, false); - var div_nodes = children(div); - - div_nodes.forEach(detachNode); - this.h(); - }, - - h: function hydrate() { - div.className = "foo"; - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - }, - - p: noop, - - u: function unmount() { - detachNode(div); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - var nodes = children(options.target); - options.hydrate ? this._fragment.l(nodes) : this._fragment.c(); - nodes.forEach(detachNode); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/legacy-quote-class/expected.js b/test/js/samples/legacy-quote-class/expected.js deleted file mode 100644 index de50dfa5e7b6..000000000000 --- a/test/js/samples/legacy-quote-class/expected.js +++ /dev/null @@ -1,54 +0,0 @@ -/* generated by Svelte vX.Y.Z */ -import { assign, children, claimElement, createElement, detachNode, init, insertNode, noop, proto } from "svelte/shared.js"; - -function create_main_fragment(component, state) { - var div; - - return { - c: function create() { - div = createElement("div"); - this.h(); - }, - - l: function claim(nodes) { - div = claimElement(nodes, "DIV", { "class": true }, false); - var div_nodes = children(div); - - div_nodes.forEach(detachNode); - this.h(); - }, - - h: function hydrate() { - div.className = "foo"; - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - }, - - p: noop, - - u: function unmount() { - detachNode(div); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - var nodes = children(options.target); - options.hydrate ? this._fragment.l(nodes) : this._fragment.c(); - nodes.forEach(detachNode); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); -export default SvelteComponent; \ No newline at end of file diff --git a/test/js/samples/legacy-quote-class/input.html b/test/js/samples/legacy-quote-class/input.html deleted file mode 100644 index c6a8a8c95d59..000000000000 --- a/test/js/samples/legacy-quote-class/input.html +++ /dev/null @@ -1 +0,0 @@ -
\ No newline at end of file diff --git a/test/js/samples/media-bindings/expected-bundle.js b/test/js/samples/media-bindings/expected-bundle.js index 7d8c7624eab7..abcdd409862d 100644 --- a/test/js/samples/media-bindings/expected-bundle.js +++ b/test/js/samples/media-bindings/expected-bundle.js @@ -67,8 +67,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -80,21 +80,7 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); @@ -150,18 +136,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/non-imported-component/expected-bundle.js b/test/js/samples/non-imported-component/expected-bundle.js index 06d1b0d4ea60..b4adec303a0a 100644 --- a/test/js/samples/non-imported-component/expected-bundle.js +++ b/test/js/samples/non-imported-component/expected-bundle.js @@ -53,8 +53,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -66,21 +66,7 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); @@ -136,18 +122,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js b/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js deleted file mode 100644 index 4b1a9fc4812e..000000000000 --- a/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js +++ /dev/null @@ -1,189 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get(key) { - return key ? this._state[key] : this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, - _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function oncreate() {} -function ondestroy() {} -function create_main_fragment(component, state) { - - return { - c: noop, - - m: noop, - - p: noop, - - u: noop, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._handlers.destroy = [ondestroy]; - - var self = this; - var _oncreate = function() { - var changed = { }; - oncreate.call(self); - self.fire("update", { changed: changed, current: self._state }); - }; - - if (!options.root) { - this._oncreate = []; - } - - this._fragment = create_main_fragment(this, this._state); - - this.root._oncreate.push(_oncreate); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - - callAll(this._oncreate); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/onrender-onteardown-rewritten/expected.js b/test/js/samples/onrender-onteardown-rewritten/expected.js deleted file mode 100644 index fed341a7f96e..000000000000 --- a/test/js/samples/onrender-onteardown-rewritten/expected.js +++ /dev/null @@ -1,53 +0,0 @@ -/* generated by Svelte vX.Y.Z */ -import { assign, callAll, init, noop, proto } from "svelte/shared.js"; - -function oncreate() {}; - -function ondestroy() {}; - -function create_main_fragment(component, state) { - - return { - c: noop, - - m: noop, - - p: noop, - - u: noop, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._handlers.destroy = [ondestroy]; - - var self = this; - var _oncreate = function() { - var changed = { }; - oncreate.call(self); - self.fire("update", { changed: changed, current: self._state }); - }; - - if (!options.root) { - this._oncreate = []; - } - - this._fragment = create_main_fragment(this, this._state); - - this.root._oncreate.push(_oncreate); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - - callAll(this._oncreate); - } -} - -assign(SvelteComponent.prototype, proto); -export default SvelteComponent; \ No newline at end of file diff --git a/test/js/samples/onrender-onteardown-rewritten/input.html b/test/js/samples/onrender-onteardown-rewritten/input.html deleted file mode 100644 index 1d3b9e3f7bb3..000000000000 --- a/test/js/samples/onrender-onteardown-rewritten/input.html +++ /dev/null @@ -1,7 +0,0 @@ - \ No newline at end of file diff --git a/test/js/samples/setup-method/expected-bundle.js b/test/js/samples/setup-method/expected-bundle.js index 39f5d28c8055..e1aaa9ae759a 100644 --- a/test/js/samples/setup-method/expected-bundle.js +++ b/test/js/samples/setup-method/expected-bundle.js @@ -39,8 +39,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -52,21 +52,7 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); @@ -122,18 +108,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ 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 13c64c9d6cb6..b1d2e97e041c 100644 --- a/test/js/samples/ssr-no-oncreate-etc/expected-bundle.js +++ b/test/js/samples/ssr-no-oncreate-etc/expected-bundle.js @@ -41,22 +41,6 @@ SvelteComponent.css = { map: null }; -var warned = false; -SvelteComponent.renderCss = function() { - if (!warned) { - console.error('Component.renderCss(...) is deprecated and will be removed in v2 — use Component.render(...).css instead'); - warned = true; - } - - var components = []; - - return { - css: components.map(x => x.css).join('\n'), - map: null, - components - }; -}; - SvelteComponent.preload = preload; module.exports = SvelteComponent; diff --git a/test/js/samples/ssr-no-oncreate-etc/expected.js b/test/js/samples/ssr-no-oncreate-etc/expected.js index d9b616e76303..0aec3a587496 100644 --- a/test/js/samples/ssr-no-oncreate-etc/expected.js +++ b/test/js/samples/ssr-no-oncreate-etc/expected.js @@ -46,20 +46,6 @@ SvelteComponent.css = { }; var warned = false; -SvelteComponent.renderCss = function() { - if (!warned) { - console.error('Component.renderCss(...) is deprecated and will be removed in v2 — use Component.render(...).css instead'); - warned = true; - } - - var components = []; - - return { - css: components.map(x => x.css).join('\n'), - map: null, - components - }; -}; SvelteComponent.preload = preload; diff --git a/test/js/samples/ssr-preserve-comments/expected-bundle.js b/test/js/samples/ssr-preserve-comments/expected-bundle.js index 19461df02059..7ccd01cbefe5 100644 --- a/test/js/samples/ssr-preserve-comments/expected-bundle.js +++ b/test/js/samples/ssr-preserve-comments/expected-bundle.js @@ -40,20 +40,4 @@ SvelteComponent.css = { map: null }; -var warned = false; -SvelteComponent.renderCss = function() { - if (!warned) { - console.error('Component.renderCss(...) is deprecated and will be removed in v2 — use Component.render(...).css instead'); - warned = true; - } - - var components = []; - - return { - css: components.map(x => x.css).join('\n'), - map: null, - components - }; -}; - module.exports = SvelteComponent; diff --git a/test/js/samples/ssr-preserve-comments/expected.js b/test/js/samples/ssr-preserve-comments/expected.js index 3497a7283298..a67287968554 100644 --- a/test/js/samples/ssr-preserve-comments/expected.js +++ b/test/js/samples/ssr-preserve-comments/expected.js @@ -44,19 +44,5 @@ SvelteComponent.css = { }; var warned = false; -SvelteComponent.renderCss = function() { - if (!warned) { - console.error('Component.renderCss(...) is deprecated and will be removed in v2 — use Component.render(...).css instead'); - warned = true; - } - - var components = []; - - return { - css: components.map(x => x.css).join('\n'), - map: null, - components - }; -}; module.exports = SvelteComponent; \ No newline at end of file diff --git a/test/js/samples/svg-title/expected-bundle.js b/test/js/samples/svg-title/expected-bundle.js index 804ce01d7c45..477d97c83947 100644 --- a/test/js/samples/svg-title/expected-bundle.js +++ b/test/js/samples/svg-title/expected-bundle.js @@ -59,8 +59,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -72,21 +72,7 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); @@ -142,18 +128,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/title/_actual-bundle-v2.js b/test/js/samples/title/_actual-bundle-v2.js deleted file mode 100644 index df4a5e21253d..000000000000 --- a/test/js/samples/title/_actual-bundle-v2.js +++ /dev/null @@ -1,177 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get(key) { - return key ? this._state[key] : this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, - _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var title_value; - - document.title = title_value = "a " + state.custom + " title"; - - return { - c: noop, - - m: noop, - - p: function update(changed, state) { - if ((changed.custom) && title_value !== (title_value = "a " + state.custom + " title")) { - document.title = title_value; - } - }, - - u: noop, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/title/expected-bundle-v2.js b/test/js/samples/title/expected-bundle-v2.js deleted file mode 100644 index df4a5e21253d..000000000000 --- a/test/js/samples/title/expected-bundle-v2.js +++ /dev/null @@ -1,177 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get(key) { - return key ? this._state[key] : this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, - _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var title_value; - - document.title = title_value = "a " + state.custom + " title"; - - return { - c: noop, - - m: noop, - - p: function update(changed, state) { - if ((changed.custom) && title_value !== (title_value = "a " + state.custom + " title")) { - document.title = title_value; - } - }, - - u: noop, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/title/expected-bundle.js b/test/js/samples/title/expected-bundle.js index df4a5e21253d..27cae18b3d14 100644 --- a/test/js/samples/title/expected-bundle.js +++ b/test/js/samples/title/expected-bundle.js @@ -39,8 +39,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -52,21 +52,7 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); @@ -122,18 +108,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ diff --git a/test/js/samples/title/expected-v2.js b/test/js/samples/title/expected-v2.js deleted file mode 100644 index 0e059bbb4c67..000000000000 --- a/test/js/samples/title/expected-v2.js +++ /dev/null @@ -1,39 +0,0 @@ -/* generated by Svelte vX.Y.Z */ -import { assign, init, noop, proto } from "svelte/shared.js"; - -function create_main_fragment(component, state) { - var title_value; - - document.title = title_value = "a " + state.custom + " title"; - - return { - c: noop, - - m: noop, - - p: function update(changed, state) { - if ((changed.custom) && title_value !== (title_value = "a " + state.custom + " title")) { - document.title = title_value; - } - }, - - u: noop, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); -export default SvelteComponent; \ No newline at end of file diff --git a/test/js/samples/title/input-v2.html b/test/js/samples/title/input-v2.html deleted file mode 100644 index 0eb2a9519de6..000000000000 --- a/test/js/samples/title/input-v2.html +++ /dev/null @@ -1,3 +0,0 @@ - - a {custom} title - \ No newline at end of file diff --git a/test/js/samples/title/input.html b/test/js/samples/title/input.html index b006a8f50f65..0eb2a9519de6 100644 --- a/test/js/samples/title/input.html +++ b/test/js/samples/title/input.html @@ -1,3 +1,3 @@ -<:Head> - a {{custom}} title - \ No newline at end of file + + a {custom} title + \ No newline at end of file diff --git a/test/js/samples/use-elements-as-anchors/_actual-bundle-v2.js b/test/js/samples/use-elements-as-anchors/_actual-bundle-v2.js deleted file mode 100644 index 5fe8f188a29a..000000000000 --- a/test/js/samples/use-elements-as-anchors/_actual-bundle-v2.js +++ /dev/null @@ -1,424 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function appendNode(node, target) { - target.appendChild(node); -} - -function insertNode(node, target, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function createText(data) { - return document.createTextNode(data); -} - -function createComment() { - return document.createComment(''); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get(key) { - return key ? this._state[key] : this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, - _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - 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_1 = (state.b) && create_if_block_1(component, state); - - var if_block_2 = (state.c) && create_if_block_2(component, state); - - var if_block_3 = (state.d) && create_if_block_3(component, state); - - var if_block_4 = (state.e) && create_if_block_4(component, state); - - return { - c: function create() { - div = createElement("div"); - if (if_block) if_block.c(); - text = createText("\n\n\t"); - p = createElement("p"); - p.textContent = "this can be used as an anchor"; - text_2 = createText("\n\n\t"); - if (if_block_1) if_block_1.c(); - text_3 = createText("\n\n\t"); - if (if_block_2) if_block_2.c(); - text_4 = createText("\n\n\t"); - p_1 = createElement("p"); - p_1.textContent = "so can this"; - text_6 = createText("\n\n\t"); - if (if_block_3) if_block_3.c(); - text_8 = createText("\n\n"); - if (if_block_4) if_block_4.c(); - if_block_4_anchor = createComment(); - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - if (if_block) if_block.m(div, null); - appendNode(text, div); - appendNode(p, div); - appendNode(text_2, div); - if (if_block_1) if_block_1.m(div, null); - appendNode(text_3, div); - if (if_block_2) if_block_2.m(div, null); - appendNode(text_4, div); - appendNode(p_1, div); - appendNode(text_6, div); - if (if_block_3) if_block_3.m(div, null); - insertNode(text_8, target, anchor); - if (if_block_4) if_block_4.m(target, anchor); - insertNode(if_block_4_anchor, target, anchor); - }, - - p: function update(changed, state) { - if (state.a) { - if (!if_block) { - if_block = create_if_block(component, state); - if_block.c(); - if_block.m(div, text); - } - } else if (if_block) { - if_block.u(); - if_block.d(); - if_block = null; - } - - if (state.b) { - if (!if_block_1) { - if_block_1 = create_if_block_1(component, state); - if_block_1.c(); - if_block_1.m(div, text_3); - } - } else if (if_block_1) { - if_block_1.u(); - if_block_1.d(); - if_block_1 = null; - } - - if (state.c) { - if (!if_block_2) { - if_block_2 = create_if_block_2(component, state); - if_block_2.c(); - if_block_2.m(div, text_4); - } - } else if (if_block_2) { - if_block_2.u(); - if_block_2.d(); - if_block_2 = null; - } - - if (state.d) { - if (!if_block_3) { - if_block_3 = create_if_block_3(component, state); - if_block_3.c(); - if_block_3.m(div, null); - } - } else if (if_block_3) { - if_block_3.u(); - if_block_3.d(); - if_block_3 = null; - } - - if (state.e) { - if (!if_block_4) { - if_block_4 = create_if_block_4(component, state); - if_block_4.c(); - if_block_4.m(if_block_4_anchor.parentNode, if_block_4_anchor); - } - } else if (if_block_4) { - if_block_4.u(); - if_block_4.d(); - if_block_4 = null; - } - }, - - u: function unmount() { - detachNode(div); - if (if_block) if_block.u(); - if (if_block_1) if_block_1.u(); - if (if_block_2) if_block_2.u(); - if (if_block_3) if_block_3.u(); - detachNode(text_8); - if (if_block_4) if_block_4.u(); - detachNode(if_block_4_anchor); - }, - - d: function destroy$$1() { - if (if_block) if_block.d(); - if (if_block_1) if_block_1.d(); - if (if_block_2) if_block_2.d(); - if (if_block_3) if_block_3.d(); - if (if_block_4) if_block_4.d(); - } - }; -} - -// (2:1) {#if a} -function create_if_block(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "a"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -// (8:1) {#if b} -function create_if_block_1(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "b"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -// (12:1) {#if c} -function create_if_block_2(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "c"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -// (18:1) {#if d} -function create_if_block_3(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "d"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -// (25:0) {#if e} -function create_if_block_4(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "e"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/use-elements-as-anchors/expected-bundle-v2.js b/test/js/samples/use-elements-as-anchors/expected-bundle-v2.js deleted file mode 100644 index 5fe8f188a29a..000000000000 --- a/test/js/samples/use-elements-as-anchors/expected-bundle-v2.js +++ /dev/null @@ -1,424 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function appendNode(node, target) { - target.appendChild(node); -} - -function insertNode(node, target, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function createText(data) { - return document.createTextNode(data); -} - -function createComment() { - return document.createComment(''); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get(key) { - return key ? this._state[key] : this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, - _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - 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_1 = (state.b) && create_if_block_1(component, state); - - var if_block_2 = (state.c) && create_if_block_2(component, state); - - var if_block_3 = (state.d) && create_if_block_3(component, state); - - var if_block_4 = (state.e) && create_if_block_4(component, state); - - return { - c: function create() { - div = createElement("div"); - if (if_block) if_block.c(); - text = createText("\n\n\t"); - p = createElement("p"); - p.textContent = "this can be used as an anchor"; - text_2 = createText("\n\n\t"); - if (if_block_1) if_block_1.c(); - text_3 = createText("\n\n\t"); - if (if_block_2) if_block_2.c(); - text_4 = createText("\n\n\t"); - p_1 = createElement("p"); - p_1.textContent = "so can this"; - text_6 = createText("\n\n\t"); - if (if_block_3) if_block_3.c(); - text_8 = createText("\n\n"); - if (if_block_4) if_block_4.c(); - if_block_4_anchor = createComment(); - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - if (if_block) if_block.m(div, null); - appendNode(text, div); - appendNode(p, div); - appendNode(text_2, div); - if (if_block_1) if_block_1.m(div, null); - appendNode(text_3, div); - if (if_block_2) if_block_2.m(div, null); - appendNode(text_4, div); - appendNode(p_1, div); - appendNode(text_6, div); - if (if_block_3) if_block_3.m(div, null); - insertNode(text_8, target, anchor); - if (if_block_4) if_block_4.m(target, anchor); - insertNode(if_block_4_anchor, target, anchor); - }, - - p: function update(changed, state) { - if (state.a) { - if (!if_block) { - if_block = create_if_block(component, state); - if_block.c(); - if_block.m(div, text); - } - } else if (if_block) { - if_block.u(); - if_block.d(); - if_block = null; - } - - if (state.b) { - if (!if_block_1) { - if_block_1 = create_if_block_1(component, state); - if_block_1.c(); - if_block_1.m(div, text_3); - } - } else if (if_block_1) { - if_block_1.u(); - if_block_1.d(); - if_block_1 = null; - } - - if (state.c) { - if (!if_block_2) { - if_block_2 = create_if_block_2(component, state); - if_block_2.c(); - if_block_2.m(div, text_4); - } - } else if (if_block_2) { - if_block_2.u(); - if_block_2.d(); - if_block_2 = null; - } - - if (state.d) { - if (!if_block_3) { - if_block_3 = create_if_block_3(component, state); - if_block_3.c(); - if_block_3.m(div, null); - } - } else if (if_block_3) { - if_block_3.u(); - if_block_3.d(); - if_block_3 = null; - } - - if (state.e) { - if (!if_block_4) { - if_block_4 = create_if_block_4(component, state); - if_block_4.c(); - if_block_4.m(if_block_4_anchor.parentNode, if_block_4_anchor); - } - } else if (if_block_4) { - if_block_4.u(); - if_block_4.d(); - if_block_4 = null; - } - }, - - u: function unmount() { - detachNode(div); - if (if_block) if_block.u(); - if (if_block_1) if_block_1.u(); - if (if_block_2) if_block_2.u(); - if (if_block_3) if_block_3.u(); - detachNode(text_8); - if (if_block_4) if_block_4.u(); - detachNode(if_block_4_anchor); - }, - - d: function destroy$$1() { - if (if_block) if_block.d(); - if (if_block_1) if_block_1.d(); - if (if_block_2) if_block_2.d(); - if (if_block_3) if_block_3.d(); - if (if_block_4) if_block_4.d(); - } - }; -} - -// (2:1) {#if a} -function create_if_block(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "a"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -// (8:1) {#if b} -function create_if_block_1(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "b"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -// (12:1) {#if c} -function create_if_block_2(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "c"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -// (18:1) {#if d} -function create_if_block_3(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "d"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -// (25:0) {#if e} -function create_if_block_4(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "e"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; 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 9ac8ca4ebeec..1fda063de122 100644 --- a/test/js/samples/use-elements-as-anchors/expected-bundle.js +++ b/test/js/samples/use-elements-as-anchors/expected-bundle.js @@ -63,8 +63,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -76,21 +76,7 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); @@ -146,18 +132,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ @@ -297,7 +281,7 @@ function create_main_fragment(component, state) { }; } -// (2:1) {{#if a}} +// (2:1) {#if a} function create_if_block(component, state) { var p; @@ -319,7 +303,7 @@ function create_if_block(component, state) { }; } -// (8:1) {{#if b}} +// (8:1) {#if b} function create_if_block_1(component, state) { var p; @@ -341,7 +325,7 @@ function create_if_block_1(component, state) { }; } -// (12:1) {{#if c}} +// (12:1) {#if c} function create_if_block_2(component, state) { var p; @@ -363,7 +347,7 @@ function create_if_block_2(component, state) { }; } -// (18:1) {{#if d}} +// (18:1) {#if d} function create_if_block_3(component, state) { var p; @@ -385,7 +369,7 @@ function create_if_block_3(component, state) { }; } -// (25:0) {{#if e}} +// (25:0) {#if e} function create_if_block_4(component, state) { var p; diff --git a/test/js/samples/use-elements-as-anchors/expected-v2.js b/test/js/samples/use-elements-as-anchors/expected-v2.js deleted file mode 100644 index d9cff08d3f98..000000000000 --- a/test/js/samples/use-elements-as-anchors/expected-v2.js +++ /dev/null @@ -1,262 +0,0 @@ -/* 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) { - 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_1 = (state.b) && create_if_block_1(component, state); - - var if_block_2 = (state.c) && create_if_block_2(component, state); - - var if_block_3 = (state.d) && create_if_block_3(component, state); - - var if_block_4 = (state.e) && create_if_block_4(component, state); - - return { - c: function create() { - div = createElement("div"); - if (if_block) if_block.c(); - text = createText("\n\n\t"); - p = createElement("p"); - p.textContent = "this can be used as an anchor"; - text_2 = createText("\n\n\t"); - if (if_block_1) if_block_1.c(); - text_3 = createText("\n\n\t"); - if (if_block_2) if_block_2.c(); - text_4 = createText("\n\n\t"); - p_1 = createElement("p"); - p_1.textContent = "so can this"; - text_6 = createText("\n\n\t"); - if (if_block_3) if_block_3.c(); - text_8 = createText("\n\n"); - if (if_block_4) if_block_4.c(); - if_block_4_anchor = createComment(); - }, - - m: function mount(target, anchor) { - insertNode(div, target, anchor); - if (if_block) if_block.m(div, null); - appendNode(text, div); - appendNode(p, div); - appendNode(text_2, div); - if (if_block_1) if_block_1.m(div, null); - appendNode(text_3, div); - if (if_block_2) if_block_2.m(div, null); - appendNode(text_4, div); - appendNode(p_1, div); - appendNode(text_6, div); - if (if_block_3) if_block_3.m(div, null); - insertNode(text_8, target, anchor); - if (if_block_4) if_block_4.m(target, anchor); - insertNode(if_block_4_anchor, target, anchor); - }, - - p: function update(changed, state) { - if (state.a) { - if (!if_block) { - if_block = create_if_block(component, state); - if_block.c(); - if_block.m(div, text); - } - } else if (if_block) { - if_block.u(); - if_block.d(); - if_block = null; - } - - if (state.b) { - if (!if_block_1) { - if_block_1 = create_if_block_1(component, state); - if_block_1.c(); - if_block_1.m(div, text_3); - } - } else if (if_block_1) { - if_block_1.u(); - if_block_1.d(); - if_block_1 = null; - } - - if (state.c) { - if (!if_block_2) { - if_block_2 = create_if_block_2(component, state); - if_block_2.c(); - if_block_2.m(div, text_4); - } - } else if (if_block_2) { - if_block_2.u(); - if_block_2.d(); - if_block_2 = null; - } - - if (state.d) { - if (!if_block_3) { - if_block_3 = create_if_block_3(component, state); - if_block_3.c(); - if_block_3.m(div, null); - } - } else if (if_block_3) { - if_block_3.u(); - if_block_3.d(); - if_block_3 = null; - } - - if (state.e) { - if (!if_block_4) { - if_block_4 = create_if_block_4(component, state); - if_block_4.c(); - if_block_4.m(if_block_4_anchor.parentNode, if_block_4_anchor); - } - } else if (if_block_4) { - if_block_4.u(); - if_block_4.d(); - if_block_4 = null; - } - }, - - u: function unmount() { - detachNode(div); - if (if_block) if_block.u(); - if (if_block_1) if_block_1.u(); - if (if_block_2) if_block_2.u(); - if (if_block_3) if_block_3.u(); - detachNode(text_8); - if (if_block_4) if_block_4.u(); - detachNode(if_block_4_anchor); - }, - - d: function destroy() { - if (if_block) if_block.d(); - if (if_block_1) if_block_1.d(); - if (if_block_2) if_block_2.d(); - if (if_block_3) if_block_3.d(); - if (if_block_4) if_block_4.d(); - } - }; -} - -// (2:1) {#if a} -function create_if_block(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "a"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -// (8:1) {#if b} -function create_if_block_1(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "b"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -// (12:1) {#if c} -function create_if_block_2(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "c"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -// (18:1) {#if d} -function create_if_block_3(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "d"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -// (25:0) {#if e} -function create_if_block_4(component, state) { - var p; - - return { - c: function create() { - p = createElement("p"); - p.textContent = "e"; - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - }, - - u: function unmount() { - detachNode(p); - }, - - d: noop - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); -export default SvelteComponent; \ No newline at end of file diff --git a/test/js/samples/use-elements-as-anchors/expected.js b/test/js/samples/use-elements-as-anchors/expected.js index 5f6f27c742b6..d9cff08d3f98 100644 --- a/test/js/samples/use-elements-as-anchors/expected.js +++ b/test/js/samples/use-elements-as-anchors/expected.js @@ -136,7 +136,7 @@ function create_main_fragment(component, state) { }; } -// (2:1) {{#if a}} +// (2:1) {#if a} function create_if_block(component, state) { var p; @@ -158,7 +158,7 @@ function create_if_block(component, state) { }; } -// (8:1) {{#if b}} +// (8:1) {#if b} function create_if_block_1(component, state) { var p; @@ -180,7 +180,7 @@ function create_if_block_1(component, state) { }; } -// (12:1) {{#if c}} +// (12:1) {#if c} function create_if_block_2(component, state) { var p; @@ -202,7 +202,7 @@ function create_if_block_2(component, state) { }; } -// (18:1) {{#if d}} +// (18:1) {#if d} function create_if_block_3(component, state) { var p; @@ -224,7 +224,7 @@ function create_if_block_3(component, state) { }; } -// (25:0) {{#if e}} +// (25:0) {#if e} function create_if_block_4(component, state) { var p; diff --git a/test/js/samples/use-elements-as-anchors/input-v2.html b/test/js/samples/use-elements-as-anchors/input-v2.html deleted file mode 100644 index 9c18d40f582b..000000000000 --- a/test/js/samples/use-elements-as-anchors/input-v2.html +++ /dev/null @@ -1,27 +0,0 @@ -
- {#if a} -

a

- {/if} - -

this can be used as an anchor

- - {#if b} -

b

- {/if} - - {#if c} -

c

- {/if} - -

so can this

- - {#if d} -

d

- {/if} - - -
- -{#if e} -

e

-{/if} \ No newline at end of file diff --git a/test/js/samples/use-elements-as-anchors/input.html b/test/js/samples/use-elements-as-anchors/input.html index c55e7bd4de7b..9c18d40f582b 100644 --- a/test/js/samples/use-elements-as-anchors/input.html +++ b/test/js/samples/use-elements-as-anchors/input.html @@ -1,27 +1,27 @@
- {{#if a}} + {#if a}

a

- {{/if}} + {/if}

this can be used as an anchor

- {{#if b}} + {#if b}

b

- {{/if}} + {/if} - {{#if c}} + {#if c}

c

- {{/if}} + {/if}

so can this

- {{#if d}} + {#if d}

d

- {{/if}} + {/if}
-{{#if e}} +{#if e}

e

-{{/if}} \ No newline at end of file +{/if} \ No newline at end of file diff --git a/test/js/samples/window-binding-scroll/_actual-bundle-v2.js b/test/js/samples/window-binding-scroll/_actual-bundle-v2.js deleted file mode 100644 index a6afbf9b14aa..000000000000 --- a/test/js/samples/window-binding-scroll/_actual-bundle-v2.js +++ /dev/null @@ -1,226 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function appendNode(node, target) { - target.appendChild(node); -} - -function insertNode(node, target, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function createText(data) { - return document.createTextNode(data); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get(key) { - return key ? this._state[key] : this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, - _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var window_updating = false, clear_window_updating = function() { window_updating = false; }, window_updating_timeout, p, text, text_1; - - function onwindowscroll(event) { - if (window_updating) return; - window_updating = true; - - component.set({ - y: this.pageYOffset - }); - window_updating = false; - } - window.addEventListener("scroll", onwindowscroll); - - component.observe("y", function(y) { - window_updating = true; - clearTimeout(window_updating_timeout); - window.scrollTo(window.pageXOffset, y); - window_updating_timeout = setTimeout(clear_window_updating, 100); - }); - - return { - c: function create() { - p = createElement("p"); - text = createText("scrolled to "); - text_1 = createText(state.y); - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - appendNode(text, p); - appendNode(text_1, p); - }, - - p: function update(changed, state) { - if (changed.y) { - text_1.data = state.y; - } - }, - - u: function unmount() { - detachNode(p); - }, - - d: function destroy$$1() { - window.removeEventListener("scroll", onwindowscroll); - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._state.y = window.pageYOffset; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/window-binding-scroll/expected-bundle-v2.js b/test/js/samples/window-binding-scroll/expected-bundle-v2.js deleted file mode 100644 index a6afbf9b14aa..000000000000 --- a/test/js/samples/window-binding-scroll/expected-bundle-v2.js +++ /dev/null @@ -1,226 +0,0 @@ -function noop() {} - -function assign(tar, src) { - for (var k in src) tar[k] = src[k]; - return tar; -} - -function appendNode(node, target) { - target.appendChild(node); -} - -function insertNode(node, target, anchor) { - target.insertBefore(node, anchor); -} - -function detachNode(node) { - node.parentNode.removeChild(node); -} - -function createElement(name) { - return document.createElement(name); -} - -function createText(data) { - return document.createTextNode(data); -} - -function blankObject() { - return Object.create(null); -} - -function destroy(detach) { - this.destroy = noop; - this.fire('destroy'); - this.set = this.get = noop; - - if (detach !== false) this._fragment.u(); - this._fragment.d(); - this._fragment = this._state = null; -} - -function _differs(a, b) { - return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); -} - -function fire(eventName, data) { - var handlers = - eventName in this._handlers && this._handlers[eventName].slice(); - if (!handlers) return; - - for (var i = 0; i < handlers.length; i += 1) { - var handler = handlers[i]; - - if (!handler.__calling) { - handler.__calling = true; - handler.call(this, data); - handler.__calling = false; - } - } -} - -function get(key) { - return key ? this._state[key] : this._state; -} - -function init(component, options) { - component._handlers = blankObject(); - component._bind = options._bind; - - component.options = options; - component.root = options.root || component; - component.store = component.root.store || options.store; -} - -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - -function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); - handlers.push(handler); - - return { - cancel: function() { - var index = handlers.indexOf(handler); - if (~index) handlers.splice(index, 1); - } - }; -} - -function set(newState) { - this._set(assign({}, newState)); - if (this.root._lock) return; - this.root._lock = true; - callAll(this.root._beforecreate); - callAll(this.root._oncreate); - callAll(this.root._aftercreate); - this.root._lock = false; -} - -function _set(newState) { - var oldState = this._state, - changed = {}, - dirty = false; - - for (var key in newState) { - if (this._differs(newState[key], oldState[key])) changed[key] = dirty = true; - } - if (!dirty) return; - - this._state = assign(assign({}, oldState), newState); - this._recompute(changed, this._state); - if (this._bind) this._bind(changed, this._state); - - if (this._fragment) { - this.fire("state", { changed: changed, current: this._state, previous: oldState }); - this._fragment.p(changed, this._state); - this.fire("update", { changed: changed, current: this._state, previous: oldState }); - } -} - -function callAll(fns) { - while (fns && fns.length) fns.shift()(); -} - -function _mount(target, anchor) { - this._fragment[this._fragment.i ? 'i' : 'm'](target, anchor || null); -} - -function _unmount() { - if (this._fragment) this._fragment.u(); -} - -var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, - _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs -}; - -/* generated by Svelte vX.Y.Z */ - -function create_main_fragment(component, state) { - var window_updating = false, clear_window_updating = function() { window_updating = false; }, window_updating_timeout, p, text, text_1; - - function onwindowscroll(event) { - if (window_updating) return; - window_updating = true; - - component.set({ - y: this.pageYOffset - }); - window_updating = false; - } - window.addEventListener("scroll", onwindowscroll); - - component.observe("y", function(y) { - window_updating = true; - clearTimeout(window_updating_timeout); - window.scrollTo(window.pageXOffset, y); - window_updating_timeout = setTimeout(clear_window_updating, 100); - }); - - return { - c: function create() { - p = createElement("p"); - text = createText("scrolled to "); - text_1 = createText(state.y); - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - appendNode(text, p); - appendNode(text_1, p); - }, - - p: function update(changed, state) { - if (changed.y) { - text_1.data = state.y; - } - }, - - u: function unmount() { - detachNode(p); - }, - - d: function destroy$$1() { - window.removeEventListener("scroll", onwindowscroll); - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._state.y = window.pageYOffset; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); - -export default SvelteComponent; diff --git a/test/js/samples/window-binding-scroll/expected-bundle.js b/test/js/samples/window-binding-scroll/expected-bundle.js index a6afbf9b14aa..df4fc6b2c981 100644 --- a/test/js/samples/window-binding-scroll/expected-bundle.js +++ b/test/js/samples/window-binding-scroll/expected-bundle.js @@ -59,8 +59,8 @@ function fire(eventName, data) { } } -function get(key) { - return key ? this._state[key] : this._state; +function get() { + return this._state; } function init(component, options) { @@ -72,21 +72,7 @@ function init(component, options) { component.store = component.root.store || options.store; } -function observe(key, callback, options) { - var fn = callback.bind(this); - - if (!options || options.init !== false) { - fn(this.get()[key], undefined); - } - - return this.on(options && options.defer ? 'update' : 'state', function(event) { - if (event.changed[key]) fn(event.current[key], event.previous && event.previous[key]); - }); -} - function on(eventName, handler) { - if (eventName === 'teardown') return this.on('destroy', handler); - var handlers = this._handlers[eventName] || (this._handlers[eventName] = []); handlers.push(handler); @@ -142,18 +128,16 @@ function _unmount() { } var proto = { - destroy: destroy, - get: get, - fire: fire, - observe: observe, - on: on, - set: set, - teardown: destroy, + destroy, + get, + fire, + on, + set, _recompute: noop, - _set: _set, - _mount: _mount, - _unmount: _unmount, - _differs: _differs + _set, + _mount, + _unmount, + _differs }; /* generated by Svelte vX.Y.Z */ @@ -172,11 +156,13 @@ function create_main_fragment(component, state) { } window.addEventListener("scroll", onwindowscroll); - component.observe("y", function(y) { - window_updating = true; - clearTimeout(window_updating_timeout); - window.scrollTo(window.pageXOffset, y); - window_updating_timeout = setTimeout(clear_window_updating, 100); + component.on("state", ({ changed, current }) => { + if (changed["y"]) { + window_updating = true; + clearTimeout(window_updating_timeout); + window.scrollTo(window.pageXOffset, current["y"]); + window_updating_timeout = setTimeout(clear_window_updating, 100); + } }); return { diff --git a/test/js/samples/window-binding-scroll/expected-v2.js b/test/js/samples/window-binding-scroll/expected-v2.js deleted file mode 100644 index 59009aeb9b99..000000000000 --- a/test/js/samples/window-binding-scroll/expected-v2.js +++ /dev/null @@ -1,68 +0,0 @@ -/* 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) { - var window_updating = false, clear_window_updating = function() { window_updating = false; }, window_updating_timeout, p, text, text_1; - - function onwindowscroll(event) { - if (window_updating) return; - window_updating = true; - - component.set({ - y: this.pageYOffset - }); - window_updating = false; - } - window.addEventListener("scroll", onwindowscroll); - - component.observe("y", function(y) { - window_updating = true; - clearTimeout(window_updating_timeout); - window.scrollTo(window.pageXOffset, y); - window_updating_timeout = setTimeout(clear_window_updating, 100); - }); - - return { - c: function create() { - p = createElement("p"); - text = createText("scrolled to "); - text_1 = createText(state.y); - }, - - m: function mount(target, anchor) { - insertNode(p, target, anchor); - appendNode(text, p); - appendNode(text_1, p); - }, - - p: function update(changed, state) { - if (changed.y) { - text_1.data = state.y; - } - }, - - u: function unmount() { - detachNode(p); - }, - - d: function destroy() { - window.removeEventListener("scroll", onwindowscroll); - } - }; -} - -function SvelteComponent(options) { - init(this, options); - this._state = assign({}, options.data); - this._state.y = window.pageYOffset; - - this._fragment = create_main_fragment(this, this._state); - - if (options.target) { - this._fragment.c(); - this._mount(options.target, options.anchor); - } -} - -assign(SvelteComponent.prototype, proto); -export default SvelteComponent; \ No newline at end of file diff --git a/test/js/samples/window-binding-scroll/expected.js b/test/js/samples/window-binding-scroll/expected.js index 59009aeb9b99..d18b35687ed9 100644 --- a/test/js/samples/window-binding-scroll/expected.js +++ b/test/js/samples/window-binding-scroll/expected.js @@ -15,11 +15,13 @@ function create_main_fragment(component, state) { } window.addEventListener("scroll", onwindowscroll); - component.observe("y", function(y) { - window_updating = true; - clearTimeout(window_updating_timeout); - window.scrollTo(window.pageXOffset, y); - window_updating_timeout = setTimeout(clear_window_updating, 100); + component.on("state", ({ changed, current }) => { + if (changed["y"]) { + window_updating = true; + clearTimeout(window_updating_timeout); + window.scrollTo(window.pageXOffset, current["y"]); + window_updating_timeout = setTimeout(clear_window_updating, 100); + } }); return { diff --git a/test/js/samples/window-binding-scroll/input-v2.html b/test/js/samples/window-binding-scroll/input-v2.html deleted file mode 100644 index 74ace567ab20..000000000000 --- a/test/js/samples/window-binding-scroll/input-v2.html +++ /dev/null @@ -1,3 +0,0 @@ -<:Window bind:scrollY=y/> - -

scrolled to {y}

\ No newline at end of file diff --git a/test/js/samples/window-binding-scroll/input.html b/test/js/samples/window-binding-scroll/input.html index 2365bfcc9622..f2f6e2c91cb3 100644 --- a/test/js/samples/window-binding-scroll/input.html +++ b/test/js/samples/window-binding-scroll/input.html @@ -1,3 +1,3 @@ -<:Window bind:scrollY=y/> + -

scrolled to {{y}}

\ No newline at end of file +

scrolled to {y}

\ No newline at end of file diff --git a/test/parser/index.js b/test/parser/index.js index 06383b975f36..7a87fc51b1eb 100644 --- a/test/parser/index.js +++ b/test/parser/index.js @@ -18,48 +18,33 @@ describe('parse', () => { (solo ? it.only : it)(dir, () => { const options = tryToLoadJson(`test/parser/samples/${dir}/options.json`) || {}; - function test(options, input, expectedOutput, expectedError, outputFile) { - try { - const actual = svelte.parse(input, options); + const input = fs.readFileSync(`test/parser/samples/${dir}/input.html`, 'utf-8').replace(/\s+$/, ''); + const expectedOutput = tryToLoadJson(`test/parser/samples/${dir}/output.json`); + const expectedError = tryToLoadJson(`test/parser/samples/${dir}/error.json`); + + try { + const actual = svelte.parse(input, options); - fs.writeFileSync(outputFile, JSON.stringify(actual, null, '\t')); + fs.writeFileSync(`test/parser/samples/${dir}/_actual.json`, JSON.stringify(actual, null, '\t')); - assert.deepEqual(actual.html, expectedOutput.html); - assert.deepEqual(actual.css, expectedOutput.css); - assert.deepEqual(actual.js, expectedOutput.js); - } catch (err) { - if (err.name !== 'ParseError') throw err; - if (!expectedError) throw err; + assert.deepEqual(actual.html, expectedOutput.html); + assert.deepEqual(actual.css, expectedOutput.css); + assert.deepEqual(actual.js, expectedOutput.js); + } catch (err) { + if (err.name !== 'ParseError') throw err; + if (!expectedError) throw err; - try { - assert.equal(err.code, expectedError.code); - assert.equal(err.message, expectedError.message); - assert.deepEqual(err.loc, expectedError.loc); - assert.equal(err.pos, expectedError.pos); - assert.equal(err.toString().split('\n')[0], `${expectedError.message} (${expectedError.loc.line}:${expectedError.loc.column})`); - } catch (err2) { - const e = err2.code === 'MODULE_NOT_FOUND' ? err : err2; - throw e; - } + try { + assert.equal(err.code, expectedError.code); + assert.equal(err.message, expectedError.message); + assert.deepEqual(err.start, expectedError.start); + assert.equal(err.pos, expectedError.pos); + assert.equal(err.toString().split('\n')[0], `${expectedError.message} (${expectedError.start.line}:${expectedError.start.column})`); + } catch (err2) { + const e = err2.code === 'MODULE_NOT_FOUND' ? err : err2; + throw e; } } - - // TODO remove v1 tests - test( - options, - fs.readFileSync(`test/parser/samples/${dir}/input.html`, 'utf-8').replace(/\s+$/, ''), - tryToLoadJson(`test/parser/samples/${dir}/output.json`), - tryToLoadJson(`test/parser/samples/${dir}/error.json`), - `test/parser/samples/${dir}/_actual.json` - ); - - test( - Object.assign({ parser: 'v2' }, options), - fs.readFileSync(`test/parser/samples/${dir}/input-v2.html`, 'utf-8').replace(/\s+$/, ''), - tryToLoadJson(`test/parser/samples/${dir}/output-v2.json`), - tryToLoadJson(`test/parser/samples/${dir}/error-v2.json`), - `test/parser/samples/${dir}/_actual-v2.json` - ); }); }); diff --git a/test/parser/samples/action-with-call/input-v2.html b/test/parser/samples/action-with-call/input-v2.html deleted file mode 100644 index 246bf02c59c3..000000000000 --- a/test/parser/samples/action-with-call/input-v2.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/test/parser/samples/action-with-call/output-v2.json b/test/parser/samples/action-with-call/output-v2.json deleted file mode 100644 index f5cc6824f3d9..000000000000 --- a/test/parser/samples/action-with-call/output-v2.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "hash": 1937205193, - "html": { - "start": 0, - "end": 38, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 38, - "type": "Element", - "name": "input", - "attributes": [ - { - "start": 7, - "end": 37, - "type": "Action", - "name": "tooltip", - "expression": { - "type": "CallExpression", - "start": 20, - "end": 36, - "callee": { - "type": "Identifier", - "start": 20, - "end": 21, - "name": "t" - }, - "arguments": [ - { - "type": "Literal", - "start": 22, - "end": 35, - "value": "tooltip msg", - "raw": "'tooltip msg'" - } - ] - } - } - ], - "children": [] - } - ] - }, - "css": null, - "js": null -} \ No newline at end of file diff --git a/test/parser/samples/action-with-identifier/input-v2.html b/test/parser/samples/action-with-identifier/input-v2.html deleted file mode 100644 index 14a65e83ed72..000000000000 --- a/test/parser/samples/action-with-identifier/input-v2.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/test/parser/samples/action-with-identifier/output-v2.json b/test/parser/samples/action-with-identifier/output-v2.json deleted file mode 100644 index 6c39ed94bc16..000000000000 --- a/test/parser/samples/action-with-identifier/output-v2.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "hash": 1937205193, - "html": { - "start": 0, - "end": 29, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 29, - "type": "Element", - "name": "input", - "attributes": [ - { - "start": 7, - "end": 28, - "type": "Action", - "name": "tooltip", - "expression": { - "type": "Identifier", - "start": 20, - "end": 27, - "name": "message" - } - } - ], - "children": [] - } - ] - }, - "css": null, - "js": null -} \ No newline at end of file diff --git a/test/parser/samples/action-with-literal/input-v2.html b/test/parser/samples/action-with-literal/input-v2.html deleted file mode 100644 index 60e16eacfc7c..000000000000 --- a/test/parser/samples/action-with-literal/input-v2.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/test/parser/samples/action-with-literal/output-v2.json b/test/parser/samples/action-with-literal/output-v2.json deleted file mode 100644 index 0da031888714..000000000000 --- a/test/parser/samples/action-with-literal/output-v2.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "hash": 1937205193, - "html": { - "start": 0, - "end": 35, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 35, - "type": "Element", - "name": "input", - "attributes": [ - { - "start": 7, - "end": 34, - "type": "Action", - "name": "tooltip", - "expression": { - "type": "Literal", - "start": 20, - "end": 33, - "value": "tooltip msg", - "raw": "'tooltip msg'" - } - } - ], - "children": [] - } - ] - }, - "css": null, - "js": null -} \ No newline at end of file diff --git a/test/parser/samples/action/input-v2.html b/test/parser/samples/action/input-v2.html deleted file mode 100644 index 64409c2a6507..000000000000 --- a/test/parser/samples/action/input-v2.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/test/parser/samples/action/output-v2.json b/test/parser/samples/action/output-v2.json deleted file mode 100644 index 597ae297a533..000000000000 --- a/test/parser/samples/action/output-v2.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "hash": 1937205193, - "html": { - "start": 0, - "end": 21, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 21, - "type": "Element", - "name": "input", - "attributes": [ - { - "start": 7, - "end": 20, - "type": "Action", - "name": "autofocus", - "expression": null - } - ], - "children": [] - } - ] - }, - "css": null, - "js": null -} \ No newline at end of file diff --git a/test/parser/samples/attribute-dynamic-boolean/input-v2.html b/test/parser/samples/attribute-dynamic-boolean/input-v2.html deleted file mode 100644 index ba531f2f8116..000000000000 --- a/test/parser/samples/attribute-dynamic-boolean/input-v2.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/test/parser/samples/attribute-dynamic-boolean/input.html b/test/parser/samples/attribute-dynamic-boolean/input.html index 59683fecb131..ba531f2f8116 100644 --- a/test/parser/samples/attribute-dynamic-boolean/input.html +++ b/test/parser/samples/attribute-dynamic-boolean/input.html @@ -1 +1 @@ - + diff --git a/test/parser/samples/attribute-dynamic-boolean/output-v2.json b/test/parser/samples/attribute-dynamic-boolean/output-v2.json deleted file mode 100644 index 4d08df34a0d6..000000000000 --- a/test/parser/samples/attribute-dynamic-boolean/output-v2.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "hash": "7xolfv", - "html": { - "start": 0, - "end": 41, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 41, - "type": "Element", - "name": "textarea", - "attributes": [ - { - "start": 10, - "end": 29, - "type": "Attribute", - "name": "readonly", - "value": [ - { - "start": 19, - "end": 29, - "type": "MustacheTag", - "expression": { - "type": "Identifier", - "start": 20, - "end": 28, - "name": "readonly" - } - } - ] - } - ], - "children": [] - } - ] - }, - "css": null, - "js": null -} \ No newline at end of file diff --git a/test/parser/samples/attribute-dynamic-boolean/output.json b/test/parser/samples/attribute-dynamic-boolean/output.json index af1635a55d95..4d08df34a0d6 100644 --- a/test/parser/samples/attribute-dynamic-boolean/output.json +++ b/test/parser/samples/attribute-dynamic-boolean/output.json @@ -1,30 +1,30 @@ { - "hash": 3179574701, + "hash": "7xolfv", "html": { "start": 0, - "end": 45, + "end": 41, "type": "Fragment", "children": [ { "start": 0, - "end": 45, + "end": 41, "type": "Element", "name": "textarea", "attributes": [ { "start": 10, - "end": 33, + "end": 29, "type": "Attribute", "name": "readonly", "value": [ { - "start": 20, - "end": 32, + "start": 19, + "end": 29, "type": "MustacheTag", "expression": { "type": "Identifier", - "start": 22, - "end": 30, + "start": 20, + "end": 28, "name": "readonly" } } diff --git a/test/parser/samples/attribute-dynamic-reserved/input-v2.html b/test/parser/samples/attribute-dynamic-reserved/input-v2.html deleted file mode 100644 index d973a9dea043..000000000000 --- a/test/parser/samples/attribute-dynamic-reserved/input-v2.html +++ /dev/null @@ -1 +0,0 @@ -
\ No newline at end of file diff --git a/test/parser/samples/attribute-dynamic-reserved/input.html b/test/parser/samples/attribute-dynamic-reserved/input.html index 6b149d165fe8..d973a9dea043 100644 --- a/test/parser/samples/attribute-dynamic-reserved/input.html +++ b/test/parser/samples/attribute-dynamic-reserved/input.html @@ -1 +1 @@ -
\ No newline at end of file +
\ No newline at end of file diff --git a/test/parser/samples/attribute-dynamic-reserved/output-v2.json b/test/parser/samples/attribute-dynamic-reserved/output-v2.json deleted file mode 100644 index 4b6506b0cdf1..000000000000 --- a/test/parser/samples/attribute-dynamic-reserved/output-v2.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "hash": "l0cddf", - "html": { - "start": 0, - "end": 25, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 25, - "type": "Element", - "name": "div", - "attributes": [ - { - "start": 5, - "end": 18, - "type": "Attribute", - "name": "class", - "value": [ - { - "start": 11, - "end": 18, - "type": "MustacheTag", - "expression": { - "type": "Identifier", - "start": 12, - "end": 17, - "name": "class" - } - } - ] - } - ], - "children": [] - } - ] - }, - "css": null, - "js": null -} \ No newline at end of file diff --git a/test/parser/samples/attribute-dynamic-reserved/output.json b/test/parser/samples/attribute-dynamic-reserved/output.json index aef0e5cb63ca..4b6506b0cdf1 100644 --- a/test/parser/samples/attribute-dynamic-reserved/output.json +++ b/test/parser/samples/attribute-dynamic-reserved/output.json @@ -1,30 +1,30 @@ { - "hash": 2788845841, + "hash": "l0cddf", "html": { "start": 0, - "end": 29, + "end": 25, "type": "Fragment", "children": [ { "start": 0, - "end": 29, + "end": 25, "type": "Element", "name": "div", "attributes": [ { "start": 5, - "end": 22, + "end": 18, "type": "Attribute", "name": "class", "value": [ { - "start": 12, - "end": 21, + "start": 11, + "end": 18, "type": "MustacheTag", "expression": { "type": "Identifier", - "start": 14, - "end": 19, + "start": 12, + "end": 17, "name": "class" } } diff --git a/test/parser/samples/attribute-dynamic/input-v2.html b/test/parser/samples/attribute-dynamic/input-v2.html deleted file mode 100644 index 9171ae22a77e..000000000000 --- a/test/parser/samples/attribute-dynamic/input-v2.html +++ /dev/null @@ -1 +0,0 @@ -
{color}
diff --git a/test/parser/samples/attribute-dynamic/input.html b/test/parser/samples/attribute-dynamic/input.html index 84a34b91ff32..9171ae22a77e 100644 --- a/test/parser/samples/attribute-dynamic/input.html +++ b/test/parser/samples/attribute-dynamic/input.html @@ -1 +1 @@ -
{{color}}
+
{color}
diff --git a/test/parser/samples/attribute-dynamic/output-v2.json b/test/parser/samples/attribute-dynamic/output-v2.json deleted file mode 100644 index 7ccb40d313fa..000000000000 --- a/test/parser/samples/attribute-dynamic/output-v2.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "hash": "ehtsx6", - "html": { - "start": 0, - "end": 42, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 42, - "type": "Element", - "name": "div", - "attributes": [ - { - "start": 5, - "end": 28, - "type": "Attribute", - "name": "style", - "value": [ - { - "start": 12, - "end": 19, - "type": "Text", - "data": "color: " - }, - { - "start": 19, - "end": 26, - "type": "MustacheTag", - "expression": { - "type": "Identifier", - "start": 20, - "end": 25, - "name": "color" - } - }, - { - "start": 26, - "end": 27, - "type": "Text", - "data": ";" - } - ] - } - ], - "children": [ - { - "start": 29, - "end": 36, - "type": "MustacheTag", - "expression": { - "type": "Identifier", - "start": 30, - "end": 35, - "name": "color" - } - } - ] - } - ] - }, - "css": null, - "js": null -} \ No newline at end of file diff --git a/test/parser/samples/attribute-dynamic/output.json b/test/parser/samples/attribute-dynamic/output.json index 79ef81065fc7..7ccb40d313fa 100644 --- a/test/parser/samples/attribute-dynamic/output.json +++ b/test/parser/samples/attribute-dynamic/output.json @@ -1,19 +1,19 @@ { - "hash": 804348386, + "hash": "ehtsx6", "html": { "start": 0, - "end": 46, + "end": 42, "type": "Fragment", "children": [ { "start": 0, - "end": 46, + "end": 42, "type": "Element", "name": "div", "attributes": [ { "start": 5, - "end": 30, + "end": 28, "type": "Attribute", "name": "style", "value": [ @@ -25,18 +25,18 @@ }, { "start": 19, - "end": 28, + "end": 26, "type": "MustacheTag", "expression": { "type": "Identifier", - "start": 21, - "end": 26, + "start": 20, + "end": 25, "name": "color" } }, { - "start": 28, - "end": 29, + "start": 26, + "end": 27, "type": "Text", "data": ";" } @@ -45,13 +45,13 @@ ], "children": [ { - "start": 31, - "end": 40, + "start": 29, + "end": 36, "type": "MustacheTag", "expression": { "type": "Identifier", - "start": 33, - "end": 38, + "start": 30, + "end": 35, "name": "color" } } diff --git a/test/parser/samples/attribute-escaped/input-v2.html b/test/parser/samples/attribute-escaped/input-v2.html deleted file mode 100644 index 82186dcee47b..000000000000 --- a/test/parser/samples/attribute-escaped/input-v2.html +++ /dev/null @@ -1 +0,0 @@ -
diff --git a/test/parser/samples/attribute-escaped/output-v2.json b/test/parser/samples/attribute-escaped/output-v2.json deleted file mode 100644 index 974084bcdde3..000000000000 --- a/test/parser/samples/attribute-escaped/output-v2.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "hash": 1563956934, - "html": { - "start": 0, - "end": 41, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 41, - "type": "Element", - "name": "div", - "attributes": [ - { - "start": 5, - "end": 34, - "type": "Attribute", - "name": "data-foo", - "value": [ - { - "start": 15, - "end": 33, - "type": "Text", - "data": "\"quoted\"" - } - ] - } - ], - "children": [] - } - ] - }, - "css": null, - "js": null -} \ No newline at end of file diff --git a/test/parser/samples/attribute-multiple/input-v2.html b/test/parser/samples/attribute-multiple/input-v2.html deleted file mode 100644 index 6f61bd628983..000000000000 --- a/test/parser/samples/attribute-multiple/input-v2.html +++ /dev/null @@ -1 +0,0 @@ -
\ No newline at end of file diff --git a/test/parser/samples/attribute-multiple/input.html b/test/parser/samples/attribute-multiple/input.html index a5adf38f2cc5..6f61bd628983 100644 --- a/test/parser/samples/attribute-multiple/input.html +++ b/test/parser/samples/attribute-multiple/input.html @@ -1 +1 @@ -
+
\ No newline at end of file diff --git a/test/parser/samples/attribute-multiple/output-v2.json b/test/parser/samples/attribute-multiple/output-v2.json deleted file mode 100644 index 81af977b51a1..000000000000 --- a/test/parser/samples/attribute-multiple/output-v2.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "hash": 507039402, - "html": { - "start": 0, - "end": 28, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 28, - "type": "Element", - "name": "div", - "attributes": [ - { - "start": 5, - "end": 11, - "type": "Attribute", - "name": "id", - "value": [ - { - "start": 9, - "end": 10, - "type": "Text", - "data": "x" - } - ] - }, - { - "start": 12, - "end": 21, - "type": "Attribute", - "name": "class", - "value": [ - { - "start": 19, - "end": 20, - "type": "Text", - "data": "y" - } - ] - } - ], - "children": [] - } - ] - }, - "css": null, - "js": null -} \ No newline at end of file diff --git a/test/parser/samples/attribute-shorthand/input-v2.html b/test/parser/samples/attribute-shorthand/input-v2.html deleted file mode 100644 index 35468de00697..000000000000 --- a/test/parser/samples/attribute-shorthand/input-v2.html +++ /dev/null @@ -1 +0,0 @@ -
\ No newline at end of file diff --git a/test/parser/samples/attribute-shorthand/input.html b/test/parser/samples/attribute-shorthand/input.html index e26deafb3a3d..35468de00697 100644 --- a/test/parser/samples/attribute-shorthand/input.html +++ b/test/parser/samples/attribute-shorthand/input.html @@ -1 +1 @@ -
\ No newline at end of file +
\ No newline at end of file diff --git a/test/parser/samples/attribute-shorthand/output-v2.json b/test/parser/samples/attribute-shorthand/output-v2.json deleted file mode 100644 index 598356350b99..000000000000 --- a/test/parser/samples/attribute-shorthand/output-v2.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "hash": 1705925892, - "html": { - "start": 0, - "end": 11, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 11, - "type": "Element", - "name": "div", - "attributes": [ - { - "start": 5, - "end": 9, - "type": "Attribute", - "name": "id", - "value": [ - { - "type": "AttributeShorthand", - "start": 6, - "end": 8, - "expression": { - "type": "Identifier", - "start": 6, - "end": 8, - "name": "id" - } - } - ] - } - ], - "children": [] - } - ] - }, - "css": null, - "js": null -} \ No newline at end of file diff --git a/test/parser/samples/attribute-shorthand/output.json b/test/parser/samples/attribute-shorthand/output.json index b6578c13eb51..598356350b99 100644 --- a/test/parser/samples/attribute-shorthand/output.json +++ b/test/parser/samples/attribute-shorthand/output.json @@ -2,18 +2,18 @@ "hash": 1705925892, "html": { "start": 0, - "end": 10, + "end": 11, "type": "Fragment", "children": [ { "start": 0, - "end": 10, + "end": 11, "type": "Element", "name": "div", "attributes": [ { "start": 5, - "end": 8, + "end": 9, "type": "Attribute", "name": "id", "value": [ diff --git a/test/parser/samples/attribute-static-boolean/input-v2.html b/test/parser/samples/attribute-static-boolean/input-v2.html deleted file mode 100644 index 1536f3e1e882..000000000000 --- a/test/parser/samples/attribute-static-boolean/input-v2.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/test/parser/samples/attribute-static-boolean/input.html b/test/parser/samples/attribute-static-boolean/input.html index 3ca3bfd9a856..1536f3e1e882 100644 --- a/test/parser/samples/attribute-static-boolean/input.html +++ b/test/parser/samples/attribute-static-boolean/input.html @@ -1 +1 @@ - + \ No newline at end of file diff --git a/test/parser/samples/attribute-static-boolean/output-v2.json b/test/parser/samples/attribute-static-boolean/output-v2.json deleted file mode 100644 index 21429893fd7d..000000000000 --- a/test/parser/samples/attribute-static-boolean/output-v2.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "hash": 606864228, - "html": { - "start": 0, - "end": 30, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 30, - "type": "Element", - "name": "textarea", - "attributes": [ - { - "start": 10, - "end": 18, - "type": "Attribute", - "name": "readonly", - "value": true - } - ], - "children": [] - } - ] - }, - "css": null, - "js": null -} \ No newline at end of file diff --git a/test/parser/samples/attribute-static/input-v2.html b/test/parser/samples/attribute-static/input-v2.html deleted file mode 100644 index c6a8a8c95d59..000000000000 --- a/test/parser/samples/attribute-static/input-v2.html +++ /dev/null @@ -1 +0,0 @@ -
\ No newline at end of file diff --git a/test/parser/samples/attribute-static/input.html b/test/parser/samples/attribute-static/input.html index 3cb2e4b23307..c6a8a8c95d59 100644 --- a/test/parser/samples/attribute-static/input.html +++ b/test/parser/samples/attribute-static/input.html @@ -1 +1 @@ -
+
\ No newline at end of file diff --git a/test/parser/samples/attribute-static/output-v2.json b/test/parser/samples/attribute-static/output-v2.json deleted file mode 100644 index 394f95f4580e..000000000000 --- a/test/parser/samples/attribute-static/output-v2.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "hash": 1493227373, - "html": { - "start": 0, - "end": 23, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 23, - "type": "Element", - "name": "div", - "attributes": [ - { - "start": 5, - "end": 16, - "type": "Attribute", - "name": "class", - "value": [ - { - "start": 12, - "end": 15, - "type": "Text", - "data": "foo" - } - ] - } - ], - "children": [] - } - ] - }, - "css": null, - "js": null -} \ No newline at end of file diff --git a/test/parser/samples/attribute-unique-error/error-v2.json b/test/parser/samples/attribute-unique-error/error-v2.json deleted file mode 100644 index 737157b24657..000000000000 --- a/test/parser/samples/attribute-unique-error/error-v2.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "code": "duplicate-attribute", - "message": "Attributes need to be unique", - "loc": { - "line": 1, - "column": 17 - }, - "pos": 17 -} diff --git a/test/parser/samples/attribute-unique-error/error.json b/test/parser/samples/attribute-unique-error/error.json index 737157b24657..dd145721499e 100644 --- a/test/parser/samples/attribute-unique-error/error.json +++ b/test/parser/samples/attribute-unique-error/error.json @@ -1,9 +1,10 @@ { "code": "duplicate-attribute", "message": "Attributes need to be unique", - "loc": { + "start": { "line": 1, - "column": 17 + "column": 17, + "character": 17 }, "pos": 17 } diff --git a/test/parser/samples/attribute-unique-error/input-v2.html b/test/parser/samples/attribute-unique-error/input-v2.html deleted file mode 100644 index 37fec733b3ce..000000000000 --- a/test/parser/samples/attribute-unique-error/input-v2.html +++ /dev/null @@ -1 +0,0 @@ -
\ No newline at end of file diff --git a/test/parser/samples/attribute-unique-error/input.html b/test/parser/samples/attribute-unique-error/input.html index 4088350ce0bd..37fec733b3ce 100644 --- a/test/parser/samples/attribute-unique-error/input.html +++ b/test/parser/samples/attribute-unique-error/input.html @@ -1 +1 @@ -
+
\ No newline at end of file diff --git a/test/parser/samples/attribute-unquoted/input-v2.html b/test/parser/samples/attribute-unquoted/input-v2.html deleted file mode 100644 index 4bab0df72f3e..000000000000 --- a/test/parser/samples/attribute-unquoted/input-v2.html +++ /dev/null @@ -1 +0,0 @@ -
\ No newline at end of file diff --git a/test/parser/samples/attribute-unquoted/input.html b/test/parser/samples/attribute-unquoted/input.html index 2d388456d0d8..4bab0df72f3e 100644 --- a/test/parser/samples/attribute-unquoted/input.html +++ b/test/parser/samples/attribute-unquoted/input.html @@ -1 +1 @@ -
+
\ No newline at end of file diff --git a/test/parser/samples/attribute-unquoted/output-v2.json b/test/parser/samples/attribute-unquoted/output-v2.json deleted file mode 100644 index 474d925b2e47..000000000000 --- a/test/parser/samples/attribute-unquoted/output-v2.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "hash": 3488539025, - "html": { - "start": 0, - "end": 21, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 21, - "type": "Element", - "name": "div", - "attributes": [ - { - "start": 5, - "end": 14, - "type": "Attribute", - "name": "class", - "value": [ - { - "start": 11, - "end": 14, - "type": "Text", - "data": "foo" - } - ] - } - ], - "children": [] - } - ] - }, - "css": null, - "js": null -} \ No newline at end of file diff --git a/test/parser/samples/await-then-catch/input-v2.html b/test/parser/samples/await-then-catch/input-v2.html deleted file mode 100644 index 79f5162ace24..000000000000 --- a/test/parser/samples/await-then-catch/input-v2.html +++ /dev/null @@ -1,7 +0,0 @@ -{#await thePromise} -

loading...

-{:then theValue} -

the value is {theValue}

-{:catch theError} -

oh no! {theError.message}

-{/await} \ No newline at end of file diff --git a/test/parser/samples/await-then-catch/input.html b/test/parser/samples/await-then-catch/input.html index 36489b90430b..79f5162ace24 100644 --- a/test/parser/samples/await-then-catch/input.html +++ b/test/parser/samples/await-then-catch/input.html @@ -1,7 +1,7 @@ -{{#await thePromise}} +{#await thePromise}

loading...

-{{then theValue}} -

the value is {{theValue}}

-{{catch theError}} -

oh no! {{theError.message}}

-{{/await}} \ No newline at end of file +{:then theValue} +

the value is {theValue}

+{:catch theError} +

oh no! {theError.message}

+{/await} \ No newline at end of file diff --git a/test/parser/samples/await-then-catch/output-v2.json b/test/parser/samples/await-then-catch/output-v2.json deleted file mode 100644 index 22ad4242e354..000000000000 --- a/test/parser/samples/await-then-catch/output-v2.json +++ /dev/null @@ -1,161 +0,0 @@ -{ - "hash": "1b28gs9", - "html": { - "start": 0, - "end": 148, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 148, - "type": "AwaitBlock", - "expression": { - "type": "Identifier", - "start": 8, - "end": 18, - "name": "thePromise" - }, - "value": "theValue", - "error": "theError", - "pending": { - "start": 19, - "end": 39, - "type": "PendingBlock", - "children": [ - { - "start": 19, - "end": 21, - "type": "Text", - "data": "\n\t" - }, - { - "start": 21, - "end": 38, - "type": "Element", - "name": "p", - "attributes": [], - "children": [ - { - "start": 24, - "end": 34, - "type": "Text", - "data": "loading..." - } - ] - }, - { - "start": 38, - "end": 39, - "type": "Text", - "data": "\n" - } - ] - }, - "then": { - "start": 39, - "end": 88, - "type": "ThenBlock", - "children": [ - { - "start": 55, - "end": 57, - "type": "Text", - "data": "\n\t" - }, - { - "start": 57, - "end": 87, - "type": "Element", - "name": "p", - "attributes": [], - "children": [ - { - "start": 60, - "end": 73, - "type": "Text", - "data": "the value is " - }, - { - "start": 73, - "end": 83, - "type": "MustacheTag", - "expression": { - "type": "Identifier", - "start": 74, - "end": 82, - "name": "theValue" - } - } - ] - }, - { - "start": 87, - "end": 88, - "type": "Text", - "data": "\n" - } - ] - }, - "catch": { - "start": 88, - "end": 140, - "type": "CatchBlock", - "children": [ - { - "start": 105, - "end": 107, - "type": "Text", - "data": "\n\t" - }, - { - "start": 107, - "end": 139, - "type": "Element", - "name": "p", - "attributes": [], - "children": [ - { - "start": 110, - "end": 117, - "type": "Text", - "data": "oh no! " - }, - { - "start": 117, - "end": 135, - "type": "MustacheTag", - "expression": { - "type": "MemberExpression", - "start": 118, - "end": 134, - "object": { - "type": "Identifier", - "start": 118, - "end": 126, - "name": "theError" - }, - "property": { - "type": "Identifier", - "start": 127, - "end": 134, - "name": "message" - }, - "computed": false - } - } - ] - }, - { - "start": 139, - "end": 140, - "type": "Text", - "data": "\n" - } - ] - } - } - ] - }, - "css": null, - "js": null -} \ No newline at end of file diff --git a/test/parser/samples/await-then-catch/output.json b/test/parser/samples/await-then-catch/output.json index 4f149e6a0cba..22ad4242e354 100644 --- a/test/parser/samples/await-then-catch/output.json +++ b/test/parser/samples/await-then-catch/output.json @@ -1,143 +1,143 @@ { - "hash": 1040536517, + "hash": "1b28gs9", "html": { "start": 0, - "end": 158, + "end": 148, "type": "Fragment", "children": [ { "start": 0, - "end": 158, + "end": 148, "type": "AwaitBlock", "expression": { "type": "Identifier", - "start": 9, - "end": 19, + "start": 8, + "end": 18, "name": "thePromise" }, "value": "theValue", "error": "theError", "pending": { - "start": 21, - "end": 41, + "start": 19, + "end": 39, "type": "PendingBlock", "children": [ { - "start": 21, - "end": 23, + "start": 19, + "end": 21, "type": "Text", "data": "\n\t" }, { - "start": 23, - "end": 40, + "start": 21, + "end": 38, "type": "Element", "name": "p", "attributes": [], "children": [ { - "start": 26, - "end": 36, + "start": 24, + "end": 34, "type": "Text", "data": "loading..." } ] }, { - "start": 40, - "end": 41, + "start": 38, + "end": 39, "type": "Text", "data": "\n" } ] }, "then": { - "start": 41, - "end": 93, + "start": 39, + "end": 88, "type": "ThenBlock", "children": [ { - "start": 58, - "end": 60, + "start": 55, + "end": 57, "type": "Text", "data": "\n\t" }, { - "start": 60, - "end": 92, + "start": 57, + "end": 87, "type": "Element", "name": "p", "attributes": [], "children": [ { - "start": 63, - "end": 76, + "start": 60, + "end": 73, "type": "Text", "data": "the value is " }, { - "start": 76, - "end": 88, + "start": 73, + "end": 83, "type": "MustacheTag", "expression": { "type": "Identifier", - "start": 78, - "end": 86, + "start": 74, + "end": 82, "name": "theValue" } } ] }, { - "start": 92, - "end": 93, + "start": 87, + "end": 88, "type": "Text", "data": "\n" } ] }, "catch": { - "start": 93, - "end": 148, + "start": 88, + "end": 140, "type": "CatchBlock", "children": [ { - "start": 111, - "end": 113, + "start": 105, + "end": 107, "type": "Text", "data": "\n\t" }, { - "start": 113, - "end": 147, + "start": 107, + "end": 139, "type": "Element", "name": "p", "attributes": [], "children": [ { - "start": 116, - "end": 123, + "start": 110, + "end": 117, "type": "Text", "data": "oh no! " }, { - "start": 123, - "end": 143, + "start": 117, + "end": 135, "type": "MustacheTag", "expression": { "type": "MemberExpression", - "start": 125, - "end": 141, + "start": 118, + "end": 134, "object": { "type": "Identifier", - "start": 125, - "end": 133, + "start": 118, + "end": 126, "name": "theError" }, "property": { "type": "Identifier", - "start": 134, - "end": 141, + "start": 127, + "end": 134, "name": "message" }, "computed": false @@ -146,8 +146,8 @@ ] }, { - "start": 147, - "end": 148, + "start": 139, + "end": 140, "type": "Text", "data": "\n" } diff --git a/test/parser/samples/binding-shorthand/input-v2.html b/test/parser/samples/binding-shorthand/input-v2.html deleted file mode 100644 index 7f8116bdded9..000000000000 --- a/test/parser/samples/binding-shorthand/input-v2.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/test/parser/samples/binding-shorthand/input.html b/test/parser/samples/binding-shorthand/input.html index 31f9c872b09b..7f8116bdded9 100644 --- a/test/parser/samples/binding-shorthand/input.html +++ b/test/parser/samples/binding-shorthand/input.html @@ -1 +1 @@ - + \ No newline at end of file diff --git a/test/parser/samples/binding-shorthand/output-v2.json b/test/parser/samples/binding-shorthand/output-v2.json deleted file mode 100644 index 8a7b615cf420..000000000000 --- a/test/parser/samples/binding-shorthand/output-v2.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "hash": 3088875001, - "html": { - "start": 0, - "end": 18, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 18, - "type": "Element", - "name": "Widget", - "attributes": [ - { - "start": 8, - "end": 16, - "type": "Binding", - "name": "foo", - "value": { - "type": "Identifier", - "start": 13, - "end": 16, - "name": "foo" - } - } - ], - "children": [] - } - ] - }, - "css": null, - "js": null -} \ No newline at end of file diff --git a/test/parser/samples/binding/input-v2.html b/test/parser/samples/binding/input-v2.html deleted file mode 100644 index 3af20a9ced1b..000000000000 --- a/test/parser/samples/binding/input-v2.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/test/parser/samples/binding/input.html b/test/parser/samples/binding/input.html index 6a7bf8566cbb..3af20a9ced1b 100644 --- a/test/parser/samples/binding/input.html +++ b/test/parser/samples/binding/input.html @@ -1 +1 @@ - + \ No newline at end of file diff --git a/test/parser/samples/binding/output-v2.json b/test/parser/samples/binding/output-v2.json deleted file mode 100644 index 74f2059f5929..000000000000 --- a/test/parser/samples/binding/output-v2.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "hash": 1937205193, - "html": { - "start": 0, - "end": 25, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 25, - "type": "Element", - "name": "input", - "attributes": [ - { - "start": 7, - "end": 24, - "type": "Binding", - "name": "value", - "value": { - "type": "Identifier", - "start": 19, - "end": 23, - "name": "name" - } - } - ], - "children": [] - } - ] - }, - "css": null, - "js": null -} \ No newline at end of file diff --git a/test/parser/samples/comment/input-v2.html b/test/parser/samples/comment/input-v2.html deleted file mode 100644 index 3b3ffe3222f9..000000000000 --- a/test/parser/samples/comment/input-v2.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/test/parser/samples/comment/input.html b/test/parser/samples/comment/input.html index b35c49dac848..3b3ffe3222f9 100644 --- a/test/parser/samples/comment/input.html +++ b/test/parser/samples/comment/input.html @@ -1 +1 @@ - + \ No newline at end of file diff --git a/test/parser/samples/comment/output-v2.json b/test/parser/samples/comment/output-v2.json deleted file mode 100644 index e77c968b6b6b..000000000000 --- a/test/parser/samples/comment/output-v2.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "hash": 3294612990, - "html": { - "start": 0, - "end": 18, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 18, - "type": "Comment", - "data": " a comment " - } - ] - }, - "css": null, - "js": null -} \ No newline at end of file diff --git a/test/parser/samples/component-dynamic/input-v2.html b/test/parser/samples/component-dynamic/input-v2.html deleted file mode 100644 index 1dad5eb269e6..000000000000 --- a/test/parser/samples/component-dynamic/input-v2.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/test/parser/samples/component-dynamic/input.html b/test/parser/samples/component-dynamic/input.html index 0d5be48552ff..1dad5eb269e6 100644 --- a/test/parser/samples/component-dynamic/input.html +++ b/test/parser/samples/component-dynamic/input.html @@ -1 +1 @@ -<:Component {foo ? Foo : Bar}> \ No newline at end of file + \ No newline at end of file diff --git a/test/parser/samples/component-dynamic/output-v2.json b/test/parser/samples/component-dynamic/output-v2.json deleted file mode 100644 index 604103ea14f5..000000000000 --- a/test/parser/samples/component-dynamic/output-v2.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "hash": "2u5ec3", - "html": { - "start": 0, - "end": 62, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 62, - "type": "Element", - "name": "svelte:component", - "attributes": [], - "children": [], - "expression": { - "type": "ConditionalExpression", - "start": 25, - "end": 40, - "test": { - "type": "Identifier", - "start": 25, - "end": 28, - "name": "foo" - }, - "consequent": { - "type": "Identifier", - "start": 31, - "end": 34, - "name": "Foo" - }, - "alternate": { - "type": "Identifier", - "start": 37, - "end": 40, - "name": "Bar" - } - } - } - ] - }, - "css": null, - "js": null -} \ No newline at end of file diff --git a/test/parser/samples/component-dynamic/output.json b/test/parser/samples/component-dynamic/output.json index 614c28c0a9f7..604103ea14f5 100644 --- a/test/parser/samples/component-dynamic/output.json +++ b/test/parser/samples/component-dynamic/output.json @@ -1,37 +1,37 @@ { - "hash": 410218696, + "hash": "2u5ec3", "html": { "start": 0, - "end": 43, + "end": 62, "type": "Fragment", "children": [ { "start": 0, - "end": 43, + "end": 62, "type": "Element", - "name": ":Component", + "name": "svelte:component", "attributes": [], "children": [], "expression": { "type": "ConditionalExpression", - "start": 13, - "end": 28, + "start": 25, + "end": 40, "test": { "type": "Identifier", - "start": 13, - "end": 16, + "start": 25, + "end": 28, "name": "foo" }, "consequent": { "type": "Identifier", - "start": 19, - "end": 22, + "start": 31, + "end": 34, "name": "Foo" }, "alternate": { "type": "Identifier", - "start": 25, - "end": 28, + "start": 37, + "end": 40, "name": "Bar" } } diff --git a/test/parser/samples/convert-entities-in-element/input-v2.html b/test/parser/samples/convert-entities-in-element/input-v2.html deleted file mode 100644 index f05dc391ad3e..000000000000 --- a/test/parser/samples/convert-entities-in-element/input-v2.html +++ /dev/null @@ -1 +0,0 @@ -

Hello & World

\ No newline at end of file diff --git a/test/parser/samples/convert-entities-in-element/input.html b/test/parser/samples/convert-entities-in-element/input.html index bc5c086536ad..f05dc391ad3e 100644 --- a/test/parser/samples/convert-entities-in-element/input.html +++ b/test/parser/samples/convert-entities-in-element/input.html @@ -1 +1 @@ -

Hello & World

+

Hello & World

\ No newline at end of file diff --git a/test/parser/samples/convert-entities-in-element/output-v2.json b/test/parser/samples/convert-entities-in-element/output-v2.json deleted file mode 100644 index cb3e50ec3b2c..000000000000 --- a/test/parser/samples/convert-entities-in-element/output-v2.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "hash": 2365862121, - "html": { - "start": 0, - "end": 24, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 24, - "type": "Element", - "name": "p", - "attributes": [], - "children": [ - { - "start": 3, - "end": 20, - "type": "Text", - "data": "Hello & World" - } - ] - } - ] - }, - "css": null, - "js": null -} \ No newline at end of file diff --git a/test/parser/samples/convert-entities/input-v2.html b/test/parser/samples/convert-entities/input-v2.html deleted file mode 100644 index 161463ec5858..000000000000 --- a/test/parser/samples/convert-entities/input-v2.html +++ /dev/null @@ -1 +0,0 @@ -Hello & World \ No newline at end of file diff --git a/test/parser/samples/convert-entities/input.html b/test/parser/samples/convert-entities/input.html index e25e3214f211..161463ec5858 100644 --- a/test/parser/samples/convert-entities/input.html +++ b/test/parser/samples/convert-entities/input.html @@ -1 +1 @@ -Hello & World +Hello & World \ No newline at end of file diff --git a/test/parser/samples/convert-entities/output-v2.json b/test/parser/samples/convert-entities/output-v2.json deleted file mode 100644 index 479bae306482..000000000000 --- a/test/parser/samples/convert-entities/output-v2.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "hash": 156753432, - "html": { - "start": 0, - "end": 17, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 17, - "type": "Text", - "data": "Hello & World" - } - ] - }, - "css": null, - "js": null -} \ No newline at end of file diff --git a/test/parser/samples/css-ref-selector/input-v2.html b/test/parser/samples/css-ref-selector/input-v2.html deleted file mode 100644 index 696075f93f0c..000000000000 --- a/test/parser/samples/css-ref-selector/input-v2.html +++ /dev/null @@ -1,7 +0,0 @@ -
- - \ No newline at end of file diff --git a/test/parser/samples/css-ref-selector/input.html b/test/parser/samples/css-ref-selector/input.html index 07ab3790f748..696075f93f0c 100644 --- a/test/parser/samples/css-ref-selector/input.html +++ b/test/parser/samples/css-ref-selector/input.html @@ -4,4 +4,4 @@ ref:foo { color: red; } - + \ No newline at end of file diff --git a/test/parser/samples/css-ref-selector/output-v2.json b/test/parser/samples/css-ref-selector/output-v2.json deleted file mode 100644 index 2ddafc4aae16..000000000000 --- a/test/parser/samples/css-ref-selector/output-v2.json +++ /dev/null @@ -1,96 +0,0 @@ -{ - "hash": 1104014177, - "html": { - "start": 0, - "end": 14, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 14, - "type": "Element", - "name": "div", - "attributes": [ - { - "start": 5, - "end": 12, - "type": "Ref", - "name": "foo" - } - ], - "children": [] - }, - { - "start": 14, - "end": 16, - "type": "Text", - "data": "\n\n" - } - ] - }, - "css": { - "start": 16, - "end": 60, - "attributes": [], - "children": [ - { - "type": "Rule", - "selector": { - "type": "SelectorList", - "children": [ - { - "type": "Selector", - "children": [ - { - "type": "RefSelector", - "start": 25, - "end": 32, - "name": "foo" - } - ], - "start": 25, - "end": 32 - } - ], - "start": 25, - "end": 32 - }, - "block": { - "type": "Block", - "children": [ - { - "type": "Declaration", - "important": false, - "property": "color", - "value": { - "type": "Value", - "children": [ - { - "type": "Identifier", - "name": "red", - "start": 44, - "end": 47 - } - ], - "start": 43, - "end": 47 - }, - "start": 37, - "end": 47 - } - ], - "start": 33, - "end": 51 - }, - "start": 25, - "end": 51 - } - ], - "content": { - "start": 23, - "end": 52, - "styles": "\n\tref:foo {\n\t\tcolor: red;\n\t}\n" - } - }, - "js": null -} \ No newline at end of file diff --git a/test/parser/samples/css/input-v2.html b/test/parser/samples/css/input-v2.html deleted file mode 100644 index a573bcf778a3..000000000000 --- a/test/parser/samples/css/input-v2.html +++ /dev/null @@ -1,7 +0,0 @@ -
foo
- - \ No newline at end of file diff --git a/test/parser/samples/css/input.html b/test/parser/samples/css/input.html index 659c4343f632..a573bcf778a3 100644 --- a/test/parser/samples/css/input.html +++ b/test/parser/samples/css/input.html @@ -4,4 +4,4 @@ div { color: red; } - + \ No newline at end of file diff --git a/test/parser/samples/css/output-v2.json b/test/parser/samples/css/output-v2.json deleted file mode 100644 index 4650ccea46bb..000000000000 --- a/test/parser/samples/css/output-v2.json +++ /dev/null @@ -1,96 +0,0 @@ -{ - "hash": 1147407419, - "html": { - "start": 0, - "end": 14, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 14, - "type": "Element", - "name": "div", - "attributes": [], - "children": [ - { - "start": 5, - "end": 8, - "type": "Text", - "data": "foo" - } - ] - }, - { - "start": 14, - "end": 16, - "type": "Text", - "data": "\n\n" - } - ] - }, - "css": { - "start": 16, - "end": 56, - "attributes": [], - "children": [ - { - "type": "Rule", - "selector": { - "type": "SelectorList", - "children": [ - { - "type": "Selector", - "children": [ - { - "type": "TypeSelector", - "name": "div", - "start": 25, - "end": 28 - } - ], - "start": 25, - "end": 28 - } - ], - "start": 25, - "end": 28 - }, - "block": { - "type": "Block", - "children": [ - { - "type": "Declaration", - "important": false, - "property": "color", - "value": { - "type": "Value", - "children": [ - { - "type": "Identifier", - "name": "red", - "start": 40, - "end": 43 - } - ], - "start": 39, - "end": 43 - }, - "start": 33, - "end": 43 - } - ], - "start": 29, - "end": 47 - }, - "start": 25, - "end": 47 - } - ], - "content": { - "start": 23, - "end": 48, - "styles": "\n\tdiv {\n\t\tcolor: red;\n\t}\n" - } - }, - "js": null -} \ No newline at end of file diff --git a/test/parser/samples/dynamic-import/input-v2.html b/test/parser/samples/dynamic-import/input-v2.html deleted file mode 100644 index 553ca6c38c5d..000000000000 --- a/test/parser/samples/dynamic-import/input-v2.html +++ /dev/null @@ -1,9 +0,0 @@ - \ No newline at end of file diff --git a/test/parser/samples/dynamic-import/output-v2.json b/test/parser/samples/dynamic-import/output-v2.json deleted file mode 100644 index b27a780a58e4..000000000000 --- a/test/parser/samples/dynamic-import/output-v2.json +++ /dev/null @@ -1,182 +0,0 @@ -{ - "hash": 1867472549, - "html": { - "start": null, - "end": null, - "type": "Fragment", - "children": [] - }, - "css": null, - "js": { - "start": 0, - "end": 131, - "attributes": [], - "content": { - "type": "Program", - "start": 8, - "end": 122, - "body": [ - { - "type": "ExportDefaultDeclaration", - "start": 10, - "end": 121, - "declaration": { - "type": "ObjectExpression", - "start": 25, - "end": 121, - "properties": [ - { - "type": "Property", - "start": 29, - "end": 118, - "method": true, - "shorthand": false, - "computed": false, - "key": { - "type": "Identifier", - "start": 29, - "end": 37, - "name": "oncreate" - }, - "kind": "init", - "value": { - "type": "FunctionExpression", - "start": 37, - "end": 118, - "id": null, - "generator": false, - "expression": false, - "async": false, - "params": [], - "body": { - "type": "BlockStatement", - "start": 40, - "end": 118, - "body": [ - { - "type": "ExpressionStatement", - "start": 45, - "end": 114, - "expression": { - "type": "CallExpression", - "start": 45, - "end": 113, - "callee": { - "type": "MemberExpression", - "start": 45, - "end": 68, - "object": { - "type": "CallExpression", - "start": 45, - "end": 63, - "callee": { - "type": "Import", - "start": 45, - "end": 51 - }, - "arguments": [ - { - "type": "Literal", - "start": 52, - "end": 62, - "value": "./foo.js", - "raw": "'./foo.js'" - } - ] - }, - "property": { - "type": "Identifier", - "start": 64, - "end": 68, - "name": "then" - }, - "computed": false - }, - "arguments": [ - { - "type": "ArrowFunctionExpression", - "start": 69, - "end": 112, - "id": null, - "generator": false, - "expression": false, - "async": false, - "params": [ - { - "type": "Identifier", - "start": 69, - "end": 72, - "name": "foo" - } - ], - "body": { - "type": "BlockStatement", - "start": 76, - "end": 112, - "body": [ - { - "type": "ExpressionStatement", - "start": 82, - "end": 107, - "expression": { - "type": "CallExpression", - "start": 82, - "end": 106, - "callee": { - "type": "MemberExpression", - "start": 82, - "end": 93, - "object": { - "type": "Identifier", - "start": 82, - "end": 89, - "name": "console" - }, - "property": { - "type": "Identifier", - "start": 90, - "end": 93, - "name": "log" - }, - "computed": false - }, - "arguments": [ - { - "type": "MemberExpression", - "start": 94, - "end": 105, - "object": { - "type": "Identifier", - "start": 94, - "end": 97, - "name": "foo" - }, - "property": { - "type": "Identifier", - "start": 98, - "end": 105, - "name": "default" - }, - "computed": false - } - ] - } - } - ] - } - } - ] - } - } - ] - } - } - } - ] - } - } - ], - "sourceType": "module" - } - } -} \ No newline at end of file diff --git a/test/parser/samples/each-block-destructured/input-v2.html b/test/parser/samples/each-block-destructured/input-v2.html deleted file mode 100644 index 4ddf33ef8585..000000000000 --- a/test/parser/samples/each-block-destructured/input-v2.html +++ /dev/null @@ -1,3 +0,0 @@ -{#each animals as [key, value]} -

{key}: {value}

-{/each} diff --git a/test/parser/samples/each-block-destructured/input.html b/test/parser/samples/each-block-destructured/input.html index 7209f5503d8a..4ddf33ef8585 100644 --- a/test/parser/samples/each-block-destructured/input.html +++ b/test/parser/samples/each-block-destructured/input.html @@ -1,3 +1,3 @@ -{{#each animals as [key, value]}} -

{{key}}: {{value}}

-{{/each}} +{#each animals as [key, value]} +

{key}: {value}

+{/each} diff --git a/test/parser/samples/each-block-destructured/output-v2.json b/test/parser/samples/each-block-destructured/output-v2.json deleted file mode 100644 index 38d5ddc770ec..000000000000 --- a/test/parser/samples/each-block-destructured/output-v2.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "hash": "gtdm5e", - "html": { - "start": 0, - "end": 62, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 62, - "type": "EachBlock", - "expression": { - "type": "Identifier", - "start": 7, - "end": 14, - "name": "animals" - }, - "children": [ - { - "start": 33, - "end": 54, - "type": "Element", - "name": "p", - "attributes": [], - "children": [ - { - "start": 36, - "end": 41, - "type": "MustacheTag", - "expression": { - "type": "Identifier", - "start": 37, - "end": 40, - "name": "key" - } - }, - { - "start": 41, - "end": 43, - "type": "Text", - "data": ": " - }, - { - "start": 43, - "end": 50, - "type": "MustacheTag", - "expression": { - "type": "Identifier", - "start": 44, - "end": 49, - "name": "value" - } - } - ] - } - ], - "destructuredContexts": [ - "key", - "value" - ], - "context": "key_value" - } - ] - }, - "css": null, - "js": null -} \ No newline at end of file diff --git a/test/parser/samples/each-block-destructured/output.json b/test/parser/samples/each-block-destructured/output.json index 897fec88b82a..38d5ddc770ec 100644 --- a/test/parser/samples/each-block-destructured/output.json +++ b/test/parser/samples/each-block-destructured/output.json @@ -1,53 +1,53 @@ { - "hash": 2621498076, + "hash": "gtdm5e", "html": { "start": 0, - "end": 70, + "end": 62, "type": "Fragment", "children": [ { "start": 0, - "end": 70, + "end": 62, "type": "EachBlock", "expression": { "type": "Identifier", - "start": 8, - "end": 15, + "start": 7, + "end": 14, "name": "animals" }, "children": [ { - "start": 35, - "end": 60, + "start": 33, + "end": 54, "type": "Element", "name": "p", "attributes": [], "children": [ { - "start": 38, - "end": 45, + "start": 36, + "end": 41, "type": "MustacheTag", "expression": { "type": "Identifier", - "start": 40, - "end": 43, + "start": 37, + "end": 40, "name": "key" } }, { - "start": 45, - "end": 47, + "start": 41, + "end": 43, "type": "Text", "data": ": " }, { - "start": 47, - "end": 56, + "start": 43, + "end": 50, "type": "MustacheTag", "expression": { "type": "Identifier", - "start": 49, - "end": 54, + "start": 44, + "end": 49, "name": "value" } } diff --git a/test/parser/samples/each-block-else/input-v2.html b/test/parser/samples/each-block-else/input-v2.html deleted file mode 100644 index dc96d8b946be..000000000000 --- a/test/parser/samples/each-block-else/input-v2.html +++ /dev/null @@ -1,5 +0,0 @@ -{#each animals as animal} -

{animal}

-{:else} -

no animals

-{/each} diff --git a/test/parser/samples/each-block-else/input.html b/test/parser/samples/each-block-else/input.html index 59925e8db7e1..dc96d8b946be 100644 --- a/test/parser/samples/each-block-else/input.html +++ b/test/parser/samples/each-block-else/input.html @@ -1,5 +1,5 @@ -{{#each animals as animal}} -

{{animal}}

-{{else}} +{#each animals as animal} +

{animal}

+{:else}

no animals

-{{/each}} +{/each} diff --git a/test/parser/samples/each-block-else/output-v2.json b/test/parser/samples/each-block-else/output-v2.json deleted file mode 100644 index 9f8c5da79ba8..000000000000 --- a/test/parser/samples/each-block-else/output-v2.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "hash": "ljl07n", - "html": { - "start": 0, - "end": 77, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 77, - "type": "EachBlock", - "expression": { - "type": "Identifier", - "start": 7, - "end": 14, - "name": "animals" - }, - "children": [ - { - "start": 27, - "end": 42, - "type": "Element", - "name": "p", - "attributes": [], - "children": [ - { - "start": 30, - "end": 38, - "type": "MustacheTag", - "expression": { - "type": "Identifier", - "start": 31, - "end": 37, - "name": "animal" - } - } - ] - } - ], - "context": "animal", - "else": { - "start": 50, - "end": 70, - "type": "ElseBlock", - "children": [ - { - "start": 52, - "end": 69, - "type": "Element", - "name": "p", - "attributes": [], - "children": [ - { - "start": 55, - "end": 65, - "type": "Text", - "data": "no animals" - } - ] - } - ] - } - } - ] - }, - "css": null, - "js": null -} \ No newline at end of file diff --git a/test/parser/samples/each-block-else/output.json b/test/parser/samples/each-block-else/output.json index 0dadad5f650f..9f8c5da79ba8 100644 --- a/test/parser/samples/each-block-else/output.json +++ b/test/parser/samples/each-block-else/output.json @@ -1,36 +1,36 @@ { - "hash": 3238289871, + "hash": "ljl07n", "html": { "start": 0, - "end": 84, + "end": 77, "type": "Fragment", "children": [ { "start": 0, - "end": 84, + "end": 77, "type": "EachBlock", "expression": { "type": "Identifier", - "start": 8, - "end": 15, + "start": 7, + "end": 14, "name": "animals" }, "children": [ { - "start": 29, - "end": 46, + "start": 27, + "end": 42, "type": "Element", "name": "p", "attributes": [], "children": [ { - "start": 32, - "end": 42, + "start": 30, + "end": 38, "type": "MustacheTag", "expression": { "type": "Identifier", - "start": 34, - "end": 40, + "start": 31, + "end": 37, "name": "animal" } } @@ -39,20 +39,20 @@ ], "context": "animal", "else": { - "start": 55, - "end": 75, + "start": 50, + "end": 70, "type": "ElseBlock", "children": [ { - "start": 57, - "end": 74, + "start": 52, + "end": 69, "type": "Element", "name": "p", "attributes": [], "children": [ { - "start": 60, - "end": 70, + "start": 55, + "end": 65, "type": "Text", "data": "no animals" } diff --git a/test/parser/samples/each-block-indexed/input-v2.html b/test/parser/samples/each-block-indexed/input-v2.html deleted file mode 100644 index d5602ec82c06..000000000000 --- a/test/parser/samples/each-block-indexed/input-v2.html +++ /dev/null @@ -1,3 +0,0 @@ -{#each animals as animal, i} -

{i}: {animal}

-{/each} diff --git a/test/parser/samples/each-block-indexed/input.html b/test/parser/samples/each-block-indexed/input.html index 5c1c74da6613..d5602ec82c06 100644 --- a/test/parser/samples/each-block-indexed/input.html +++ b/test/parser/samples/each-block-indexed/input.html @@ -1,3 +1,3 @@ -{{#each animals as animal, i}} -

{{i}}: {{animal}}

-{{/each}} +{#each animals as animal, i} +

{i}: {animal}

+{/each} diff --git a/test/parser/samples/each-block-indexed/output-v2.json b/test/parser/samples/each-block-indexed/output-v2.json deleted file mode 100644 index 9ffa02aaa871..000000000000 --- a/test/parser/samples/each-block-indexed/output-v2.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "hash": "1143n2g", - "html": { - "start": 0, - "end": 58, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 58, - "type": "EachBlock", - "expression": { - "type": "Identifier", - "start": 7, - "end": 14, - "name": "animals" - }, - "children": [ - { - "start": 30, - "end": 50, - "type": "Element", - "name": "p", - "attributes": [], - "children": [ - { - "start": 33, - "end": 36, - "type": "MustacheTag", - "expression": { - "type": "Identifier", - "start": 34, - "end": 35, - "name": "i" - } - }, - { - "start": 36, - "end": 38, - "type": "Text", - "data": ": " - }, - { - "start": 38, - "end": 46, - "type": "MustacheTag", - "expression": { - "type": "Identifier", - "start": 39, - "end": 45, - "name": "animal" - } - } - ] - } - ], - "context": "animal", - "index": "i" - } - ] - }, - "css": null, - "js": null -} \ No newline at end of file diff --git a/test/parser/samples/each-block-indexed/output.json b/test/parser/samples/each-block-indexed/output.json index fc8954d6ad96..9ffa02aaa871 100644 --- a/test/parser/samples/each-block-indexed/output.json +++ b/test/parser/samples/each-block-indexed/output.json @@ -1,53 +1,53 @@ { - "hash": 2841674990, + "hash": "1143n2g", "html": { "start": 0, - "end": 66, + "end": 58, "type": "Fragment", "children": [ { "start": 0, - "end": 66, + "end": 58, "type": "EachBlock", "expression": { "type": "Identifier", - "start": 8, - "end": 15, + "start": 7, + "end": 14, "name": "animals" }, "children": [ { - "start": 32, - "end": 56, + "start": 30, + "end": 50, "type": "Element", "name": "p", "attributes": [], "children": [ { - "start": 35, - "end": 40, + "start": 33, + "end": 36, "type": "MustacheTag", "expression": { "type": "Identifier", - "start": 37, - "end": 38, + "start": 34, + "end": 35, "name": "i" } }, { - "start": 40, - "end": 42, + "start": 36, + "end": 38, "type": "Text", "data": ": " }, { - "start": 42, - "end": 52, + "start": 38, + "end": 46, "type": "MustacheTag", "expression": { "type": "Identifier", - "start": 44, - "end": 50, + "start": 39, + "end": 45, "name": "animal" } } diff --git a/test/parser/samples/each-block-keyed/input-v2.html b/test/parser/samples/each-block-keyed/input-v2.html deleted file mode 100644 index 46348678d448..000000000000 --- a/test/parser/samples/each-block-keyed/input-v2.html +++ /dev/null @@ -1,3 +0,0 @@ -{#each todos as todo (todo.id)} -

{todo}

-{/each} diff --git a/test/parser/samples/each-block-keyed/input.html b/test/parser/samples/each-block-keyed/input.html index 2bc79c9c8b47..46348678d448 100644 --- a/test/parser/samples/each-block-keyed/input.html +++ b/test/parser/samples/each-block-keyed/input.html @@ -1,3 +1,3 @@ -{{#each todos as todo @id}} -

{{todo}}

-{{/each}} +{#each todos as todo (todo.id)} +

{todo}

+{/each} diff --git a/test/parser/samples/each-block-keyed/output-v2.json b/test/parser/samples/each-block-keyed/output-v2.json deleted file mode 100644 index 461992347b74..000000000000 --- a/test/parser/samples/each-block-keyed/output-v2.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "hash": "1x6az5m", - "html": { - "start": 0, - "end": 54, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 54, - "type": "EachBlock", - "expression": { - "type": "Identifier", - "start": 7, - "end": 12, - "name": "todos" - }, - "children": [ - { - "start": 33, - "end": 46, - "type": "Element", - "name": "p", - "attributes": [], - "children": [ - { - "start": 36, - "end": 42, - "type": "MustacheTag", - "expression": { - "type": "Identifier", - "start": 37, - "end": 41, - "name": "todo" - } - } - ] - } - ], - "context": "todo", - "key": "id" - } - ] - }, - "css": null, - "js": null -} \ No newline at end of file diff --git a/test/parser/samples/each-block-keyed/output.json b/test/parser/samples/each-block-keyed/output.json index 1a16afb82b31..461992347b74 100644 --- a/test/parser/samples/each-block-keyed/output.json +++ b/test/parser/samples/each-block-keyed/output.json @@ -1,5 +1,5 @@ { - "hash": 2025411181, + "hash": "1x6az5m", "html": { "start": 0, "end": 54, @@ -11,26 +11,26 @@ "type": "EachBlock", "expression": { "type": "Identifier", - "start": 8, - "end": 13, + "start": 7, + "end": 12, "name": "todos" }, "children": [ { - "start": 29, - "end": 44, + "start": 33, + "end": 46, "type": "Element", "name": "p", "attributes": [], "children": [ { - "start": 32, - "end": 40, + "start": 36, + "end": 42, "type": "MustacheTag", "expression": { "type": "Identifier", - "start": 34, - "end": 38, + "start": 37, + "end": 41, "name": "todo" } } diff --git a/test/parser/samples/each-block/input-v2.html b/test/parser/samples/each-block/input-v2.html deleted file mode 100644 index 83a5e88ddd2a..000000000000 --- a/test/parser/samples/each-block/input-v2.html +++ /dev/null @@ -1,3 +0,0 @@ -{#each animals as animal} -

{animal}

-{/each} diff --git a/test/parser/samples/each-block/input.html b/test/parser/samples/each-block/input.html index 23bfc3c46565..83a5e88ddd2a 100644 --- a/test/parser/samples/each-block/input.html +++ b/test/parser/samples/each-block/input.html @@ -1,3 +1,3 @@ -{{#each animals as animal}} -

{{animal}}

-{{/each}} +{#each animals as animal} +

{animal}

+{/each} diff --git a/test/parser/samples/each-block/output-v2.json b/test/parser/samples/each-block/output-v2.json deleted file mode 100644 index 7df4a20eba77..000000000000 --- a/test/parser/samples/each-block/output-v2.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "hash": "mzeq0s", - "html": { - "start": 0, - "end": 50, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 50, - "type": "EachBlock", - "expression": { - "type": "Identifier", - "start": 7, - "end": 14, - "name": "animals" - }, - "children": [ - { - "start": 27, - "end": 42, - "type": "Element", - "name": "p", - "attributes": [], - "children": [ - { - "start": 30, - "end": 38, - "type": "MustacheTag", - "expression": { - "type": "Identifier", - "start": 31, - "end": 37, - "name": "animal" - } - } - ] - } - ], - "context": "animal" - } - ] - }, - "css": null, - "js": null -} \ No newline at end of file diff --git a/test/parser/samples/each-block/output.json b/test/parser/samples/each-block/output.json index e549faca3953..7df4a20eba77 100644 --- a/test/parser/samples/each-block/output.json +++ b/test/parser/samples/each-block/output.json @@ -1,36 +1,36 @@ { - "hash": 220340986, + "hash": "mzeq0s", "html": { "start": 0, - "end": 56, + "end": 50, "type": "Fragment", "children": [ { "start": 0, - "end": 56, + "end": 50, "type": "EachBlock", "expression": { "type": "Identifier", - "start": 8, - "end": 15, + "start": 7, + "end": 14, "name": "animals" }, "children": [ { - "start": 29, - "end": 46, + "start": 27, + "end": 42, "type": "Element", "name": "p", "attributes": [], "children": [ { - "start": 32, - "end": 42, + "start": 30, + "end": 38, "type": "MustacheTag", "expression": { "type": "Identifier", - "start": 34, - "end": 40, + "start": 31, + "end": 37, "name": "animal" } } diff --git a/test/parser/samples/element-with-mustache/input-v2.html b/test/parser/samples/element-with-mustache/input-v2.html deleted file mode 100644 index 1e9232da02fd..000000000000 --- a/test/parser/samples/element-with-mustache/input-v2.html +++ /dev/null @@ -1 +0,0 @@ -

hello {name}!

diff --git a/test/parser/samples/element-with-mustache/input.html b/test/parser/samples/element-with-mustache/input.html index 6a2a43bf7984..1e9232da02fd 100644 --- a/test/parser/samples/element-with-mustache/input.html +++ b/test/parser/samples/element-with-mustache/input.html @@ -1 +1 @@ -

hello {{name}}!

+

hello {name}!

diff --git a/test/parser/samples/element-with-mustache/output-v2.json b/test/parser/samples/element-with-mustache/output-v2.json deleted file mode 100644 index 76e71dc3278f..000000000000 --- a/test/parser/samples/element-with-mustache/output-v2.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "hash": 1265376132, - "html": { - "start": 0, - "end": 22, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 22, - "type": "Element", - "name": "h1", - "attributes": [], - "children": [ - { - "start": 4, - "end": 10, - "type": "Text", - "data": "hello " - }, - { - "start": 10, - "end": 16, - "type": "MustacheTag", - "expression": { - "type": "Identifier", - "start": 11, - "end": 15, - "name": "name" - } - }, - { - "start": 16, - "end": 17, - "type": "Text", - "data": "!" - } - ] - } - ] - }, - "css": null, - "js": null -} \ No newline at end of file diff --git a/test/parser/samples/element-with-mustache/output.json b/test/parser/samples/element-with-mustache/output.json index fd6799e1922f..76e71dc3278f 100644 --- a/test/parser/samples/element-with-mustache/output.json +++ b/test/parser/samples/element-with-mustache/output.json @@ -2,12 +2,12 @@ "hash": 1265376132, "html": { "start": 0, - "end": 24, + "end": 22, "type": "Fragment", "children": [ { "start": 0, - "end": 24, + "end": 22, "type": "Element", "name": "h1", "attributes": [], @@ -20,18 +20,18 @@ }, { "start": 10, - "end": 18, + "end": 16, "type": "MustacheTag", "expression": { "type": "Identifier", - "start": 12, - "end": 16, + "start": 11, + "end": 15, "name": "name" } }, { - "start": 18, - "end": 19, + "start": 16, + "end": 17, "type": "Text", "data": "!" } diff --git a/test/parser/samples/element-with-text/input-v2.html b/test/parser/samples/element-with-text/input-v2.html deleted file mode 100644 index fcf3199655df..000000000000 --- a/test/parser/samples/element-with-text/input-v2.html +++ /dev/null @@ -1 +0,0 @@ -test \ No newline at end of file diff --git a/test/parser/samples/element-with-text/input.html b/test/parser/samples/element-with-text/input.html index 61dba8bc46f0..fcf3199655df 100644 --- a/test/parser/samples/element-with-text/input.html +++ b/test/parser/samples/element-with-text/input.html @@ -1 +1 @@ -test +test \ No newline at end of file diff --git a/test/parser/samples/element-with-text/output-v2.json b/test/parser/samples/element-with-text/output-v2.json deleted file mode 100644 index 22cae35547ca..000000000000 --- a/test/parser/samples/element-with-text/output-v2.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "hash": 611274658, - "html": { - "start": 0, - "end": 17, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 17, - "type": "Element", - "name": "span", - "attributes": [], - "children": [ - { - "start": 6, - "end": 10, - "type": "Text", - "data": "test" - } - ] - } - ] - }, - "css": null, - "js": null -} \ No newline at end of file diff --git a/test/parser/samples/elements/input-v2.html b/test/parser/samples/elements/input-v2.html deleted file mode 100644 index 937d25b42e2e..000000000000 --- a/test/parser/samples/elements/input-v2.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/test/parser/samples/elements/input.html b/test/parser/samples/elements/input.html index c50eddd41fab..937d25b42e2e 100644 --- a/test/parser/samples/elements/input.html +++ b/test/parser/samples/elements/input.html @@ -1 +1 @@ - + \ No newline at end of file diff --git a/test/parser/samples/elements/output-v2.json b/test/parser/samples/elements/output-v2.json deleted file mode 100644 index 7b4e6bffe12e..000000000000 --- a/test/parser/samples/elements/output-v2.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "hash": 825536165, - "html": { - "start": 0, - "end": 15, - "type": "Fragment", - "children": [ - { - "start": 0, - "end": 15, - "type": "Element", - "name": "!doctype", - "attributes": [ - { - "start": 10, - "end": 14, - "type": "Attribute", - "name": "html", - "value": true - } - ], - "children": [] - } - ] - }, - "css": null, - "js": null -} \ No newline at end of file diff --git a/test/parser/samples/error-binding-disabled/error-v2.json b/test/parser/samples/error-binding-disabled/error-v2.json deleted file mode 100644 index 71953c41766f..000000000000 --- a/test/parser/samples/error-binding-disabled/error-v2.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "code": "binding-disabled", - "message": "Two-way binding is disabled", - "loc": { - "line": 1, - "column": 7 - }, - "pos": 7 -} \ No newline at end of file diff --git a/test/parser/samples/error-binding-disabled/error.json b/test/parser/samples/error-binding-disabled/error.json index 71953c41766f..63f01e705694 100644 --- a/test/parser/samples/error-binding-disabled/error.json +++ b/test/parser/samples/error-binding-disabled/error.json @@ -1,9 +1,10 @@ { "code": "binding-disabled", "message": "Two-way binding is disabled", - "loc": { + "start": { "line": 1, - "column": 7 + "column": 7, + "character": 7 }, "pos": 7 } \ No newline at end of file diff --git a/test/parser/samples/error-binding-disabled/input-v2.html b/test/parser/samples/error-binding-disabled/input-v2.html deleted file mode 100644 index 3af20a9ced1b..000000000000 --- a/test/parser/samples/error-binding-disabled/input-v2.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/test/parser/samples/error-binding-disabled/input.html b/test/parser/samples/error-binding-disabled/input.html index 6a7bf8566cbb..3af20a9ced1b 100644 --- a/test/parser/samples/error-binding-disabled/input.html +++ b/test/parser/samples/error-binding-disabled/input.html @@ -1 +1 @@ - + \ No newline at end of file diff --git a/test/parser/samples/error-binding-mustaches/error-v2.json b/test/parser/samples/error-binding-mustaches/error-v2.json deleted file mode 100644 index 4d239270860f..000000000000 --- a/test/parser/samples/error-binding-mustaches/error-v2.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "code": "invalid-directive-value", - "message": "directive values should not be wrapped — use 'foo', not '{foo}'", - "loc": { - "line": 1, - "column": 19 - }, - "pos": 19 -} \ No newline at end of file diff --git a/test/parser/samples/error-binding-mustaches/error.json b/test/parser/samples/error-binding-mustaches/error.json index 0c4f9e01bd40..b2a5c1c564b1 100644 --- a/test/parser/samples/error-binding-mustaches/error.json +++ b/test/parser/samples/error-binding-mustaches/error.json @@ -1,9 +1,10 @@ { "code": "invalid-directive-value", - "message": "directive values should not be wrapped — use 'foo', not '{{foo}}'", - "loc": { + "message": "directive values should not be wrapped — use 'foo', not '{foo}'", + "start": { "line": 1, - "column": 19 + "column": 19, + "character": 19 }, "pos": 19 } \ No newline at end of file diff --git a/test/parser/samples/error-binding-mustaches/input-v2.html b/test/parser/samples/error-binding-mustaches/input-v2.html deleted file mode 100644 index 2629696c9ec8..000000000000 --- a/test/parser/samples/error-binding-mustaches/input-v2.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/test/parser/samples/error-binding-mustaches/input.html b/test/parser/samples/error-binding-mustaches/input.html index a334ea705578..2629696c9ec8 100644 --- a/test/parser/samples/error-binding-mustaches/input.html +++ b/test/parser/samples/error-binding-mustaches/input.html @@ -1 +1 @@ - + diff --git a/test/parser/samples/error-binding-rvalue/error-v2.json b/test/parser/samples/error-binding-rvalue/error-v2.json deleted file mode 100644 index b774b8a29f3c..000000000000 --- a/test/parser/samples/error-binding-rvalue/error-v2.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "code": "invalid-directive-value", - "message": "Can only bind to an identifier (e.g. `foo`) or a member expression (e.g. `foo.bar` or `foo[baz]`)", - "pos": 19, - "loc": { - "line": 1, - "column": 19 - } -} \ No newline at end of file diff --git a/test/parser/samples/error-binding-rvalue/error.json b/test/parser/samples/error-binding-rvalue/error.json index b774b8a29f3c..2d081afac509 100644 --- a/test/parser/samples/error-binding-rvalue/error.json +++ b/test/parser/samples/error-binding-rvalue/error.json @@ -2,8 +2,9 @@ "code": "invalid-directive-value", "message": "Can only bind to an identifier (e.g. `foo`) or a member expression (e.g. `foo.bar` or `foo[baz]`)", "pos": 19, - "loc": { + "start": { "line": 1, - "column": 19 + "column": 19, + "character": 19 } } \ No newline at end of file diff --git a/test/parser/samples/error-binding-rvalue/input-v2.html b/test/parser/samples/error-binding-rvalue/input-v2.html deleted file mode 100644 index 0b1f716c237e..000000000000 --- a/test/parser/samples/error-binding-rvalue/input-v2.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/test/parser/samples/error-comment-unclosed/error-v2.json b/test/parser/samples/error-comment-unclosed/error-v2.json deleted file mode 100644 index d83ecbdc0961..000000000000 --- a/test/parser/samples/error-comment-unclosed/error-v2.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "code": "unexpected-eof", - "message": "comment was left open, expected -->", - "loc": { - "line": 1, - "column": 24 - }, - "pos": 24 -} diff --git a/test/parser/samples/error-comment-unclosed/error.json b/test/parser/samples/error-comment-unclosed/error.json index d83ecbdc0961..8e355fb8211b 100644 --- a/test/parser/samples/error-comment-unclosed/error.json +++ b/test/parser/samples/error-comment-unclosed/error.json @@ -1,9 +1,10 @@ { "code": "unexpected-eof", "message": "comment was left open, expected -->", - "loc": { + "start": { "line": 1, - "column": 24 + "column": 24, + "character": 24 }, "pos": 24 } diff --git a/test/parser/samples/error-comment-unclosed/input-v2.html b/test/parser/samples/error-comment-unclosed/input-v2.html deleted file mode 100644 index fe6d748e1b04..000000000000 --- a/test/parser/samples/error-comment-unclosed/input-v2.html +++ /dev/null @@ -1 +0,0 @@ -`, test ( assert, component, target, window ) { const inputs = [ ...target.querySelectorAll( 'input' ) ]; - const items = component.get( 'items' ); + const items = component.get().items; const event = new window.Event( 'input' ); assert.equal( inputs[0].value, 'one' ); diff --git a/test/runtime/samples/binding-input-text-contextual/main.html b/test/runtime/samples/binding-input-text-contextual/main.html index 5f07fadc2673..7b3f35244fde 100644 --- a/test/runtime/samples/binding-input-text-contextual/main.html +++ b/test/runtime/samples/binding-input-text-contextual/main.html @@ -1,3 +1,3 @@ -{{#each items as item}} -

{{item}}

-{{/each}} +{#each items as item} +

{item}

+{/each} diff --git a/test/runtime/samples/binding-input-text-deconflicted/main.html b/test/runtime/samples/binding-input-text-deconflicted/main.html index 391a47c3f1b7..9d631bf040f9 100644 --- a/test/runtime/samples/binding-input-text-deconflicted/main.html +++ b/test/runtime/samples/binding-input-text-deconflicted/main.html @@ -1,2 +1,2 @@ -

Hello {{component.name}}!

+

Hello {component.name}!

\ No newline at end of file diff --git a/test/runtime/samples/binding-input-text-deep-computed-dynamic/main.html b/test/runtime/samples/binding-input-text-deep-computed-dynamic/main.html index 3a95b383e490..d3afde0a7a6d 100644 --- a/test/runtime/samples/binding-input-text-deep-computed-dynamic/main.html +++ b/test/runtime/samples/binding-input-text-deep-computed-dynamic/main.html @@ -1,2 +1,2 @@ -
{{JSON.stringify(obj)}}
\ No newline at end of file +
{JSON.stringify(obj)}
\ No newline at end of file diff --git a/test/runtime/samples/binding-input-text-deep-computed/_config.js b/test/runtime/samples/binding-input-text-deep-computed/_config.js index 597395ed5201..33cc605a615e 100644 --- a/test/runtime/samples/binding-input-text-deep-computed/_config.js +++ b/test/runtime/samples/binding-input-text-deep-computed/_config.js @@ -20,7 +20,7 @@ export default { assert.equal( target.innerHTML, `\n

hello bob

` ); - const user = component.get( 'user' ); + const user = component.get().user; user.name = 'carol'; component.set({ user }); diff --git a/test/runtime/samples/binding-input-text-deep-computed/main.html b/test/runtime/samples/binding-input-text-deep-computed/main.html index 281849a4d0f8..55ad4b53faa6 100644 --- a/test/runtime/samples/binding-input-text-deep-computed/main.html +++ b/test/runtime/samples/binding-input-text-deep-computed/main.html @@ -1,2 +1,2 @@ -

hello {{user.name}}

+

hello {user.name}

diff --git a/test/runtime/samples/binding-input-text-deep-contextual-computed-dynamic/main.html b/test/runtime/samples/binding-input-text-deep-contextual-computed-dynamic/main.html index b2f36850f4c5..1af3bee5b69e 100644 --- a/test/runtime/samples/binding-input-text-deep-contextual-computed-dynamic/main.html +++ b/test/runtime/samples/binding-input-text-deep-contextual-computed-dynamic/main.html @@ -1,4 +1,4 @@ -{{#each objects as obj}} +{#each objects as obj} -
{{JSON.stringify(obj)}}
-{{/each}} \ No newline at end of file +
{JSON.stringify(obj)}
+{/each} \ No newline at end of file diff --git a/test/runtime/samples/binding-input-text-deep-contextual/_config.js b/test/runtime/samples/binding-input-text-deep-contextual/_config.js index 587110786c89..8cf72df95649 100644 --- a/test/runtime/samples/binding-input-text-deep-contextual/_config.js +++ b/test/runtime/samples/binding-input-text-deep-contextual/_config.js @@ -19,7 +19,7 @@ export default { assert.equal( target.innerHTML, `

one

four

three

` ); - const items = component.get( 'items' ); + const items = component.get().items; items[2].description = 'five'; component.set({ items }); diff --git a/test/runtime/samples/binding-input-text-deep-contextual/main.html b/test/runtime/samples/binding-input-text-deep-contextual/main.html index 210e4e4fea59..7d21a2ddb233 100644 --- a/test/runtime/samples/binding-input-text-deep-contextual/main.html +++ b/test/runtime/samples/binding-input-text-deep-contextual/main.html @@ -1,3 +1,3 @@ -{{#each items as item}} -

{{item.description}}

-{{/each}} +{#each items as item} +

{item.description}

+{/each} diff --git a/test/runtime/samples/binding-input-text-deep/_config.js b/test/runtime/samples/binding-input-text-deep/_config.js index 9ef090f8648b..f1abe383a6c8 100644 --- a/test/runtime/samples/binding-input-text-deep/_config.js +++ b/test/runtime/samples/binding-input-text-deep/_config.js @@ -19,7 +19,7 @@ export default { assert.equal( target.innerHTML, `\n

hello bob

` ); - const user = component.get( 'user' ); + const user = component.get().user; user.name = 'carol'; component.set({ user }); diff --git a/test/runtime/samples/binding-input-text-deep/main.html b/test/runtime/samples/binding-input-text-deep/main.html index 8ed32a7e903e..f7f7d4dbc014 100644 --- a/test/runtime/samples/binding-input-text-deep/main.html +++ b/test/runtime/samples/binding-input-text-deep/main.html @@ -1,2 +1,2 @@ -

hello {{user.name}}

+

hello {user.name}

diff --git a/test/runtime/samples/binding-input-text/main.html b/test/runtime/samples/binding-input-text/main.html index 806f31fbdd50..143c9054b1c4 100644 --- a/test/runtime/samples/binding-input-text/main.html +++ b/test/runtime/samples/binding-input-text/main.html @@ -1,2 +1,2 @@ -

hello {{name}}

+

hello {name}

diff --git a/test/runtime/samples/binding-input-with-event/_config.js b/test/runtime/samples/binding-input-with-event/_config.js index c09f09439b3e..1b4736e0aa58 100644 --- a/test/runtime/samples/binding-input-with-event/_config.js +++ b/test/runtime/samples/binding-input-with-event/_config.js @@ -13,7 +13,7 @@ export default { input.dispatchEvent( event ); assert.equal( input.value, '43' ); - assert.equal( component.get( 'a' ), 43 ); + assert.equal( component.get().a, 43 ); component.destroy(); } diff --git a/test/runtime/samples/binding-select-implicit-option-value/_config.js b/test/runtime/samples/binding-select-implicit-option-value/_config.js index 40a73647973c..1ab8de20aa7f 100644 --- a/test/runtime/samples/binding-select-implicit-option-value/_config.js +++ b/test/runtime/samples/binding-select-implicit-option-value/_config.js @@ -19,14 +19,14 @@ export default { const options = [...target.querySelectorAll('option')]; assert.ok(options[1].selected); - assert.equal(component.get('foo'), 2); + assert.equal(component.get().foo, 2); const change = new window.Event('change'); options[2].selected = true; select.dispatchEvent(change); - assert.equal(component.get('foo'), 3); + assert.equal(component.get().foo, 3); assert.htmlEqual( target.innerHTML, ` - {{#each values as v}} - - {{/each}} + {#each values as v} + + {/each} -

foo: {{foo}}

\ No newline at end of file +

foo: {foo}

\ No newline at end of file diff --git a/test/runtime/samples/binding-select-in-each-block/_config.js b/test/runtime/samples/binding-select-in-each-block/_config.js index 5a333501bbf1..e95662c740b9 100644 --- a/test/runtime/samples/binding-select-in-each-block/_config.js +++ b/test/runtime/samples/binding-select-in-each-block/_config.js @@ -25,7 +25,7 @@ export default { selects[1].options[0].selected = true; selects[1].dispatchEvent(change); - assert.deepEqual(component.get('items'), [ + assert.deepEqual(component.get().items, [ { value: 'hullo' }, { value: 'hullo' } ]); } diff --git a/test/runtime/samples/binding-select-in-each-block/main.html b/test/runtime/samples/binding-select-in-each-block/main.html index f61ee5b2ca11..68281ebe7a7d 100644 --- a/test/runtime/samples/binding-select-in-each-block/main.html +++ b/test/runtime/samples/binding-select-in-each-block/main.html @@ -1,6 +1,6 @@ -{{#each items as item}} +{#each items as item} -{{/each}} \ No newline at end of file +{/each} \ No newline at end of file diff --git a/test/runtime/samples/binding-select-in-yield/Modal.html b/test/runtime/samples/binding-select-in-yield/Modal.html index 9e580bb57ccc..ceeece2ddd72 100644 --- a/test/runtime/samples/binding-select-in-yield/Modal.html +++ b/test/runtime/samples/binding-select-in-yield/Modal.html @@ -1,6 +1,6 @@ -{{#if !hidden}} +{#if !hidden} -{{/if}} +{/if} \ No newline at end of file diff --git a/test/runtime/samples/bindings-before-oncreate/Two.html b/test/runtime/samples/bindings-before-oncreate/Two.html index f6fc00fcaf7b..a1143a68f161 100644 --- a/test/runtime/samples/bindings-before-oncreate/Two.html +++ b/test/runtime/samples/bindings-before-oncreate/Two.html @@ -7,7 +7,7 @@ }, computed: { - foo(bar) { + foo({ bar }) { return bar * 2; } } diff --git a/test/runtime/samples/bindings-coalesced/Foo.html b/test/runtime/samples/bindings-coalesced/Foo.html index 5d453fbb7315..3b6b796ccb09 100644 --- a/test/runtime/samples/bindings-coalesced/Foo.html +++ b/test/runtime/samples/bindings-coalesced/Foo.html @@ -1,5 +1,5 @@ -

bar in Foo: {{bar}}

-

baz in Foo: {{baz}}

+

bar in Foo: {bar}

+

baz in Foo: {baz}

diff --git a/test/runtime/samples/component-binding-blowback-b/main.html b/test/runtime/samples/component-binding-blowback-b/main.html index 4e3ca438139b..301f5b7da8c7 100644 --- a/test/runtime/samples/component-binding-blowback-b/main.html +++ b/test/runtime/samples/component-binding-blowback-b/main.html @@ -1,11 +1,11 @@
    - {{#each ids as id}} - - {{id}}: value is {{idToValue[id]}} + {#each ids as id} + + {id}: value is {idToValue[id]} - {{/each}} + {/each}
diff --git a/test/runtime/samples/component-binding-blowback-c/main.html b/test/runtime/samples/component-binding-blowback-c/main.html index 3cf809552b16..21d69d3c40c6 100644 --- a/test/runtime/samples/component-binding-blowback-c/main.html +++ b/test/runtime/samples/component-binding-blowback-c/main.html @@ -1,11 +1,11 @@
    - {{#each ids as object @id}} - - {{object.id}}: value is {{idToValue[object.id]}} + {#each ids as object (object.id)} + + {object.id}: value is {idToValue[object.id]} - {{/each}} + {/each}
diff --git a/test/runtime/samples/computed-function/main.html b/test/runtime/samples/computed-function/main.html index f3fc14727d29..a43225216687 100644 --- a/test/runtime/samples/computed-function/main.html +++ b/test/runtime/samples/computed-function/main.html @@ -1,4 +1,4 @@ -

{{scale(x)}}

+

{scale(x)}

\ No newline at end of file diff --git a/test/runtime/samples/computed-values-deconflicted/main.html b/test/runtime/samples/computed-values-deconflicted/main.html index d32fde6167a6..e5a016084cad 100644 --- a/test/runtime/samples/computed-values-deconflicted/main.html +++ b/test/runtime/samples/computed-values-deconflicted/main.html @@ -1,4 +1,4 @@ -{{state}} +{state} \ No newline at end of file diff --git a/test/runtime/samples/computed-values-default/main-v2.html b/test/runtime/samples/computed-values-default/main-v2.html deleted file mode 100644 index b26762f3d826..000000000000 --- a/test/runtime/samples/computed-values-default/main-v2.html +++ /dev/null @@ -1,9 +0,0 @@ -

{foo}

- - diff --git a/test/runtime/samples/computed-values-default/main.html b/test/runtime/samples/computed-values-default/main.html index 74292a3a2e14..b26762f3d826 100644 --- a/test/runtime/samples/computed-values-default/main.html +++ b/test/runtime/samples/computed-values-default/main.html @@ -1,9 +1,9 @@ -

{{foo}}

+

{foo}

diff --git a/test/runtime/samples/computed-values-function-dependency/_config.js b/test/runtime/samples/computed-values-function-dependency/_config.js index 38b716b4d7a2..9320a0aad81d 100644 --- a/test/runtime/samples/computed-values-function-dependency/_config.js +++ b/test/runtime/samples/computed-values-function-dependency/_config.js @@ -3,7 +3,7 @@ export default { test ( assert, component, target ) { component.set({ y: 2 }); - assert.equal( component.get( 'x' ), 4 ); + assert.equal( component.get().x, 4 ); assert.equal( target.innerHTML, '

4

' ); component.destroy(); } diff --git a/test/runtime/samples/computed-values-function-dependency/main-v2.html b/test/runtime/samples/computed-values-function-dependency/main-v2.html deleted file mode 100644 index adf66137fa8a..000000000000 --- a/test/runtime/samples/computed-values-function-dependency/main-v2.html +++ /dev/null @@ -1,28 +0,0 @@ -

{x}

- - \ No newline at end of file diff --git a/test/runtime/samples/computed-values-function-dependency/main.html b/test/runtime/samples/computed-values-function-dependency/main.html index d385bf6da896..adf66137fa8a 100644 --- a/test/runtime/samples/computed-values-function-dependency/main.html +++ b/test/runtime/samples/computed-values-function-dependency/main.html @@ -1,4 +1,4 @@ -

{{x}}

+

{x}

diff --git a/test/runtime/samples/computed-values/main.html b/test/runtime/samples/computed-values/main.html index 0cee54f8671e..7e4f8d772853 100644 --- a/test/runtime/samples/computed-values/main.html +++ b/test/runtime/samples/computed-values/main.html @@ -1,5 +1,5 @@ -

{{a}} + {{b}} = {{c}}

-

{{c}} * {{c}} = {{cSquared}}

+

{a} + {b} = {c}

+

{c} * {c} = {cSquared}

diff --git a/test/runtime/samples/custom-method/_config.js b/test/runtime/samples/custom-method/_config.js index 1586df8a79e9..fb1aa7f46aaf 100644 --- a/test/runtime/samples/custom-method/_config.js +++ b/test/runtime/samples/custom-method/_config.js @@ -5,11 +5,11 @@ export default { const event = new window.MouseEvent( 'click' ); button.dispatchEvent( event ); - assert.equal( component.get( 'counter' ), 1 ); + assert.equal( component.get().counter, 1 ); assert.equal( target.innerHTML, '\n\n

1

' ); button.dispatchEvent( event ); - assert.equal( component.get( 'counter' ), 2 ); + assert.equal( component.get().counter, 2 ); assert.equal( target.innerHTML, '\n\n

2

' ); assert.equal( component.foo(), 42 ); diff --git a/test/runtime/samples/custom-method/main.html b/test/runtime/samples/custom-method/main.html index 06ad01ca7962..0f1ad3387cb8 100644 --- a/test/runtime/samples/custom-method/main.html +++ b/test/runtime/samples/custom-method/main.html @@ -1,6 +1,6 @@ -

{{counter}}

+

{counter}

diff --git a/test/runtime/samples/deconflict-template-1/main.html b/test/runtime/samples/deconflict-template-1/main.html index f4fe8de42389..395d7b22b379 100644 --- a/test/runtime/samples/deconflict-template-1/main.html +++ b/test/runtime/samples/deconflict-template-1/main.html @@ -1,4 +1,4 @@ -{{value}} +{value} \ No newline at end of file diff --git a/test/runtime/samples/dev-warning-custom-event-destroy-not-teardown/_config.js b/test/runtime/samples/dev-warning-custom-event-destroy-not-teardown/_config.js deleted file mode 100644 index 59c583ba1a93..000000000000 --- a/test/runtime/samples/dev-warning-custom-event-destroy-not-teardown/_config.js +++ /dev/null @@ -1,7 +0,0 @@ -export default { - dev: true, - - warnings: [ - `Return 'destroy()' from custom event handlers. Returning 'teardown()' has been deprecated and will be unsupported in Svelte 2` - ] -}; \ No newline at end of file diff --git a/test/runtime/samples/dev-warning-custom-event-destroy-not-teardown/main.html b/test/runtime/samples/dev-warning-custom-event-destroy-not-teardown/main.html deleted file mode 100644 index 1e83835f0324..000000000000 --- a/test/runtime/samples/dev-warning-custom-event-destroy-not-teardown/main.html +++ /dev/null @@ -1,16 +0,0 @@ - - - \ No newline at end of file diff --git a/test/runtime/samples/dev-warning-destroy-not-teardown/_config.js b/test/runtime/samples/dev-warning-destroy-not-teardown/_config.js deleted file mode 100644 index 7e9b391f4ba5..000000000000 --- a/test/runtime/samples/dev-warning-destroy-not-teardown/_config.js +++ /dev/null @@ -1,7 +0,0 @@ -export default { - dev: true, - - warnings: [ - `Use component.on('destroy', ...) instead of component.on('teardown', ...) which has been deprecated and will be unsupported in Svelte 2` - ] -}; \ No newline at end of file diff --git a/test/runtime/samples/dev-warning-destroy-not-teardown/main.html b/test/runtime/samples/dev-warning-destroy-not-teardown/main.html deleted file mode 100644 index 22c2e9c28760..000000000000 --- a/test/runtime/samples/dev-warning-destroy-not-teardown/main.html +++ /dev/null @@ -1,9 +0,0 @@ - \ No newline at end of file diff --git a/test/runtime/samples/dev-warning-dynamic-components-misplaced/main-v2.html b/test/runtime/samples/dev-warning-dynamic-components-misplaced/main-v2.html deleted file mode 100644 index eb6e7d8e8e61..000000000000 --- a/test/runtime/samples/dev-warning-dynamic-components-misplaced/main-v2.html +++ /dev/null @@ -1,13 +0,0 @@ - - - \ No newline at end of file diff --git a/test/runtime/samples/dev-warning-dynamic-components-misplaced/main.html b/test/runtime/samples/dev-warning-dynamic-components-misplaced/main.html index 37392f27e6fd..eb6e7d8e8e61 100644 --- a/test/runtime/samples/dev-warning-dynamic-components-misplaced/main.html +++ b/test/runtime/samples/dev-warning-dynamic-components-misplaced/main.html @@ -1,4 +1,4 @@ -<:Component {x ? Foo : Bar}/> + \ No newline at end of file diff --git a/test/runtime/samples/dev-warning-readonly-window-binding/main-v2.html b/test/runtime/samples/dev-warning-readonly-window-binding/main-v2.html deleted file mode 100644 index 87b0403ee32e..000000000000 --- a/test/runtime/samples/dev-warning-readonly-window-binding/main-v2.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/test/runtime/samples/dev-warning-readonly-window-binding/main.html b/test/runtime/samples/dev-warning-readonly-window-binding/main.html index 635ae75e9c3f..87b0403ee32e 100644 --- a/test/runtime/samples/dev-warning-readonly-window-binding/main.html +++ b/test/runtime/samples/dev-warning-readonly-window-binding/main.html @@ -1 +1 @@ -<:Window bind:innerWidth='width'/> \ No newline at end of file + \ No newline at end of file diff --git a/test/runtime/samples/dynamic-component-bindings-recreated/Green-v2.html b/test/runtime/samples/dynamic-component-bindings-recreated/Green-v2.html deleted file mode 100644 index b4faa1b66263..000000000000 --- a/test/runtime/samples/dynamic-component-bindings-recreated/Green-v2.html +++ /dev/null @@ -1 +0,0 @@ -

green {foo}

\ No newline at end of file diff --git a/test/runtime/samples/dynamic-component-bindings-recreated/Green.html b/test/runtime/samples/dynamic-component-bindings-recreated/Green.html index 692847c1c204..b4faa1b66263 100644 --- a/test/runtime/samples/dynamic-component-bindings-recreated/Green.html +++ b/test/runtime/samples/dynamic-component-bindings-recreated/Green.html @@ -1 +1 @@ -

green {{foo}}

\ No newline at end of file +

green {foo}

\ No newline at end of file diff --git a/test/runtime/samples/dynamic-component-bindings-recreated/Red-v2.html b/test/runtime/samples/dynamic-component-bindings-recreated/Red-v2.html deleted file mode 100644 index a3e3c792a03f..000000000000 --- a/test/runtime/samples/dynamic-component-bindings-recreated/Red-v2.html +++ /dev/null @@ -1 +0,0 @@ -

red {foo}

\ No newline at end of file diff --git a/test/runtime/samples/dynamic-component-bindings-recreated/Red.html b/test/runtime/samples/dynamic-component-bindings-recreated/Red.html index 8f10e3294dbe..a3e3c792a03f 100644 --- a/test/runtime/samples/dynamic-component-bindings-recreated/Red.html +++ b/test/runtime/samples/dynamic-component-bindings-recreated/Red.html @@ -1 +1 @@ -

red {{foo}}

\ No newline at end of file +

red {foo}

\ No newline at end of file diff --git a/test/runtime/samples/dynamic-component-bindings-recreated/main-v2.html b/test/runtime/samples/dynamic-component-bindings-recreated/main-v2.html deleted file mode 100644 index 6d748ed21705..000000000000 --- a/test/runtime/samples/dynamic-component-bindings-recreated/main-v2.html +++ /dev/null @@ -1,15 +0,0 @@ - - - \ No newline at end of file diff --git a/test/runtime/samples/dynamic-component-bindings-recreated/main.html b/test/runtime/samples/dynamic-component-bindings-recreated/main.html index b9cdf9266099..a26c1cd080d6 100644 --- a/test/runtime/samples/dynamic-component-bindings-recreated/main.html +++ b/test/runtime/samples/dynamic-component-bindings-recreated/main.html @@ -1,4 +1,4 @@ -<:Component {x ? Green : Red} bind:foo /> + \ No newline at end of file diff --git a/test/runtime/samples/dynamic-component-bindings/main.html b/test/runtime/samples/dynamic-component-bindings/main.html index cb260da71fe2..020855cb2272 100644 --- a/test/runtime/samples/dynamic-component-bindings/main.html +++ b/test/runtime/samples/dynamic-component-bindings/main.html @@ -1,4 +1,4 @@ -<:Component { x ? Foo : Bar } bind:y bind:z/> + \ No newline at end of file diff --git a/test/runtime/samples/dynamic-component-events/main.html b/test/runtime/samples/dynamic-component-events/main.html index 8606b56ce069..5fa66b2c6135 100644 --- a/test/runtime/samples/dynamic-component-events/main.html +++ b/test/runtime/samples/dynamic-component-events/main.html @@ -1,4 +1,4 @@ -<:Component { x ? Foo : Bar } on:select='set({ selected: event.id })'/> + \ No newline at end of file diff --git a/test/runtime/samples/dynamic-component-inside-element/main.html b/test/runtime/samples/dynamic-component-inside-element/main.html index 2f2eb2658735..0844346301e2 100644 --- a/test/runtime/samples/dynamic-component-inside-element/main.html +++ b/test/runtime/samples/dynamic-component-inside-element/main.html @@ -1,5 +1,5 @@
- <:Component { x ? Foo : Bar } x='{{x}}'/> +
diff --git a/test/runtime/samples/dynamic-component-ref/main.html b/test/runtime/samples/dynamic-component-ref/main.html index ff506517bc9d..1d54b172995d 100644 --- a/test/runtime/samples/dynamic-component-ref/main.html +++ b/test/runtime/samples/dynamic-component-ref/main.html @@ -1,4 +1,4 @@ -<:Component {foo} ref:test/> + \ No newline at end of file diff --git a/test/runtime/samples/dynamic-component-slot/main.html b/test/runtime/samples/dynamic-component-slot/main.html index fd4fad13691b..e8b5c487ad3d 100644 --- a/test/runtime/samples/dynamic-component-slot/main.html +++ b/test/runtime/samples/dynamic-component-slot/main.html @@ -1,26 +1,26 @@ -<:Component { x ? Foo : Bar } x='{{x}}'> +

element

- {{tag}} + {tag} - {{#if foo}} + {#if foo}

foo

- {{elseif bar}} + {:elseif bar}

bar

- {{else}} + {:else}

neither foo nor bar

- {{/if}} + {/if} text - {{#each things as thing}} - {{thing}} - {{/each}} + {#each things as thing} + {thing} + {/each}
what goes up must come down
- +
\ No newline at end of file diff --git a/test/runtime/samples/dynamic-component-update-existing-instance/main.html b/test/runtime/samples/dynamic-component-update-existing-instance/main.html index 127c189cc316..1f8bd35f8cad 100644 --- a/test/runtime/samples/dynamic-component-update-existing-instance/main.html +++ b/test/runtime/samples/dynamic-component-update-existing-instance/main.html @@ -1,4 +1,4 @@ -<:Component { x ? Foo : Bar } x='{{x}}'/> + \ No newline at end of file diff --git a/test/runtime/samples/function-in-expression/_config.js b/test/runtime/samples/function-in-expression/_config.js index 14cfb8f89f55..9b79770eb93f 100644 --- a/test/runtime/samples/function-in-expression/_config.js +++ b/test/runtime/samples/function-in-expression/_config.js @@ -1,6 +1,4 @@ export default { - allowES2015: true, - data: { numbers: [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ] }, diff --git a/test/runtime/samples/function-in-expression/main.html b/test/runtime/samples/function-in-expression/main.html index 2c98a5124d1e..1f038d771b3a 100644 --- a/test/runtime/samples/function-in-expression/main.html +++ b/test/runtime/samples/function-in-expression/main.html @@ -1 +1 @@ -{{ numbers.filter( x => x % 2 ).join( ', ' ) }} \ No newline at end of file +{ numbers.filter( x => x % 2 ).join( ', ' ) } \ No newline at end of file diff --git a/test/runtime/samples/get-state/_config.js b/test/runtime/samples/get-state/_config.js index dd0b72fb16af..3c2dae5a815d 100644 --- a/test/runtime/samples/get-state/_config.js +++ b/test/runtime/samples/get-state/_config.js @@ -1,7 +1,7 @@ export default { test ( assert, component ) { - assert.equal( component.get('a'), 1 ); - assert.equal( component.get('c'), 3 ); + assert.equal( component.get().a, 1 ); + assert.equal( component.get().c, 3 ); assert.deepEqual( component.get(), { a: 1, b: 2, c: 3 }); } }; diff --git a/test/runtime/samples/get-state/main.html b/test/runtime/samples/get-state/main.html index c8492f4db1ef..e67adaf72e60 100644 --- a/test/runtime/samples/get-state/main.html +++ b/test/runtime/samples/get-state/main.html @@ -6,7 +6,7 @@ }), computed: { - c: ( a, b ) => a + b, + c: ({ a, b }) => a + b, } }; diff --git a/test/runtime/samples/globals-accessible-directly/main.html b/test/runtime/samples/globals-accessible-directly/main.html index 349b4b1d3292..77225fa117a5 100644 --- a/test/runtime/samples/globals-accessible-directly/main.html +++ b/test/runtime/samples/globals-accessible-directly/main.html @@ -1 +1 @@ -{{NaN}} +{NaN} diff --git a/test/runtime/samples/globals-not-dereferenced/main.html b/test/runtime/samples/globals-not-dereferenced/main.html index 771042ed0742..ec39251992cb 100644 --- a/test/runtime/samples/globals-not-dereferenced/main.html +++ b/test/runtime/samples/globals-not-dereferenced/main.html @@ -1 +1 @@ -{{Math.min(x, 5)}} +{Math.min(x, 5)} diff --git a/test/runtime/samples/globals-not-overwritten-by-bindings/_config.js b/test/runtime/samples/globals-not-overwritten-by-bindings/_config.js index a10750e1a035..cf15f47d9d3d 100644 --- a/test/runtime/samples/globals-not-overwritten-by-bindings/_config.js +++ b/test/runtime/samples/globals-not-overwritten-by-bindings/_config.js @@ -40,7 +40,7 @@ export default { input.checked = true; input.dispatchEvent(change); - assert.ok(component.get('todos').third.done); + assert.ok(component.get().todos.third.done); assert.htmlEqual(target.innerHTML, `
diff --git a/test/runtime/samples/globals-not-overwritten-by-bindings/main.html b/test/runtime/samples/globals-not-overwritten-by-bindings/main.html index ca6c6ccb3545..a8b873211ca2 100644 --- a/test/runtime/samples/globals-not-overwritten-by-bindings/main.html +++ b/test/runtime/samples/globals-not-overwritten-by-bindings/main.html @@ -1,6 +1,6 @@ -{{#each Object.keys(todos) as key}} -
+{#each Object.keys(todos) as key} +
-{{/each}} \ No newline at end of file +{/each} \ No newline at end of file diff --git a/test/runtime/samples/globals-shadowed-by-data/main.html b/test/runtime/samples/globals-shadowed-by-data/main.html index 73fd9437aff3..7e3b4083313a 100644 --- a/test/runtime/samples/globals-shadowed-by-data/main.html +++ b/test/runtime/samples/globals-shadowed-by-data/main.html @@ -1,4 +1,4 @@ -{{Math.min(x, 5)}} +{Math.min(x, 5)} \ No newline at end of file diff --git a/test/runtime/samples/immutable-mutable/_config.js b/test/runtime/samples/immutable-mutable/_config.js index 5dab0f239b20..d7381a38a247 100644 --- a/test/runtime/samples/immutable-mutable/_config.js +++ b/test/runtime/samples/immutable-mutable/_config.js @@ -4,13 +4,15 @@ export default { test(assert, component, target, window) { var nested = component.refs.nested; - nested.observe('foo', foo => { - nested.set({ count: nested.get('count') + 1 }); + nested.on('state', ({ changed }) => { + if (changed.foo) { + nested.set({ count: nested.get().count + 1 }); + } }); - assert.htmlEqual(target.innerHTML, `

Called 1 times.

`); + assert.htmlEqual(target.innerHTML, `

Called 0 times.

`); - nested.set({ foo: nested.get('foo') }); - assert.htmlEqual(target.innerHTML, `

Called 2 times.

`); + nested.set({ foo: nested.get().foo }); + assert.htmlEqual(target.innerHTML, `

Called 1 times.

`); } }; diff --git a/test/runtime/samples/immutable-nested/Nested.html b/test/runtime/samples/immutable-nested/Nested.html index 05eb9f3fdfe5..1f3d808d638c 100644 --- a/test/runtime/samples/immutable-nested/Nested.html +++ b/test/runtime/samples/immutable-nested/Nested.html @@ -1,4 +1,4 @@ -

Called {{count}} times.

+

Called {count} times.

\ No newline at end of file diff --git a/test/runtime/samples/ondestroy-before-cleanup/main.html b/test/runtime/samples/ondestroy-before-cleanup/main.html index c4b7ac879f0f..cce0356f6a05 100644 --- a/test/runtime/samples/ondestroy-before-cleanup/main.html +++ b/test/runtime/samples/ondestroy-before-cleanup/main.html @@ -1,6 +1,6 @@ -{{#if visible}} +{#if visible} -{{/if}} +{/if} + \ No newline at end of file diff --git a/test/runtime/samples/onrender-chain/List.html b/test/runtime/samples/onrender-chain/List.html index 5bf8f12cd87f..513c62b2e601 100644 --- a/test/runtime/samples/onrender-chain/List.html +++ b/test/runtime/samples/onrender-chain/List.html @@ -1,6 +1,6 @@ -{{#each items as item}} - -{{/each}} +{#each items as item} + +{/each} -
\ No newline at end of file diff --git a/test/runtime/samples/select-bind-array/main.html b/test/runtime/samples/select-bind-array/main.html index 7971c4fe1017..67c1dfdb918e 100644 --- a/test/runtime/samples/select-bind-array/main.html +++ b/test/runtime/samples/select-bind-array/main.html @@ -1,5 +1,5 @@ diff --git a/test/runtime/samples/select-bind-in-array/_config.js b/test/runtime/samples/select-bind-in-array/_config.js index 609fc4592ad9..32b522982b60 100644 --- a/test/runtime/samples/select-bind-in-array/_config.js +++ b/test/runtime/samples/select-bind-in-array/_config.js @@ -8,7 +8,7 @@ export default { }, test ( assert, component, target ) { - const items = component.get('items'); + const items = component.get().items; assert.equal( items[0].id, 'a' ); assert.equal( items[1].id, 'b' ); diff --git a/test/runtime/samples/select-bind-in-array/main.html b/test/runtime/samples/select-bind-in-array/main.html index 1a80b1afa0a6..9a4d1e82cdea 100644 --- a/test/runtime/samples/select-bind-in-array/main.html +++ b/test/runtime/samples/select-bind-in-array/main.html @@ -1,6 +1,6 @@ -{{#each items as item}} +{#each items as item} -{{/each}} +{/each} diff --git a/test/runtime/samples/select-change-handler/_config.js b/test/runtime/samples/select-change-handler/_config.js index 015c8182b41c..8ea4d66e8237 100644 --- a/test/runtime/samples/select-change-handler/_config.js +++ b/test/runtime/samples/select-change-handler/_config.js @@ -14,8 +14,8 @@ export default { select.dispatchEvent( event ); assert.equal( select.value, 'c' ); - assert.equal( component.get( 'lastChangedTo' ), 'c' ); - assert.equal( component.get( 'selected' ), 'c' ); + assert.equal( component.get().lastChangedTo, 'c' ); + assert.equal( component.get().selected, 'c' ); component.destroy(); } diff --git a/test/runtime/samples/select-change-handler/main.html b/test/runtime/samples/select-change-handler/main.html index 48376dfa93fb..13d9bd75afe8 100644 --- a/test/runtime/samples/select-change-handler/main.html +++ b/test/runtime/samples/select-change-handler/main.html @@ -1,7 +1,7 @@ \ No newline at end of file diff --git a/test/runtime/samples/set-in-observe-dedupes-renders/Widget.html b/test/runtime/samples/set-in-observe-dedupes-renders/Widget.html deleted file mode 100644 index 3d414dd2043b..000000000000 --- a/test/runtime/samples/set-in-observe-dedupes-renders/Widget.html +++ /dev/null @@ -1,17 +0,0 @@ -
{{foo.x}}
- - diff --git a/test/runtime/samples/set-in-observe/main.html b/test/runtime/samples/set-in-observe/main.html deleted file mode 100644 index d07607f5fec8..000000000000 --- a/test/runtime/samples/set-in-observe/main.html +++ /dev/null @@ -1,16 +0,0 @@ -

{{foo}}

-

{{bar}}

- - diff --git a/test/runtime/samples/set-in-oncreate/main.html b/test/runtime/samples/set-in-oncreate/main.html index 8e71ec5905bf..77633574f1bd 100644 --- a/test/runtime/samples/set-in-oncreate/main.html +++ b/test/runtime/samples/set-in-oncreate/main.html @@ -1,4 +1,4 @@ -

{{foo}}

+

{foo}

\ No newline at end of file diff --git a/test/runtime/samples/set-in-observe-dedupes-renders/_config.js b/test/runtime/samples/set-in-onstate-dedupes-renders/_config.js similarity index 100% rename from test/runtime/samples/set-in-observe-dedupes-renders/_config.js rename to test/runtime/samples/set-in-onstate-dedupes-renders/_config.js diff --git a/test/runtime/samples/set-in-observe-dedupes-renders/main.html b/test/runtime/samples/set-in-onstate-dedupes-renders/main.html similarity index 58% rename from test/runtime/samples/set-in-observe-dedupes-renders/main.html rename to test/runtime/samples/set-in-onstate-dedupes-renders/main.html index f62940a4732c..6813463ec1b2 100644 --- a/test/runtime/samples/set-in-observe-dedupes-renders/main.html +++ b/test/runtime/samples/set-in-onstate-dedupes-renders/main.html @@ -1,4 +1,4 @@ - + diff --git a/test/runtime/samples/set-mutated-data/main.html b/test/runtime/samples/set-mutated-data/main.html index 24369f73a466..e076ac55f82a 100644 --- a/test/runtime/samples/set-mutated-data/main.html +++ b/test/runtime/samples/set-mutated-data/main.html @@ -1 +1 @@ -{{foo}} \ No newline at end of file +{foo} \ No newline at end of file diff --git a/test/runtime/samples/set-prevents-loop/main.html b/test/runtime/samples/set-prevents-loop/main.html index becfe053feca..685bfeaa14e0 100644 --- a/test/runtime/samples/set-prevents-loop/main.html +++ b/test/runtime/samples/set-prevents-loop/main.html @@ -1,8 +1,8 @@ -{{#if visible}} +{#if visible} -{{else}} +{:else} -{{/if}} +{/if} \ No newline at end of file diff --git a/test/runtime/samples/window-event-custom/main.html b/test/runtime/samples/window-event-custom/main.html index af33d08d975a..515d5bc4caf0 100644 --- a/test/runtime/samples/window-event-custom/main.html +++ b/test/runtime/samples/window-event-custom/main.html @@ -1,6 +1,6 @@ -<:Window on:esc="set({ escaped: true })" /> + -

escaped: {{escaped}}

+

escaped: {escaped}

diff --git a/test/server-side-rendering/samples/component-refs-and-attributes/Widget.html b/test/server-side-rendering/samples/component-refs-and-attributes/Widget.html index f0d335dfc780..c35a27b8e68f 100644 --- a/test/server-side-rendering/samples/component-refs-and-attributes/Widget.html +++ b/test/server-side-rendering/samples/component-refs-and-attributes/Widget.html @@ -1 +1 @@ -

{{foo}}

+

{foo}

diff --git a/test/server-side-rendering/samples/component-refs-and-attributes/main.html b/test/server-side-rendering/samples/component-refs-and-attributes/main.html index b9b82910e3bc..d0e56efa384f 100644 --- a/test/server-side-rendering/samples/component-refs-and-attributes/main.html +++ b/test/server-side-rendering/samples/component-refs-and-attributes/main.html @@ -1,4 +1,4 @@ -
+
diff --git a/test/server-side-rendering/samples/default-data-override/main.html b/test/server-side-rendering/samples/default-data-override/main.html index 36054878558b..1014c2df07e1 100644 --- a/test/server-side-rendering/samples/default-data-override/main.html +++ b/test/server-side-rendering/samples/default-data-override/main.html @@ -1,4 +1,4 @@ -

{{foo}}

+

{foo}

\ No newline at end of file diff --git a/test/validator/samples/component-slot-dynamic/errors.json b/test/validator/samples/component-slot-dynamic/errors.json index e09b1ab91610..959aa87fd2b2 100644 --- a/test/validator/samples/component-slot-dynamic/errors.json +++ b/test/validator/samples/component-slot-dynamic/errors.json @@ -1,13 +1,15 @@ [{ "code": "dynamic-slot-name", "message": " name cannot be dynamic", - "loc": { + "start": { "line": 1, - "column": 6 + "column": 6, + "character": 6 }, "end": { "line": 1, - "column": 20 + "column": 18, + "character": 18 }, "pos": 6 }] \ No newline at end of file diff --git a/test/validator/samples/component-slot-dynamic/input.html b/test/validator/samples/component-slot-dynamic/input.html index 4636cd49732a..74348a49db73 100644 --- a/test/validator/samples/component-slot-dynamic/input.html +++ b/test/validator/samples/component-slot-dynamic/input.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/test/validator/samples/component-slot-each-block/errors.json b/test/validator/samples/component-slot-each-block/errors.json index 0e67b707ab34..97f88e4e602c 100644 --- a/test/validator/samples/component-slot-each-block/errors.json +++ b/test/validator/samples/component-slot-each-block/errors.json @@ -1,13 +1,15 @@ [{ "code": "invalid-slot-placement", "message": " cannot be a child of an each-block", - "loc": { + "start": { "line": 2, - "column": 1 + "column": 1, + "character": 25 }, "end": { "line": 2, - "column": 1 + "column": 1, + "character": 25 }, - "pos": 27 + "pos": 25 }] \ No newline at end of file diff --git a/test/validator/samples/component-slot-each-block/input.html b/test/validator/samples/component-slot-each-block/input.html index 2e4f7cb81245..ddc27a7d0d37 100644 --- a/test/validator/samples/component-slot-each-block/input.html +++ b/test/validator/samples/component-slot-each-block/input.html @@ -1,3 +1,3 @@ -{{#each things as thing}} +{#each things as thing} -{{/each}} \ No newline at end of file +{/each} \ No newline at end of file diff --git a/test/validator/samples/component-slot-named-duplicate.skip/errors.json b/test/validator/samples/component-slot-named-duplicate.skip/errors.json index 535a049c0d93..8e5d995da61a 100644 --- a/test/validator/samples/component-slot-named-duplicate.skip/errors.json +++ b/test/validator/samples/component-slot-named-duplicate.skip/errors.json @@ -1,6 +1,6 @@ [{ "message": "duplicate 'foo' element", - "loc": { + "start": { "line": 2, "column": 6 }, diff --git a/test/validator/samples/component-slotted-each-block/errors.json b/test/validator/samples/component-slotted-each-block/errors.json index 5d0102abf254..3c96ba22aed0 100644 --- a/test/validator/samples/component-slotted-each-block/errors.json +++ b/test/validator/samples/component-slotted-each-block/errors.json @@ -1,13 +1,15 @@ [{ "code": "invalid-slotted-content", "message": "Cannot place slotted elements inside an each-block", - "loc": { + "start": { "line": 3, - "column": 7 + "column": 7, + "character": 41 }, "end": { "line": 3, - "column": 17 + "column": 17, + "character": 51 }, - "pos": 43 + "pos": 41 }] \ No newline at end of file diff --git a/test/validator/samples/component-slotted-each-block/input.html b/test/validator/samples/component-slotted-each-block/input.html index 81166f3e54d6..dca4980f30f9 100644 --- a/test/validator/samples/component-slotted-each-block/input.html +++ b/test/validator/samples/component-slotted-each-block/input.html @@ -1,7 +1,7 @@ - {{#each things as thing}} -
{{thing}}
- {{/each}} + {#each things as thing} +
{thing}
+ {/each}
diff --git a/test/validator/samples/properties-computed-must-be-an-object/errors.json b/test/validator/samples/properties-computed-must-be-an-object/errors.json index 764b911fb62f..b964b6b8bc62 100644 --- a/test/validator/samples/properties-computed-must-be-an-object/errors.json +++ b/test/validator/samples/properties-computed-must-be-an-object/errors.json @@ -1,13 +1,15 @@ [{ "code": "invalid-computed-property", "message": "The 'computed' property must be an object literal", - "loc": { + "start": { "line": 5, - "column": 2 + "column": 2, + "character": 42 }, "end": { "line": 5, - "column": 23 + "column": 23, + "character": 63 }, "pos": 42 }] diff --git a/test/validator/samples/properties-computed-must-be-functions/errors.json b/test/validator/samples/properties-computed-must-be-functions/errors.json index 5db219b2227d..40661ca5f3c1 100644 --- a/test/validator/samples/properties-computed-must-be-functions/errors.json +++ b/test/validator/samples/properties-computed-must-be-functions/errors.json @@ -1,13 +1,15 @@ [{ "code": "invalid-computed-value", "message": "Computed properties can be function expressions or arrow function expressions", - "loc": { + "start": { "line": 6, - "column": 8 + "column": 8, + "character": 62 }, "end": { "line": 6, - "column": 20 + "column": 20, + "character": 74 }, "pos": 62 }] diff --git a/test/validator/samples/properties-computed-must-be-valid-function-names/errors.json b/test/validator/samples/properties-computed-must-be-valid-function-names/errors.json index 7cdc2df451a7..d52061b79d9d 100644 --- a/test/validator/samples/properties-computed-must-be-valid-function-names/errors.json +++ b/test/validator/samples/properties-computed-must-be-valid-function-names/errors.json @@ -1,13 +1,15 @@ [{ "code": "invalid-computed-name", "message": "Computed property name 'with-hyphen' is invalid — must be a valid identifier such as with_hyphen", - "loc": { + "start": { "line": 9, - "column": 3 + "column": 3, + "character": 87 }, "end": { "line": 9, - "column": 28 + "column": 16, + "character": 100 }, "pos": 87 }] diff --git a/test/validator/samples/properties-computed-must-be-valid-function-names/input.html b/test/validator/samples/properties-computed-must-be-valid-function-names/input.html index 1c9173f52320..35e2c598e00c 100644 --- a/test/validator/samples/properties-computed-must-be-valid-function-names/input.html +++ b/test/validator/samples/properties-computed-must-be-valid-function-names/input.html @@ -6,7 +6,7 @@ }; }, computed: { - "with-hyphen": a => a * 2 + "with-hyphen": ({ a }) => a * 2 } }; diff --git a/test/validator/samples/properties-computed-no-destructuring/errors.json b/test/validator/samples/properties-computed-no-destructuring/errors.json deleted file mode 100644 index 7ac9e009d64e..000000000000 --- a/test/validator/samples/properties-computed-no-destructuring/errors.json +++ /dev/null @@ -1,13 +0,0 @@ -[{ - "code": "invalid-computed-arguments", - "message": "Computed properties cannot use destructuring in function parameters", - "loc": { - "line": 6, - "column": 8 - }, - "end": { - "line": 6, - "column": 16 - }, - "pos": 62 -}] diff --git a/test/validator/samples/properties-computed-no-destructuring/input.html b/test/validator/samples/properties-computed-no-destructuring/input.html deleted file mode 100644 index ae88d47b9e01..000000000000 --- a/test/validator/samples/properties-computed-no-destructuring/input.html +++ /dev/null @@ -1,9 +0,0 @@ -
- - diff --git a/test/validator/samples/properties-computed-values-needs-arguments/errors.json b/test/validator/samples/properties-computed-values-needs-arguments/errors.json index 20d33b1fe967..6e91ecf32cf8 100644 --- a/test/validator/samples/properties-computed-values-needs-arguments/errors.json +++ b/test/validator/samples/properties-computed-values-needs-arguments/errors.json @@ -2,12 +2,14 @@ "code": "impure-computed", "message": "A computed value must depend on at least one property", "pos": 49, - "loc": { + "start": { "line": 4, - "column": 8 + "column": 8, + "character": 49 }, "end": { "line": 4, - "column": 16 + "column": 16, + "character": 57 } }] \ No newline at end of file diff --git a/test/validator/samples/properties-data-must-be-function/errors.json b/test/validator/samples/properties-data-must-be-function/errors.json index 68fe8eafb9fd..d59826c49d51 100644 --- a/test/validator/samples/properties-data-must-be-function/errors.json +++ b/test/validator/samples/properties-data-must-be-function/errors.json @@ -1,13 +1,15 @@ [{ "code": "invalid-data-property", "message": "'data' must be a function", - "loc": { + "start": { "line": 5, - "column": 8 + "column": 8, + "character": 48 }, "end": { "line": 7, - "column": 3 + "column": 3, + "character": 64 }, "pos": 48 }] diff --git a/test/validator/samples/properties-duplicated/errors.json b/test/validator/samples/properties-duplicated/errors.json index 3b0acf6a128d..08da6cc99963 100644 --- a/test/validator/samples/properties-duplicated/errors.json +++ b/test/validator/samples/properties-duplicated/errors.json @@ -1,13 +1,15 @@ [{ "code": "duplicate-property", "message": "Duplicate property 'methods'", - "loc": { + "start": { "line": 9, - "column": 2 + "column": 2, + "character": 74 }, "end": { "line": 11, - "column": 3 + "column": 3, + "character": 101 }, "pos": 74 }] diff --git a/test/validator/samples/properties-methods-getters-setters/errors.json b/test/validator/samples/properties-methods-getters-setters/errors.json index 5cde6051e4a4..d86fedc83c01 100644 --- a/test/validator/samples/properties-methods-getters-setters/errors.json +++ b/test/validator/samples/properties-methods-getters-setters/errors.json @@ -1,13 +1,15 @@ [{ "code": "illegal-accessor", "message": "Methods cannot use getters and setters", - "loc": { + "start": { "line": 4, - "column": 3 + "column": 3, + "character": 43 }, "end": { "line": 6, - "column": 4 + "column": 4, + "character": 61 }, "pos": 43 }] diff --git a/test/validator/samples/properties-props-must-be-an-array/errors.json b/test/validator/samples/properties-props-must-be-an-array/errors.json index cd5be4fa4622..a9f30e3e0569 100644 --- a/test/validator/samples/properties-props-must-be-an-array/errors.json +++ b/test/validator/samples/properties-props-must-be-an-array/errors.json @@ -1,13 +1,15 @@ [{ "code": "invalid-props-property", "message": "'props' must be an array expression, if specified", - "loc": { + "start": { "line": 5, - "column": 9 + "column": 9, + "character": 49 }, "end": { "line": 5, - "column": 11 + "column": 11, + "character": 51 }, "pos": 49 }] diff --git a/test/validator/samples/properties-props-must-be-array-of-strings/errors.json b/test/validator/samples/properties-props-must-be-array-of-strings/errors.json index 0f9b38334320..02117119d80e 100644 --- a/test/validator/samples/properties-props-must-be-array-of-strings/errors.json +++ b/test/validator/samples/properties-props-must-be-array-of-strings/errors.json @@ -1,13 +1,15 @@ [{ "code": "invalid-props-property", "message": "'props' must be an array of string literals", - "loc": { + "start": { "line": 5, - "column": 10 + "column": 10, + "character": 50 }, "end": { "line": 5, - "column": 12 + "column": 12, + "character": 52 }, "pos": 50 }] diff --git a/test/validator/samples/properties-unexpected-b/errors.json b/test/validator/samples/properties-unexpected-b/errors.json index 45694450a8e6..aaa2c80cc786 100644 --- a/test/validator/samples/properties-unexpected-b/errors.json +++ b/test/validator/samples/properties-unexpected-b/errors.json @@ -1,13 +1,15 @@ [{ "code": "unexpected-property", "message": "Unexpected property 'doSomething' (did you mean to include it in 'methods'?)", - "loc": { + "start": { "line": 5, - "column": 2 + "column": 2, + "character": 42 }, "end": { "line": 7, - "column": 3 + "column": 3, + "character": 81 }, "pos": 42 }] diff --git a/test/validator/samples/properties-unexpected/errors.json b/test/validator/samples/properties-unexpected/errors.json index 5bc2a4b41626..1ea3517e45d6 100644 --- a/test/validator/samples/properties-unexpected/errors.json +++ b/test/validator/samples/properties-unexpected/errors.json @@ -1,13 +1,15 @@ [{ "code": "unexpected-property", "message": "Unexpected property 'dada' (did you mean 'data'?)", - "loc": { + "start": { "line": 5, - "column": 2 + "column": 2, + "character": 42 }, "end": { "line": 9, - "column": 3 + "column": 3, + "character": 84 }, "pos": 42 }] diff --git a/test/validator/samples/slot-attribute-invalid/errors.json b/test/validator/samples/slot-attribute-invalid/errors.json index 5c56bed158c4..fc01fa979224 100644 --- a/test/validator/samples/slot-attribute-invalid/errors.json +++ b/test/validator/samples/slot-attribute-invalid/errors.json @@ -1,13 +1,15 @@ [{ "code": "invalid-slotted-content", "message": "Element with a slot='...' attribute must be a descendant of a component or custom element", - "loc": { + "start": { "line": 1, - "column": 5 + "column": 5, + "character": 5 }, "end": { "line": 1, - "column": 15 + "column": 15, + "character": 15 }, "pos": 5 }] diff --git a/test/validator/samples/store-invalid-callee/input.html b/test/validator/samples/store-invalid-callee/input.html new file mode 100644 index 000000000000..2184dab2882f --- /dev/null +++ b/test/validator/samples/store-invalid-callee/input.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/validator/samples/store-invalid-callee/warnings.json b/test/validator/samples/store-invalid-callee/warnings.json new file mode 100644 index 000000000000..31e7982c7150 --- /dev/null +++ b/test/validator/samples/store-invalid-callee/warnings.json @@ -0,0 +1,15 @@ +[{ + "code": "invalid-callee", + "message": "'store.set' is an invalid callee (did you mean '$set(...)'?)", + "pos": 18, + "start": { + "line": 1, + "column": 18, + "character": 18 + }, + "end": { + "line": 1, + "column": 43, + "character": 43 + } +}] \ No newline at end of file diff --git a/test/validator/samples/store-unexpected/input.html b/test/validator/samples/store-unexpected/input.html deleted file mode 100644 index 589f28e647e0..000000000000 --- a/test/validator/samples/store-unexpected/input.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/test/validator/samples/store-unexpected/warnings.json b/test/validator/samples/store-unexpected/warnings.json deleted file mode 100644 index 5e0f69f8e624..000000000000 --- a/test/validator/samples/store-unexpected/warnings.json +++ /dev/null @@ -1,13 +0,0 @@ -[{ - "code": "options-missing-store", - "message": "compile with `store: true` in order to call store methods", - "loc": { - "line": 1, - "column": 18 - }, - "end": { - "line": 1, - "column": 29 - }, - "pos": 18 -}] \ No newline at end of file diff --git a/test/validator/samples/svg-child-component-declared-namespace/input.html b/test/validator/samples/svg-child-component-declared-namespace/input.html index c158d7fdf57e..536f47107ed9 100644 --- a/test/validator/samples/svg-child-component-declared-namespace/input.html +++ b/test/validator/samples/svg-child-component-declared-namespace/input.html @@ -1,4 +1,4 @@ - +