Merge pull request #813 from sveltejs/tidy-up

more consistent style for generated code
pull/814/head
Rich Harris 8 years ago committed by GitHub
commit dc48ae6358

@ -210,10 +210,10 @@ export default class Generator {
} }
if (globalWhitelist.has(name)) { if (globalWhitelist.has(name)) {
code.prependRight(node.start, `( '${name}' in state ? state.`); code.prependRight(node.start, `('${name}' in state ? state.`);
code.appendLeft( code.appendLeft(
node.object ? node.object.end : node.end, node.object ? node.object.end : node.end,
` : ${name} )` ` : ${name})`
); );
} else { } else {
code.prependRight(node.start, `state.`); code.prependRight(node.start, `state.`);
@ -337,7 +337,7 @@ export default class Generator {
if (defaultImport) { if (defaultImport) {
statements.push( statements.push(
`${name} = ( ${name} && ${name}.__esModule ) ? ${name}['default'] : ${name};` `${name} = (${name} && ${name}.__esModule) ? ${name}['default'] : ${name};`
); );
} }
}); });
@ -629,8 +629,8 @@ export default class Generator {
// user code gets wrapped in an IIFE // user code gets wrapped in an IIFE
if (js.content.body.length) { if (js.content.body.length) {
const prefix = hasDefaultExport const prefix = hasDefaultExport
? `var ${this.alias('template')} = (function () {` ? `var ${this.alias('template')} = (function() {`
: `(function () {`; : `(function() {`;
this.code this.code
.prependRight(js.content.start, prefix) .prependRight(js.content.start, prefix)
.appendLeft(js.content.end, '}());'); .appendLeft(js.content.end, '}());');

@ -135,7 +135,7 @@ export default class Block {
this.mount(name, parentNode); this.mount(name, parentNode);
if (isToplevel) { if (isToplevel) {
this.builders.unmount.addLine(`@detachNode( ${name} );`); this.builders.unmount.addLine(`@detachNode(${name});`);
} }
} }
@ -180,9 +180,9 @@ export default class Block {
mount(name: string, parentNode: string) { mount(name: string, parentNode: string) {
if (parentNode) { if (parentNode) {
this.builders.mount.addLine(`@appendNode( ${name}, ${parentNode} );`); this.builders.mount.addLine(`@appendNode(${name}, ${parentNode});`);
} else { } else {
this.builders.mount.addLine(`@insertNode( ${name}, #target, anchor );`); this.builders.mount.addLine(`@insertNode(${name}, #target, anchor);`);
} }
} }
@ -225,7 +225,7 @@ export default class Block {
properties.addBlock(`create: @noop,`); properties.addBlock(`create: @noop,`);
} else { } else {
properties.addBlock(deindent` properties.addBlock(deindent`
create: function () { create: function() {
${this.builders.create} ${this.builders.create}
${!this.builders.hydrate.isEmpty() && `this.hydrate();`} ${!this.builders.hydrate.isEmpty() && `this.hydrate();`}
}, },
@ -237,7 +237,7 @@ export default class Block {
properties.addBlock(`claim: @noop,`); properties.addBlock(`claim: @noop,`);
} else { } else {
properties.addBlock(deindent` properties.addBlock(deindent`
claim: function ( nodes ) { claim: function(nodes) {
${this.builders.claim} ${this.builders.claim}
${!this.builders.hydrate.isEmpty() && `this.hydrate();`} ${!this.builders.hydrate.isEmpty() && `this.hydrate();`}
}, },
@ -247,7 +247,7 @@ export default class Block {
if (!this.builders.hydrate.isEmpty()) { if (!this.builders.hydrate.isEmpty()) {
properties.addBlock(deindent` properties.addBlock(deindent`
hydrate: function ( nodes ) { hydrate: function(nodes) {
${this.builders.hydrate} ${this.builders.hydrate}
}, },
`); `);
@ -257,7 +257,7 @@ export default class Block {
properties.addBlock(`mount: @noop,`); properties.addBlock(`mount: @noop,`);
} else { } else {
properties.addBlock(deindent` properties.addBlock(deindent`
mount: function ( #target, anchor ) { mount: function(#target, anchor) {
${this.builders.mount} ${this.builders.mount}
}, },
`); `);
@ -268,7 +268,7 @@ export default class Block {
properties.addBlock(`update: @noop,`); properties.addBlock(`update: @noop,`);
} else { } else {
properties.addBlock(deindent` properties.addBlock(deindent`
update: function ( changed, ${this.params.join(', ')} ) { update: function(changed, ${this.params.join(', ')}) {
${this.builders.update} ${this.builders.update}
}, },
`); `);
@ -278,20 +278,20 @@ export default class Block {
if (this.hasIntroMethod) { if (this.hasIntroMethod) {
if (hasIntros) { if (hasIntros) {
properties.addBlock(deindent` properties.addBlock(deindent`
intro: function ( #target, anchor ) { intro: function(#target, anchor) {
if ( ${introing} ) return; if (${introing}) return;
${introing} = true; ${introing} = true;
${hasOutros && `${outroing} = false;`} ${hasOutros && `${outroing} = false;`}
${this.builders.intro} ${this.builders.intro}
this.mount( #target, anchor ); this.mount(#target, anchor);
}, },
`); `);
} else { } else {
properties.addBlock(deindent` properties.addBlock(deindent`
intro: function ( #target, anchor ) { intro: function(#target, anchor) {
this.mount( #target, anchor ); this.mount(#target, anchor);
}, },
`); `);
} }
@ -300,8 +300,8 @@ export default class Block {
if (this.hasOutroMethod) { if (this.hasOutroMethod) {
if (hasOutros) { if (hasOutros) {
properties.addBlock(deindent` properties.addBlock(deindent`
outro: function ( ${this.alias('outrocallback')} ) { outro: function(${this.alias('outrocallback')}) {
if ( ${outroing} ) return; if (${outroing}) return;
${outroing} = true; ${outroing} = true;
${hasIntros && `${introing} = false;`} ${hasIntros && `${introing} = false;`}
@ -312,7 +312,7 @@ export default class Block {
`); `);
} else { } else {
properties.addBlock(deindent` properties.addBlock(deindent`
outro: function ( outrocallback ) { outro: function(outrocallback) {
outrocallback(); outrocallback();
}, },
`); `);
@ -323,7 +323,7 @@ export default class Block {
properties.addBlock(`unmount: @noop,`); properties.addBlock(`unmount: @noop,`);
} else { } else {
properties.addBlock(deindent` properties.addBlock(deindent`
unmount: function () { unmount: function() {
${this.builders.unmount} ${this.builders.unmount}
}, },
`); `);
@ -333,16 +333,14 @@ export default class Block {
properties.addBlock(`destroy: @noop`); properties.addBlock(`destroy: @noop`);
} else { } else {
properties.addBlock(deindent` properties.addBlock(deindent`
destroy: function () { destroy: function() {
${this.builders.destroy} ${this.builders.destroy}
} }
`); `);
} }
return deindent` return deindent`
function ${this.name} ( ${this.params.join(', ')}, #component${this.key function ${this.name}(${this.params.join(', ')}, #component${this.key ? `, ${localKey}` : ''}) {
? `, ${localKey}`
: ''} ) {
${this.variables.size > 0 && ${this.variables.size > 0 &&
`var ${Array.from(this.variables.keys()) `var ${Array.from(this.variables.keys())
.map(key => { .map(key => {

@ -91,9 +91,9 @@ export default function dom(
const condition = `isInitial || ${deps.map(dep => `changed.${dep}`).join(' || ')}`; const condition = `isInitial || ${deps.map(dep => `changed.${dep}`).join(' || ')}`;
const statement = `if ( @differs( ( state.${key} = @template.computed.${key}( ${deps const statement = `if (@differs((state.${key} = @template.computed.${key}(${deps
.map(dep => `state.${dep}`) .map(dep => `state.${dep}`)
.join(', ')} ) ), oldState.${key} ) ) changed.${key} = true;`; .join(', ')})), oldState.${key})) changed.${key} = true;`;
computationBuilder.addConditional(condition, statement); computationBuilder.addConditional(condition, statement);
}); });
@ -105,8 +105,8 @@ export default function dom(
if (generator.needsEncapsulateHelper) { if (generator.needsEncapsulateHelper) {
builder.addBlock(deindent` builder.addBlock(deindent`
function @encapsulateStyles ( node ) { function @encapsulateStyles(node) {
@setAttribute( node, '${generator.stylesheet.id}', '' ); @setAttribute(node, "${generator.stylesheet.id}", "");
} }
`); `);
} }
@ -118,11 +118,11 @@ export default function dom(
if (styles && generator.options.css !== false && !generator.customElement) { if (styles && generator.options.css !== false && !generator.customElement) {
builder.addBlock(deindent` builder.addBlock(deindent`
function @add_css () { function @add_css() {
var style = @createElement( 'style' ); var style = @createElement("style");
style.id = '${generator.stylesheet.id}-style'; style.id = '${generator.stylesheet.id}-style';
style.textContent = ${styles}; style.textContent = ${styles};
@appendNode( style, document.head ); @appendNode(style, document.head);
} }
`); `);
} }
@ -149,30 +149,28 @@ export default function dom(
const constructorBody = deindent` const constructorBody = deindent`
${options.dev && !generator.customElement && ${options.dev && !generator.customElement &&
`if ( !options || (!options.target && !options._root) ) throw new Error( "'target' is a required option" );`} `if (!options || (!options.target && !options._root)) throw new Error("'target' is a required option");`}
this.options = options; this.options = options;
${generator.usesRefs && `this.refs = {};`} ${generator.usesRefs && `this.refs = {};`}
this._state = ${templateProperties.data this._state = ${templateProperties.data
? `@assign( @template.data(), options.data )` ? `@assign(@template.data(), options.data)`
: `options.data || {}`}; : `options.data || {}`};
${generator.metaBindings} ${generator.metaBindings}
${computations.length && `this._recompute( {}, this._state, {}, true );`} ${computations.length && `this._recompute({}, this._state, {}, true);`}
${options.dev && ${options.dev &&
Array.from(generator.expectedProperties).map( Array.from(generator.expectedProperties).map(
prop => prop =>
`if ( !( '${prop}' in this._state ) ) console.warn( "Component was created without expected data property '${prop}'" );` `if (!('${prop}' in this._state)) console.warn("Component was created without expected data property '${prop}'");`
)} )}
${generator.bindingGroups.length && ${generator.bindingGroups.length &&
`this._bindingGroups = [ ${Array(generator.bindingGroups.length) `this._bindingGroups = [${Array(generator.bindingGroups.length).fill('[]').join(', ')}];`}
.fill('[]')
.join(', ')} ];`}
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
${templateProperties.ondestroy && `this._handlers.destroy = [@template.ondestroy]`} ${templateProperties.ondestroy && `this._handlers.destroy = [@template.ondestroy]`}
this._root = options._root || this; this._root = options._root || this;
@ -186,13 +184,13 @@ export default function dom(
${css && `this.shadowRoot.innerHTML = \`<style>${options.dev ? `${css}\n/*# sourceMappingURL=${cssMap.toUrl()} */` : css}</style>\`;`} ${css && `this.shadowRoot.innerHTML = \`<style>${options.dev ? `${css}\n/*# sourceMappingURL=${cssMap.toUrl()} */` : css}</style>\`;`}
` : ` :
(generator.stylesheet.hasStyles && options.css !== false && (generator.stylesheet.hasStyles && options.css !== false &&
`if ( !document.getElementById( '${generator.stylesheet.id}-style' ) ) @add_css();`) `if (!document.getElementById("${generator.stylesheet.id}-style")) @add_css();`)
} }
${templateProperties.oncreate && `var oncreate = @template.oncreate.bind( this );`} ${templateProperties.oncreate && `var oncreate = @template.oncreate.bind(this);`}
${(templateProperties.oncreate || generator.hasComponents || generator.hasComplexBindings || generator.hasIntroTransitions) && deindent` ${(templateProperties.oncreate || generator.hasComponents || generator.hasComplexBindings || generator.hasIntroTransitions) && deindent`
if ( !options._root ) { if (!options._root) {
this._oncreate = [${templateProperties.oncreate && `oncreate`}]; this._oncreate = [${templateProperties.oncreate && `oncreate`}];
${(generator.hasComponents || generator.hasComplexBindings) && `this._beforecreate = [];`} ${(generator.hasComponents || generator.hasComplexBindings) && `this._beforecreate = [];`}
${(generator.hasComponents || generator.hasIntroTransitions) && `this._aftercreate = [];`} ${(generator.hasComponents || generator.hasIntroTransitions) && `this._aftercreate = [];`}
@ -205,22 +203,22 @@ export default function dom(
${generator.slots.size && `this.slots = {};`} ${generator.slots.size && `this.slots = {};`}
this._fragment = @create_main_fragment( this._state, this ); this._fragment = @create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
${generator.hydratable ${generator.hydratable
? deindent` ? deindent`
var nodes = @children( options.target ); var nodes = @children(options.target);
options.hydrate ? this._fragment.claim( nodes ) : this._fragment.create(); options.hydrate ? this._fragment.claim(nodes) : this._fragment.create();
nodes.forEach( @detachNode ); nodes.forEach(@detachNode);
` : ` :
deindent` deindent`
${options.dev && `if ( options.hydrate ) throw new Error( 'options.hydrate only works if the component was compiled with the \`hydratable: true\` option' );`} ${options.dev && `if (options.hydrate) throw new Error("options.hydrate only works if the component was compiled with the \`hydratable: true\` option");`}
this._fragment.create(); this._fragment.create();
`} `}
${generator.customElement ? ${generator.customElement ?
`this._mount( options.target, options.anchor || null );` : `this._mount(options.target, options.anchor || null);` :
`this._fragment.${block.hasIntroMethod ? 'intro' : 'mount'}( options.target, options.anchor || null );`} `this._fragment.${block.hasIntroMethod ? 'intro' : 'mount'}(options.target, options.anchor || null);`}
${(generator.hasComponents || generator.hasComplexBindings || templateProperties.oncreate || generator.hasIntroTransitions) && deindent` ${(generator.hasComponents || generator.hasComplexBindings || templateProperties.oncreate || generator.hasIntroTransitions) && deindent`
${generator.hasComponents && `this._lock = true;`} ${generator.hasComponents && `this._lock = true;`}
@ -263,13 +261,13 @@ export default function dom(
}); });
}`} }`}
attributeChangedCallback ( attr, oldValue, newValue ) { attributeChangedCallback(attr, oldValue, newValue) {
this.set({ [attr]: newValue }); this.set({ [attr]: newValue });
} }
} }
customElements.define('${generator.tag}', ${name}); customElements.define("${generator.tag}", ${name});
@assign( ${prototypeBase}, ${proto}, { @assign(${prototypeBase}, ${proto}, {
_mount(target, anchor) { _mount(target, anchor) {
this._fragment.${block.hasIntroMethod ? 'intro' : 'mount'}(this.shadowRoot, null); this._fragment.${block.hasIntroMethod ? 'intro' : 'mount'}(this.shadowRoot, null);
target.insertBefore(this, anchor); target.insertBefore(this, anchor);
@ -282,32 +280,32 @@ export default function dom(
`); `);
} else { } else {
builder.addBlock(deindent` builder.addBlock(deindent`
function ${name} ( options ) { function ${name}(options) {
${constructorBody} ${constructorBody}
} }
@assign( ${prototypeBase}, ${proto}); @assign(${prototypeBase}, ${proto});
`); `);
} }
// TODO deprecate component.teardown() // TODO deprecate component.teardown()
builder.addBlock(deindent` builder.addBlock(deindent`
${options.dev && deindent` ${options.dev && deindent`
${name}.prototype._checkReadOnly = function _checkReadOnly ( newState ) { ${name}.prototype._checkReadOnly = function _checkReadOnly(newState) {
${Array.from(generator.readonly).map( ${Array.from(generator.readonly).map(
prop => prop =>
`if ( '${prop}' in newState && !this._updatingReadonlyProperty ) throw new Error( "Cannot set read-only property '${prop}'" );` `if ('${prop}' in newState && !this._updatingReadonlyProperty) throw new Error("Cannot set read-only property '${prop}'");`
)} )}
}; };
`} `}
${computations.length ? deindent` ${computations.length ? deindent`
${name}.prototype._recompute = function _recompute ( changed, state, oldState, isInitial ) { ${name}.prototype._recompute = function _recompute(changed, state, oldState, isInitial) {
${computationBuilder} ${computationBuilder}
} }
` : (!sharedPath && `${name}.prototype._recompute = @noop;`)} ` : (!sharedPath && `${name}.prototype._recompute = @noop;`)}
${templateProperties.setup && `@template.setup( ${name} );`} ${templateProperties.setup && `@template.setup(${name});`}
`); `);
const usedHelpers = new Set(); const usedHelpers = new Set();
@ -340,7 +338,7 @@ export default function dom(
else if (format === 'cjs') { else if (format === 'cjs') {
const SHARED = '__shared'; const SHARED = '__shared';
let requires = `var ${SHARED} = require( ${JSON.stringify(sharedPath)} );`; let requires = `var ${SHARED} = require(${JSON.stringify(sharedPath)});`;
used.forEach(name => { used.forEach(name => {
const alias = generator.alias(name); const alias = generator.alias(name);
requires += `\nvar ${alias} = ${SHARED}.${name};`; requires += `\nvar ${alias} = ${SHARED}.${name};`;
@ -390,9 +388,7 @@ export default function dom(
// special case // special case
const global = `_svelteTransitionManager`; const global = `_svelteTransitionManager`;
result += `\n\nvar ${generator.alias( result += `\n\nvar ${generator.alias('transitionManager')} = window.${global} || (window.${global} = ${code});`;
'transitionManager'
)} = window.${global} || ( window.${global} = ${code});`;
} else { } else {
const alias = generator.alias(expression.id.name); const alias = generator.alias(expression.id.name);
if (alias !== expression.id.name) if (alias !== expression.id.name)

@ -5,6 +5,7 @@ import { DomGenerator } from '../index';
import Block from '../Block'; import Block from '../Block';
import getTailSnippet from '../../../utils/getTailSnippet'; import getTailSnippet from '../../../utils/getTailSnippet';
import getObject from '../../../utils/getObject'; import getObject from '../../../utils/getObject';
import getExpressionPrecedence from '../../../utils/getExpressionPrecedence';
import { stringify } from '../../../utils/stringify'; import { stringify } from '../../../utils/stringify';
import { Node } from '../../../interfaces'; import { Node } from '../../../interfaces';
import { State } from '../interfaces'; import { State } from '../interfaces';
@ -90,9 +91,9 @@ export default function visitComponent(
.forEach((attribute: Attribute) => { .forEach((attribute: Attribute) => {
if (attribute.dependencies.length) { if (attribute.dependencies.length) {
updates.push(deindent` updates.push(deindent`
if ( ${attribute.dependencies if (${attribute.dependencies
.map(dependency => `changed.${dependency}`) .map(dependency => `changed.${dependency}`)
.join(' || ')} ) ${name}_changes.${attribute.name} = ${attribute.value}; .join(' || ')}) ${name}_changes.${attribute.name} = ${attribute.value};
`); `);
} }
@ -152,7 +153,7 @@ export default function visitComponent(
} }
statements.push(deindent` statements.push(deindent`
if ( ${binding.prop} in ${binding.obj} ) { if (${binding.prop} in ${binding.obj}) {
${name_initial_data}.${binding.name} = ${binding.snippet}; ${name_initial_data}.${binding.name} = ${binding.snippet};
${name_updating}.${binding.name} = true; ${name_updating}.${binding.name} = true;
}` }`
@ -171,7 +172,7 @@ export default function visitComponent(
// TODO could binding.dependencies.length ever be 0? // TODO could binding.dependencies.length ever be 0?
if (binding.dependencies.length) { if (binding.dependencies.length) {
updates.push(deindent` updates.push(deindent`
if ( !${name_updating}.${binding.name} && ${binding.dependencies.map((dependency: string) => `changed.${dependency}`).join(' || ')} ) { if (!${name_updating}.${binding.name} && ${binding.dependencies.map((dependency: string) => `changed.${dependency}`).join(' || ')}) {
${name}_changes.${binding.name} = ${binding.snippet}; ${name}_changes.${binding.name} = ${binding.snippet};
${name_updating}.${binding.name} = true; ${name_updating}.${binding.name} = true;
} }
@ -234,12 +235,12 @@ export default function visitComponent(
); );
block.builders.mount.addLine( block.builders.mount.addLine(
`${name}._mount( ${state.parentNode || '#target'}, ${state.parentNode ? 'null' : 'anchor'} );` `${name}._mount(${state.parentNode || '#target'}, ${state.parentNode ? 'null' : 'anchor'});`
); );
if (!state.parentNode) block.builders.unmount.addLine(`${name}._unmount();`); if (!state.parentNode) block.builders.unmount.addLine(`${name}._unmount();`);
block.builders.destroy.addLine(`${name}.destroy( false );`); block.builders.destroy.addLine(`${name}.destroy(false);`);
// event handlers // event handlers
node.attributes.filter((a: Node) => a.type === 'EventHandler').forEach((handler: Node) => { node.attributes.filter((a: Node) => a.type === 'EventHandler').forEach((handler: Node) => {
@ -279,7 +280,7 @@ export default function visitComponent(
`${block.alias('component')}.fire('${handler.name}', event);`); `${block.alias('component')}.fire('${handler.name}', event);`);
block.builders.init.addBlock(deindent` block.builders.init.addBlock(deindent`
${name}.on( '${handler.name}', function ( event ) { ${name}.on("${handler.name}", function(event) {
${handlerBody} ${handlerBody}
}); });
`); `);
@ -292,7 +293,7 @@ export default function visitComponent(
block.builders.init.addLine(`#component.refs.${ref.name} = ${name};`); block.builders.init.addLine(`#component.refs.${ref.name} = ${name};`);
block.builders.destroy.addLine(deindent` block.builders.destroy.addLine(deindent`
if ( #component.refs.${ref.name} === ${name} ) #component.refs.${ref.name} = null; if (#component.refs.${ref.name} === ${name}) #component.refs.${ref.name} = null;
`); `);
}); });
@ -392,7 +393,7 @@ function mungeAttribute(attribute: Node, block: Block): Attribute {
allDependencies.add(dependency); allDependencies.add(dependency);
}); });
return `( ${snippet} )`; // TODO only parenthesize if necessary return getExpressionPrecedence(chunk.expression) <= 13 ? `( ${snippet} )` : snippet;
} }
}) })
.join(' + '); .join(' + ');

@ -73,16 +73,15 @@ export default function visitEachBlock(
// TODO neaten this up... will end up with an empty line in the block // TODO neaten this up... will end up with an empty line in the block
block.builders.init.addBlock(deindent` block.builders.init.addBlock(deindent`
if ( !${each_block_value}.${length} ) { if (!${each_block_value}.${length}) {
${each_block_else} = ${node.else._block.name}( ${params}, #component ); ${each_block_else} = ${node.else._block.name}(${params}, #component);
${each_block_else}.create(); ${each_block_else}.create();
} }
`); `);
block.builders.mount.addBlock(deindent` block.builders.mount.addBlock(deindent`
if ( ${each_block_else} ) { if (${each_block_else}) {
${each_block_else}.${mountOrIntro}( ${state.parentNode || ${each_block_else}.${mountOrIntro}(${state.parentNode || '#target'}, null);
'#target'}, null );
} }
`); `);
@ -90,13 +89,13 @@ export default function visitEachBlock(
if (node.else._block.hasUpdateMethod) { if (node.else._block.hasUpdateMethod) {
block.builders.update.addBlock(deindent` block.builders.update.addBlock(deindent`
if ( !${each_block_value}.${length} && ${each_block_else} ) { if (!${each_block_value}.${length} && ${each_block_else}) {
${each_block_else}.update( changed, ${params} ); ${each_block_else}.update( changed, ${params} );
} else if ( !${each_block_value}.${length} ) { } else if (!${each_block_value}.${length}) {
${each_block_else} = ${node.else._block.name}( ${params}, #component ); ${each_block_else} = ${node.else._block.name}(${params}, #component);
${each_block_else}.create(); ${each_block_else}.create();
${each_block_else}.${mountOrIntro}( ${parentNode}, ${anchor} ); ${each_block_else}.${mountOrIntro}(${parentNode}, ${anchor});
} else if ( ${each_block_else} ) { } else if (${each_block_else}) {
${each_block_else}.unmount(); ${each_block_else}.unmount();
${each_block_else}.destroy(); ${each_block_else}.destroy();
${each_block_else} = null; ${each_block_else} = null;
@ -104,26 +103,26 @@ export default function visitEachBlock(
`); `);
} else { } else {
block.builders.update.addBlock(deindent` block.builders.update.addBlock(deindent`
if ( ${each_block_value}.${length} ) { if (${each_block_value}.${length}) {
if ( ${each_block_else} ) { if (${each_block_else}) {
${each_block_else}.unmount(); ${each_block_else}.unmount();
${each_block_else}.destroy(); ${each_block_else}.destroy();
${each_block_else} = null; ${each_block_else} = null;
} }
} else if ( !${each_block_else} ) { } else if (!${each_block_else}) {
${each_block_else} = ${node.else._block.name}( ${params}, #component ); ${each_block_else} = ${node.else._block.name}(${params}, #component);
${each_block_else}.create(); ${each_block_else}.create();
${each_block_else}.${mountOrIntro}( ${parentNode}, ${anchor} ); ${each_block_else}.${mountOrIntro}(${parentNode}, ${anchor});
} }
`); `);
} }
block.builders.unmount.addLine( block.builders.unmount.addLine(
`if ( ${each_block_else} ) ${each_block_else}.unmount()` `if (${each_block_else}) ${each_block_else}.unmount()`
); );
block.builders.destroy.addBlock(deindent` block.builders.destroy.addBlock(deindent`
if ( ${each_block_else} ) ${each_block_else}.destroy( false ); if (${each_block_else}) ${each_block_else}.destroy(false);
`); `);
} }
@ -161,7 +160,7 @@ function keyed(
const last = block.getUniqueName(`${each_block}_last`); const last = block.getUniqueName(`${each_block}_last`);
const expected = block.getUniqueName(`${each_block}_expected`); const expected = block.getUniqueName(`${each_block}_expected`);
block.addVariable(lookup, `Object.create( null )`); block.addVariable(lookup, `Object.create(null)`);
block.addVariable(head); block.addVariable(head);
block.addVariable(last); block.addVariable(last);
@ -179,15 +178,15 @@ function keyed(
} }
block.builders.init.addBlock(deindent` block.builders.init.addBlock(deindent`
for ( var #i = 0; #i < ${each_block_value}.${length}; #i += 1 ) { for (var #i = 0; #i < ${each_block_value}.${length}; #i += 1) {
var ${key} = ${each_block_value}[#i].${node.key}; var ${key} = ${each_block_value}[#i].${node.key};
var ${iteration} = ${lookup}[${key}] = ${create_each_block}( ${params}, ${each_block_value}, ${each_block_value}[#i], #i, #component, ${key} ); var ${iteration} = ${lookup}[${key}] = ${create_each_block}(${params}, ${each_block_value}, ${each_block_value}[#i], #i, #component, ${key});
if ( ${last} ) ${last}.next = ${iteration}; if (${last}) ${last}.next = ${iteration};
${iteration}.last = ${last}; ${iteration}.last = ${last};
${last} = ${iteration}; ${last} = ${iteration};
if ( #i === 0 ) ${head} = ${iteration}; if (#i === 0) ${head} = ${iteration};
} }
`); `);
@ -196,7 +195,7 @@ function keyed(
block.builders.create.addBlock(deindent` block.builders.create.addBlock(deindent`
var ${iteration} = ${head}; var ${iteration} = ${head};
while ( ${iteration} ) { while (${iteration}) {
${iteration}.create(); ${iteration}.create();
${iteration} = ${iteration}.next; ${iteration} = ${iteration}.next;
} }
@ -204,16 +203,16 @@ function keyed(
block.builders.claim.addBlock(deindent` block.builders.claim.addBlock(deindent`
var ${iteration} = ${head}; var ${iteration} = ${head};
while ( ${iteration} ) { while (${iteration}) {
${iteration}.claim( ${state.parentNodes} ); ${iteration}.claim(${state.parentNodes});
${iteration} = ${iteration}.next; ${iteration} = ${iteration}.next;
} }
`); `);
block.builders.mount.addBlock(deindent` block.builders.mount.addBlock(deindent`
var ${iteration} = ${head}; var ${iteration} = ${head};
while ( ${iteration} ) { while (${iteration}) {
${iteration}.${mountOrIntro}( ${targetNode}, ${anchorNode} ); ${iteration}.${mountOrIntro}(${targetNode}, ${anchorNode});
${iteration} = ${iteration}.next; ${iteration} = ${iteration}.next;
} }
`); `);
@ -225,8 +224,8 @@ function keyed(
if (node._block.hasOutroMethod) { if (node._block.hasOutroMethod) {
const fn = block.getUniqueName(`${each_block}_outro`); const fn = block.getUniqueName(`${each_block}_outro`);
block.builders.init.addBlock(deindent` block.builders.init.addBlock(deindent`
function ${fn} ( iteration ) { function ${fn}(iteration) {
iteration.outro( function () { iteration.outro(function() {
iteration.unmount(); iteration.unmount();
iteration.destroy(); iteration.destroy();
${lookup}[iteration.key] = null; ${lookup}[iteration.key] = null;
@ -235,21 +234,21 @@ function keyed(
`); `);
destroy = deindent` destroy = deindent`
while ( ${expected} ) { while (${expected}) {
${fn}( ${expected} ); ${fn}(${expected});
${expected} = ${expected}.next; ${expected} = ${expected}.next;
} }
for ( #i = 0; #i < discard_pile.length; #i += 1 ) { for (#i = 0; #i < discard_pile.length; #i += 1) {
if ( discard_pile[#i].discard ) { if (discard_pile[#i].discard) {
${fn}( discard_pile[#i] ); ${fn}(discard_pile[#i]);
} }
} }
`; `;
} else { } else {
const fn = block.getUniqueName(`${each_block}_destroy`); const fn = block.getUniqueName(`${each_block}_destroy`);
block.builders.init.addBlock(deindent` block.builders.init.addBlock(deindent`
function ${fn} ( iteration ) { function ${fn}(iteration) {
iteration.unmount(); iteration.unmount();
iteration.destroy(); iteration.destroy();
${lookup}[iteration.key] = null; ${lookup}[iteration.key] = null;
@ -257,15 +256,15 @@ function keyed(
`); `);
destroy = deindent` destroy = deindent`
while ( ${expected} ) { while (${expected}) {
${fn}( ${expected} ); ${fn}(${expected});
${expected} = ${expected}.next; ${expected} = ${expected}.next;
} }
for ( #i = 0; #i < discard_pile.length; #i += 1 ) { for (#i = 0; #i < discard_pile.length; #i += 1) {
var ${iteration} = discard_pile[#i]; var ${iteration} = discard_pile[#i];
if ( ${iteration}.discard ) { if (${iteration}.discard) {
${fn}( ${iteration} ); ${fn}(${iteration});
} }
} }
`; `;
@ -279,22 +278,22 @@ function keyed(
var discard_pile = []; var discard_pile = [];
for ( #i = 0; #i < ${each_block_value}.${length}; #i += 1 ) { for (#i = 0; #i < ${each_block_value}.${length}; #i += 1) {
var ${key} = ${each_block_value}[#i].${node.key}; var ${key} = ${each_block_value}[#i].${node.key};
var ${iteration} = ${lookup}[${key}]; var ${iteration} = ${lookup}[${key}];
${dynamic && ${dynamic &&
`if ( ${iteration} ) ${iteration}.update( changed, ${params}, ${each_block_value}, ${each_block_value}[#i], #i );`} `if (${iteration}) ${iteration}.update(changed, ${params}, ${each_block_value}, ${each_block_value}[#i], #i);`}
if ( ${expected} ) { if (${expected}) {
if ( ${key} === ${expected}.key ) { if (${key} === ${expected}.key) {
${expected} = ${expected}.next; ${expected} = ${expected}.next;
} else { } else {
if ( ${iteration} ) { if (${iteration}) {
// probably a deletion // probably a deletion
while ( ${expected} && ${expected}.key !== ${key} ) { while (${expected} && ${expected}.key !== ${key}) {
${expected}.discard = true; ${expected}.discard = true;
discard_pile.push( ${expected} ); discard_pile.push(${expected});
${expected} = ${expected}.next; ${expected} = ${expected}.next;
}; };
@ -302,12 +301,12 @@ function keyed(
${iteration}.discard = false; ${iteration}.discard = false;
${iteration}.last = ${last}; ${iteration}.last = ${last};
if (!${expected}) ${iteration}.mount( ${parentNode}, ${anchor} ); if (!${expected}) ${iteration}.mount(${parentNode}, ${anchor});
} else { } else {
// key is being inserted // key is being inserted
${iteration} = ${lookup}[${key}] = ${create_each_block}( ${params}, ${each_block_value}, ${each_block_value}[#i], #i, #component, ${key} ); ${iteration} = ${lookup}[${key}] = ${create_each_block}(${params}, ${each_block_value}, ${each_block_value}[#i], #i, #component, ${key});
${iteration}.create(); ${iteration}.create();
${iteration}.${mountOrIntro}( ${parentNode}, ${expected}.first ); ${iteration}.${mountOrIntro}(${parentNode}, ${expected}.first);
${expected}.last = ${iteration}; ${expected}.last = ${iteration};
${iteration}.next = ${expected}; ${iteration}.next = ${expected};
@ -315,25 +314,24 @@ function keyed(
} }
} else { } else {
// we're appending from this point forward // we're appending from this point forward
if ( ${iteration} ) { if (${iteration}) {
${iteration}.discard = false; ${iteration}.discard = false;
${iteration}.next = null; ${iteration}.next = null;
${iteration}.mount( ${parentNode}, ${anchor} ); ${iteration}.mount(${parentNode}, ${anchor});
} else { } else {
${iteration} = ${lookup}[${key}] = ${create_each_block}( ${params}, ${each_block_value}, ${each_block_value}[#i], #i, #component, ${key} ); ${iteration} = ${lookup}[${key}] = ${create_each_block}(${params}, ${each_block_value}, ${each_block_value}[#i], #i, #component, ${key});
${iteration}.create(); ${iteration}.create();
${iteration}.${mountOrIntro}( ${parentNode}, ${anchor} ); ${iteration}.${mountOrIntro}(${parentNode}, ${anchor});
} }
} }
if ( ${last} ) ${last}.next = ${iteration}; if (${last}) ${last}.next = ${iteration};
${iteration}.last = ${last}; ${iteration}.last = ${last};
${node._block.hasIntroMethod && ${node._block.hasIntroMethod && `${iteration}.intro(${parentNode}, ${anchor});`}
`${iteration}.intro( ${parentNode}, ${anchor} );`}
${last} = ${iteration}; ${last} = ${iteration};
} }
if ( ${last} ) ${last}.next = null; if (${last}) ${last}.next = null;
${destroy} ${destroy}
@ -343,7 +341,7 @@ function keyed(
if (!state.parentNode) { if (!state.parentNode) {
block.builders.unmount.addBlock(deindent` block.builders.unmount.addBlock(deindent`
var ${iteration} = ${head}; var ${iteration} = ${head};
while ( ${iteration} ) { while (${iteration}) {
${iteration}.unmount(); ${iteration}.unmount();
${iteration} = ${iteration}.next; ${iteration} = ${iteration}.next;
} }
@ -352,8 +350,8 @@ function keyed(
block.builders.destroy.addBlock(deindent` block.builders.destroy.addBlock(deindent`
var ${iteration} = ${head}; var ${iteration} = ${head};
while ( ${iteration} ) { while (${iteration}) {
${iteration}.destroy( false ); ${iteration}.destroy(false);
${iteration} = ${iteration}.next; ${iteration} = ${iteration}.next;
} }
`); `);
@ -378,8 +376,8 @@ function unkeyed(
block.builders.init.addBlock(deindent` block.builders.init.addBlock(deindent`
var ${iterations} = []; var ${iterations} = [];
for ( var #i = 0; #i < ${each_block_value}.${length}; #i += 1 ) { for (var #i = 0; #i < ${each_block_value}.${length}; #i += 1) {
${iterations}[#i] = ${create_each_block}( ${params}, ${each_block_value}, ${each_block_value}[#i], #i, #component ); ${iterations}[#i] = ${create_each_block}(${params}, ${each_block_value}, ${each_block_value}[#i], #i, #component);
} }
`); `);
@ -387,20 +385,20 @@ function unkeyed(
const anchorNode = state.parentNode ? 'null' : 'anchor'; const anchorNode = state.parentNode ? 'null' : 'anchor';
block.builders.create.addBlock(deindent` block.builders.create.addBlock(deindent`
for ( var #i = 0; #i < ${iterations}.length; #i += 1 ) { for (var #i = 0; #i < ${iterations}.length; #i += 1) {
${iterations}[#i].create(); ${iterations}[#i].create();
} }
`); `);
block.builders.claim.addBlock(deindent` block.builders.claim.addBlock(deindent`
for ( var #i = 0; #i < ${iterations}.length; #i += 1 ) { for (var #i = 0; #i < ${iterations}.length; #i += 1) {
${iterations}[#i].claim( ${state.parentNodes} ); ${iterations}[#i].claim(${state.parentNodes});
} }
`); `);
block.builders.mount.addBlock(deindent` block.builders.mount.addBlock(deindent`
for ( var #i = 0; #i < ${iterations}.length; #i += 1 ) { for (var #i = 0; #i < ${iterations}.length; #i += 1) {
${iterations}[#i].${mountOrIntro}( ${targetNode}, ${anchorNode} ); ${iterations}[#i].${mountOrIntro}(${targetNode}, ${anchorNode});
} }
`); `);
@ -421,27 +419,27 @@ function unkeyed(
const forLoopBody = node._block.hasUpdateMethod const forLoopBody = node._block.hasUpdateMethod
? node._block.hasIntroMethod ? node._block.hasIntroMethod
? deindent` ? deindent`
if ( ${iterations}[#i] ) { if (${iterations}[#i]) {
${iterations}[#i].update( changed, ${params}, ${each_block_value}, ${each_block_value}[#i], #i ); ${iterations}[#i].update(changed, ${params}, ${each_block_value}, ${each_block_value}[#i], #i);
} else { } else {
${iterations}[#i] = ${create_each_block}( ${params}, ${each_block_value}, ${each_block_value}[#i], #i, #component ); ${iterations}[#i] = ${create_each_block}(${params}, ${each_block_value}, ${each_block_value}[#i], #i, #component);
${iterations}[#i].create(); ${iterations}[#i].create();
} }
${iterations}[#i].intro( ${parentNode}, ${anchor} ); ${iterations}[#i].intro(${parentNode}, ${anchor});
` `
: deindent` : deindent`
if ( ${iterations}[#i] ) { if (${iterations}[#i]) {
${iterations}[#i].update( changed, ${params}, ${each_block_value}, ${each_block_value}[#i], #i ); ${iterations}[#i].update(changed, ${params}, ${each_block_value}, ${each_block_value}[#i], #i);
} else { } else {
${iterations}[#i] = ${create_each_block}( ${params}, ${each_block_value}, ${each_block_value}[#i], #i, #component ); ${iterations}[#i] = ${create_each_block}(${params}, ${each_block_value}, ${each_block_value}[#i], #i, #component);
${iterations}[#i].create(); ${iterations}[#i].create();
${iterations}[#i].mount( ${parentNode}, ${anchor} ); ${iterations}[#i].mount(${parentNode}, ${anchor});
} }
` `
: deindent` : deindent`
${iterations}[#i] = ${create_each_block}( ${params}, ${each_block_value}, ${each_block_value}[#i], #i, #component ); ${iterations}[#i] = ${create_each_block}(${params}, ${each_block_value}, ${each_block_value}[#i], #i, #component);
${iterations}[#i].create(); ${iterations}[#i].create();
${iterations}[#i].${mountOrIntro}( ${parentNode}, ${anchor} ); ${iterations}[#i].${mountOrIntro}(${parentNode}, ${anchor});
`; `;
const start = node._block.hasUpdateMethod ? '0' : `${iterations}.length`; const start = node._block.hasUpdateMethod ? '0' : `${iterations}.length`;
@ -449,9 +447,9 @@ function unkeyed(
const outro = block.getUniqueName('outro'); const outro = block.getUniqueName('outro');
const destroy = node._block.hasOutroMethod const destroy = node._block.hasOutroMethod
? deindent` ? deindent`
function ${outro} ( i ) { function ${outro}(i) {
if ( ${iterations}[i] ) { if (${iterations}[i]) {
${iterations}[i].outro( function () { ${iterations}[i].outro(function() {
${iterations}[i].unmount(); ${iterations}[i].unmount();
${iterations}[i].destroy(); ${iterations}[i].destroy();
${iterations}[i] = null; ${iterations}[i] = null;
@ -459,10 +457,10 @@ function unkeyed(
} }
} }
for ( ; #i < ${iterations}.length; #i += 1 ) ${outro}( #i ); for (; #i < ${iterations}.length; #i += 1) ${outro}(#i);
` `
: deindent` : deindent`
for ( ; #i < ${iterations}.length; #i += 1 ) { for (; #i < ${iterations}.length; #i += 1) {
${iterations}[#i].unmount(); ${iterations}[#i].unmount();
${iterations}[#i].destroy(); ${iterations}[#i].destroy();
} }
@ -472,8 +470,8 @@ function unkeyed(
block.builders.update.addBlock(deindent` block.builders.update.addBlock(deindent`
var ${each_block_value} = ${snippet}; var ${each_block_value} = ${snippet};
if ( ${condition} ) { if (${condition}) {
for ( var #i = ${start}; #i < ${each_block_value}.${length}; #i += 1 ) { for (var #i = ${start}; #i < ${each_block_value}.${length}; #i += 1) {
${forLoopBody} ${forLoopBody}
} }
@ -483,10 +481,10 @@ function unkeyed(
} }
block.builders.unmount.addBlock(deindent` block.builders.unmount.addBlock(deindent`
for ( var #i = 0; #i < ${iterations}.length; #i += 1 ) { for (var #i = 0; #i < ${iterations}.length; #i += 1) {
${iterations}[#i].unmount(); ${iterations}[#i].unmount();
} }
`); `);
block.builders.destroy.addBlock(`@destroyEach( ${iterations}, false, 0 );`); block.builders.destroy.addBlock(`@destroyEach(${iterations}, false, 0);`);
} }

@ -2,6 +2,7 @@ import attributeLookup from './lookup';
import deindent from '../../../../utils/deindent'; import deindent from '../../../../utils/deindent';
import visitStyleAttribute, { optimizeStyle } from './StyleAttribute'; import visitStyleAttribute, { optimizeStyle } from './StyleAttribute';
import { stringify } from '../../../../utils/stringify'; import { stringify } from '../../../../utils/stringify';
import getExpressionPrecedence from '../../../../utils/getExpressionPrecedence';
import getStaticAttributeValue from '../../../shared/getStaticAttributeValue'; import getStaticAttributeValue from '../../../shared/getStaticAttributeValue';
import { DomGenerator } from '../../index'; import { DomGenerator } from '../../index';
import Block from '../../Block'; import Block from '../../Block';
@ -99,7 +100,7 @@ export default function visitAttribute(
allDependencies.add(d); allDependencies.add(d);
}); });
return `( ${snippet} )`; return getExpressionPrecedence(chunk.expression) <= 13 ? `(${snippet})` : snippet;
} }
}) })
.join(' + '); .join(' + ');
@ -121,9 +122,9 @@ export default function visitAttribute(
if (isLegacyInputType) { if (isLegacyInputType) {
block.builders.hydrate.addLine( block.builders.hydrate.addLine(
`@setInputType( ${state.parentNode}, ${init} );` `@setInputType(${state.parentNode}, ${init});`
); );
updater = `@setInputType( ${state.parentNode}, ${shouldCache ? last : value} );`; updater = `@setInputType(${state.parentNode}, ${shouldCache ? last : value});`;
} else if (isSelectValueAttribute) { } else if (isSelectValueAttribute) {
// annoying special case // annoying special case
const isMultipleSelect = const isMultipleSelect =
@ -136,15 +137,15 @@ export default function visitAttribute(
const ifStatement = isMultipleSelect const ifStatement = isMultipleSelect
? deindent` ? deindent`
${option}.selected = ~${last}.indexOf( ${option}.__value );` ${option}.selected = ~${last}.indexOf(${option}.__value);`
: deindent` : deindent`
if ( ${option}.__value === ${last} ) { if (${option}.__value === ${last}) {
${option}.selected = true; ${option}.selected = true;
break; break;
}`; }`;
updater = deindent` updater = deindent`
for ( var ${i} = 0; ${i} < ${state.parentNode}.options.length; ${i} += 1 ) { for (var ${i} = 0; ${i} < ${state.parentNode}.options.length; ${i} += 1) {
var ${option} = ${state.parentNode}.options[${i}]; var ${option} = ${state.parentNode}.options[${i}];
${ifStatement} ${ifStatement}
@ -164,9 +165,9 @@ export default function visitAttribute(
updater = `${state.parentNode}.${propertyName} = ${shouldCache || isSelectValueAttribute ? last : value};`; updater = `${state.parentNode}.${propertyName} = ${shouldCache || isSelectValueAttribute ? last : value};`;
} else { } else {
block.builders.hydrate.addLine( block.builders.hydrate.addLine(
`${method}( ${state.parentNode}, '${name}', ${init} );` `${method}(${state.parentNode}, "${name}", ${init});`
); );
updater = `${method}( ${state.parentNode}, '${name}', ${shouldCache || isSelectValueAttribute ? last : value} );`; updater = `${method}(${state.parentNode}, "${name}", ${shouldCache || isSelectValueAttribute ? last : value});`;
} }
if (allDependencies.size || hasChangeableIndex || isSelectValueAttribute) { if (allDependencies.size || hasChangeableIndex || isSelectValueAttribute) {
@ -176,10 +177,10 @@ export default function visitAttribute(
dependencies.map(dependency => `changed.${dependency}`).join(' || ') dependencies.map(dependency => `changed.${dependency}`).join(' || ')
); );
const updateCachedValue = `${last} !== ( ${last} = ${value} )`; const updateCachedValue = `${last} !== (${last} = ${value})`;
const condition = shouldCache ? const condition = shouldCache ?
( dependencies.length ? `( ${changedCheck} ) && ${updateCachedValue}` : updateCachedValue ) : ( dependencies.length ? `(${changedCheck}) && ${updateCachedValue}` : updateCachedValue ) :
changedCheck; changedCheck;
block.builders.update.addConditional( block.builders.update.addConditional(
@ -195,9 +196,9 @@ export default function visitAttribute(
: stringify(attribute.value[0].data); : stringify(attribute.value[0].data);
const statement = ( const statement = (
isLegacyInputType ? `@setInputType( ${state.parentNode}, ${value} );` : isLegacyInputType ? `@setInputType(${state.parentNode}, ${value});` :
propertyName ? `${state.parentNode}.${propertyName} = ${value};` : propertyName ? `${state.parentNode}.${propertyName} = ${value};` :
`${method}( ${state.parentNode}, '${name}', ${value} );` `${method}(${state.parentNode}, "${name}", ${value});`
); );
block.builders.hydrate.addLine(statement); block.builders.hydrate.addLine(statement);

@ -67,9 +67,9 @@ export default function visitBinding(
const ifStatement = isMultipleSelect const ifStatement = isMultipleSelect
? deindent` ? deindent`
${option}.selected = ~${value}.indexOf( ${option}.__value );` ${option}.selected = ~${value}.indexOf(${option}.__value);`
: deindent` : deindent`
if ( ${option}.__value === ${value} ) { if (${option}.__value === ${value}) {
${option}.selected = true; ${option}.selected = true;
break; break;
}`; }`;
@ -79,7 +79,7 @@ export default function visitBinding(
updateElement = deindent` updateElement = deindent`
var ${value} = ${snippet}; var ${value} = ${snippet};
for ( var #i = 0; #i < ${state.parentNode}.options.length; #i += 1 ) { for (var #i = 0; #i < ${state.parentNode}.options.length; #i += 1) {
var ${option} = ${state.parentNode}.options[#i]; var ${option} = ${state.parentNode}.options[#i];
${ifStatement} ${ifStatement}
@ -88,44 +88,44 @@ export default function visitBinding(
generator.hasComplexBindings = true; generator.hasComplexBindings = true;
block.builders.hydrate.addBlock( block.builders.hydrate.addBlock(
`if ( !('${name}' in state) ) #component._root._beforecreate.push( ${handler} );` `if (!('${name}' in state)) #component._root._beforecreate.push(${handler});`
); );
} else if (attribute.name === 'group') { } else if (attribute.name === 'group') {
// <input type='checkbox|radio' bind:group='selected'> special case // <input type='checkbox|radio' bind:group='selected'> special case
if (type === 'radio') { if (type === 'radio') {
setter = deindent` setter = deindent`
if ( !${state.parentNode}.checked ) return; if (!${state.parentNode}.checked) return;
${setter} ${setter}
`; `;
} }
const condition = type === 'checkbox' const condition = type === 'checkbox'
? `~${snippet}.indexOf( ${state.parentNode}.__value )` ? `~${snippet}.indexOf(${state.parentNode}.__value)`
: `${state.parentNode}.__value === ${snippet}`; : `${state.parentNode}.__value === ${snippet}`;
block.builders.hydrate.addLine( block.builders.hydrate.addLine(
`#component._bindingGroups[${bindingGroup}].push( ${state.parentNode} );` `#component._bindingGroups[${bindingGroup}].push(${state.parentNode});`
); );
block.builders.destroy.addBlock( block.builders.destroy.addBlock(
`#component._bindingGroups[${bindingGroup}].splice( #component._bindingGroups[${bindingGroup}].indexOf( ${state.parentNode} ), 1 );` `#component._bindingGroups[${bindingGroup}].splice(#component._bindingGroups[${bindingGroup}].indexOf(${state.parentNode}), 1);`
); );
updateElement = `${state.parentNode}.checked = ${condition};`; updateElement = `${state.parentNode}.checked = ${condition};`;
} else if (node.name === 'audio' || node.name === 'video') { } else if (node.name === 'audio' || node.name === 'video') {
generator.hasComplexBindings = true; generator.hasComplexBindings = true;
block.builders.hydrate.addBlock(`#component._root._beforecreate.push( ${handler} );`); block.builders.hydrate.addBlock(`#component._root._beforecreate.push(${handler});`);
if (attribute.name === 'currentTime') { if (attribute.name === 'currentTime') {
const frame = block.getUniqueName(`${state.parentNode}_animationframe`); const frame = block.getUniqueName(`${state.parentNode}_animationframe`);
block.addVariable(frame); block.addVariable(frame);
setter = deindent` setter = deindent`
cancelAnimationFrame( ${frame} ); cancelAnimationFrame(${frame});
if ( !${state.parentNode}.paused ) ${frame} = requestAnimationFrame( ${handler} ); if (!${state.parentNode}.paused) ${frame} = requestAnimationFrame(${handler});
${setter} ${setter}
`; `;
updateCondition += ` && !isNaN( ${snippet} )`; updateCondition += ` && !isNaN(${snippet})`;
} else if (attribute.name === 'duration') { } else if (attribute.name === 'duration') {
updateCondition = null; updateCondition = null;
} else if (attribute.name === 'paused') { } else if (attribute.name === 'paused') {
@ -133,13 +133,13 @@ export default function visitBinding(
const last = block.getUniqueName(`${state.parentNode}_paused_value`); const last = block.getUniqueName(`${state.parentNode}_paused_value`);
block.addVariable(last, 'true'); block.addVariable(last, 'true');
updateCondition = `${last} !== ( ${last} = ${snippet} )`; updateCondition = `${last} !== (${last} = ${snippet})`;
updateElement = `${state.parentNode}[ ${last} ? 'pause' : 'play' ]();`; updateElement = `${state.parentNode}[${last} ? "pause" : "play"]();`;
} }
} }
block.builders.init.addBlock(deindent` block.builders.init.addBlock(deindent`
function ${handler} () { function ${handler}() {
${lock} = true; ${lock} = true;
${setter} ${setter}
${lock} = false; ${lock} = false;
@ -149,21 +149,21 @@ export default function visitBinding(
if (node.name === 'input' && type === 'range') { if (node.name === 'input' && type === 'range') {
// need to bind to `input` and `change`, for the benefit of IE // need to bind to `input` and `change`, for the benefit of IE
block.builders.hydrate.addBlock(deindent` block.builders.hydrate.addBlock(deindent`
@addListener( ${state.parentNode}, 'input', ${handler} ); @addListener(${state.parentNode}, "input", ${handler});
@addListener( ${state.parentNode}, 'change', ${handler} ); @addListener(${state.parentNode}, "change", ${handler});
`); `);
block.builders.destroy.addBlock(deindent` block.builders.destroy.addBlock(deindent`
@removeListener( ${state.parentNode}, 'input', ${handler} ); @removeListener(${state.parentNode}, "input", ${handler});
@removeListener( ${state.parentNode}, 'change', ${handler} ); @removeListener(${state.parentNode}, "change", ${handler});
`); `);
} else { } else {
block.builders.hydrate.addLine( block.builders.hydrate.addLine(
`@addListener( ${state.parentNode}, '${eventName}', ${handler} );` `@addListener(${state.parentNode}, "${eventName}", ${handler});`
); );
block.builders.destroy.addLine( block.builders.destroy.addLine(
`@removeListener( ${state.parentNode}, '${eventName}', ${handler} );` `@removeListener(${state.parentNode}, "${eventName}", ${handler});`
); );
} }
@ -175,7 +175,7 @@ export default function visitBinding(
if (updateCondition !== null) { if (updateCondition !== null) {
// audio/video duration is read-only, it never updates // audio/video duration is read-only, it never updates
block.builders.update.addBlock(deindent` block.builders.update.addBlock(deindent`
if ( ${updateCondition} ) { if (${updateCondition}) {
${updateElement} ${updateElement}
} }
`); `);
@ -183,10 +183,10 @@ export default function visitBinding(
if (attribute.name === 'paused') { if (attribute.name === 'paused') {
block.builders.create.addLine( block.builders.create.addLine(
`@addListener( ${state.parentNode}, 'play', ${handler} );` `@addListener(${state.parentNode}, "play", ${handler});`
); );
block.builders.destroy.addLine( block.builders.destroy.addLine(
`@removeListener( ${state.parentNode}, 'play', ${handler} );` `@removeListener(${state.parentNode}, "play", ${handler});`
); );
} }
} }
@ -221,7 +221,7 @@ function getBindingValue(
) { ) {
// <select multiple bind:value='selected> // <select multiple bind:value='selected>
if (isMultipleSelect) { if (isMultipleSelect) {
return `[].map.call( ${state.parentNode}.querySelectorAll(':checked'), function ( option ) { return option.__value; })`; return `[].map.call(${state.parentNode}.querySelectorAll(':checked'), function(option) { return option.__value; })`;
} }
// <select bind:value='selected> // <select bind:value='selected>
@ -232,7 +232,7 @@ function getBindingValue(
// <input type='checkbox' bind:group='foo'> // <input type='checkbox' bind:group='foo'>
if (attribute.name === 'group') { if (attribute.name === 'group') {
if (type === 'checkbox') { if (type === 'checkbox') {
return `@getBindingGroupValue( #component._bindingGroups[${bindingGroup}] )`; return `@getBindingGroupValue(#component._bindingGroups[${bindingGroup}])`;
} }
return `${state.parentNode}.__value`; return `${state.parentNode}.__value`;
@ -240,7 +240,7 @@ function getBindingValue(
// <input type='range|number' bind:value> // <input type='range|number' bind:value>
if (type === 'range' || type === 'number') { if (type === 'range' || type === 'number') {
return `@toNumber( ${state.parentNode}.${attribute.name} )`; return `@toNumber(${state.parentNode}.${attribute.name})`;
} }
// everything else // everything else
@ -286,12 +286,8 @@ function getSetter(
list[index]${tail} = ${value}; list[index]${tail} = ${value};
${computed ${computed
? `#component.set({ ${dependencies ? `#component.set({${dependencies.map((prop: string) => `${prop}: state.${prop}`).join(', ')} });`
.map((prop: string) => `${prop}: state.${prop}`) : `#component.set({${dependencies.map((prop: string) => `${prop}: #component.get('${prop}')`).join(', ')} });`}
.join(', ')} });`
: `#component.set({ ${dependencies
.map((prop: string) => `${prop}: #component.get( '${prop}' )`)
.join(', ')} });`}
`; `;
} }
@ -299,9 +295,7 @@ function getSetter(
return deindent` return deindent`
var state = #component.get(); var state = #component.get();
${snippet} = ${value}; ${snippet} = ${value};
#component.set({ ${dependencies #component.set({ ${dependencies.map((prop: string) => `${prop}: state.${prop}`).join(', ')} });
.map((prop: string) => `${prop}: state.${prop}`)
.join(', ')} });
`; `;
} }

@ -71,14 +71,14 @@ export default function visitEventHandler(
${declarations} ${declarations}
${attribute.expression ? ${attribute.expression ?
`[✂${attribute.expression.start}-${attribute.expression.end}✂];` : `[✂${attribute.expression.start}-${attribute.expression.end}✂];` :
`${block.alias('component')}.fire('${attribute.name}', event);`} `${block.alias('component')}.fire("${attribute.name}", event);`}
`; `;
if (isCustomEvent) { if (isCustomEvent) {
block.addVariable(handlerName); block.addVariable(handlerName);
block.builders.hydrate.addBlock(deindent` block.builders.hydrate.addBlock(deindent`
${handlerName} = @template.events.${name}.call( #component, ${state.parentNode}, function ( event ) { ${handlerName} = @template.events.${name}.call(#component, ${state.parentNode}, function(event) {
${handlerBody} ${handlerBody}
}); });
`); `);
@ -88,7 +88,7 @@ export default function visitEventHandler(
`); `);
} else { } else {
const handler = deindent` const handler = deindent`
function ${handlerName} ( event ) { function ${handlerName}(event) {
${handlerBody} ${handlerBody}
} }
`; `;
@ -100,11 +100,11 @@ export default function visitEventHandler(
} }
block.builders.hydrate.addLine( block.builders.hydrate.addLine(
`@addListener( ${state.parentNode}, '${name}', ${handlerName} );` `@addListener(${state.parentNode}, "${name}", ${handlerName});`
); );
block.builders.destroy.addLine( block.builders.destroy.addLine(
`@removeListener( ${state.parentNode}, '${name}', ${handlerName} );` `@removeListener(${state.parentNode}, "${name}", ${handlerName});`
); );
} }
} }

@ -18,7 +18,7 @@ export default function visitRef(
); );
block.builders.destroy.addLine(deindent` block.builders.destroy.addLine(deindent`
if ( #component.refs.${name} === ${state.parentNode} ) #component.refs.${name} = null; if (#component.refs.${name} === ${state.parentNode}) #component.refs.${name} = null;
`); `);
generator.usesRefs = true; // so this component.refs object is created generator.usesRefs = true; // so this component.refs object is created

@ -60,7 +60,7 @@ export default function visitStyleAttribute(
block.builders.update.addConditional( block.builders.update.addConditional(
condition, condition,
`@setStyle(${node.var}, '${prop.key}', ${value});` `@setStyle(${node.var}, "${prop.key}", ${value});`
); );
} }
} else { } else {
@ -68,7 +68,7 @@ export default function visitStyleAttribute(
} }
block.builders.hydrate.addLine( block.builders.hydrate.addLine(
`@setStyle(${node.var}, '${prop.key}', ${value});` `@setStyle(${node.var}, "${prop.key}", ${value});`
); );
}); });
} }

@ -23,18 +23,18 @@ export default function addTransitions(
const fn = `@template.transitions.${intro.name}`; const fn = `@template.transitions.${intro.name}`;
block.builders.intro.addBlock(deindent` block.builders.intro.addBlock(deindent`
#component._root._aftercreate.push( function () { #component._root._aftercreate.push(function() {
if ( !${name} ) ${name} = @wrapTransition( #component, ${node.var}, ${fn}, ${snippet}, true, null ); if (!${name}) ${name} = @wrapTransition(#component, ${node.var}, ${fn}, ${snippet}, true, null);
${name}.run( true, function () { ${name}.run(true, function() {
#component.fire( 'intro.end', { node: ${node.var} }); #component.fire("intro.end", { node: ${node.var} });
}); });
}); });
`); `);
block.builders.outro.addBlock(deindent` block.builders.outro.addBlock(deindent`
${name}.run( false, function () { ${name}.run(false, function() {
#component.fire( 'outro.end', { node: ${node.var} }); #component.fire("outro.end", { node: ${node.var} });
if ( --#outros === 0 ) #outrocallback(); if (--#outros === 0) #outrocallback();
${name} = null; ${name} = null;
}); });
`); `);
@ -52,16 +52,16 @@ export default function addTransitions(
if (outro) { if (outro) {
block.builders.intro.addBlock(deindent` block.builders.intro.addBlock(deindent`
if ( ${introName} ) ${introName}.abort(); if (${introName}) ${introName}.abort();
if ( ${outroName} ) ${outroName}.abort(); if (${outroName}) ${outroName}.abort();
`); `);
} }
block.builders.intro.addBlock(deindent` block.builders.intro.addBlock(deindent`
#component._root._aftercreate.push( function () { #component._root._aftercreate.push(function() {
${introName} = @wrapTransition( #component, ${node.var}, ${fn}, ${snippet}, true, null ); ${introName} = @wrapTransition(#component, ${node.var}, ${fn}, ${snippet}, true, null);
${introName}.run( true, function () { ${introName}.run(true, function() {
#component.fire( 'intro.end', { node: ${node.var} }); #component.fire("intro.end", { node: ${node.var} });
}); });
}); });
`); `);
@ -78,10 +78,10 @@ export default function addTransitions(
// TODO hide elements that have outro'd (unless they belong to a still-outroing // TODO hide elements that have outro'd (unless they belong to a still-outroing
// group) prior to their removal from the DOM // group) prior to their removal from the DOM
block.builders.outro.addBlock(deindent` block.builders.outro.addBlock(deindent`
${outroName} = @wrapTransition( #component, ${node.var}, ${fn}, ${snippet}, false, null ); ${outroName} = @wrapTransition(#component, ${node.var}, ${fn}, ${snippet}, false, null);
${outroName}.run( false, function () { ${outroName}.run(false, function() {
#component.fire( 'outro.end', { node: ${node.var} }); #component.fire("outro.end", { node: ${node.var} });
if ( --#outros === 0 ) #outrocallback(); if (--#outros === 0) #outrocallback();
}); });
`); `);
} }

@ -58,14 +58,14 @@ export default function visitWindow(
`; `;
block.builders.init.addBlock(deindent` block.builders.init.addBlock(deindent`
function ${handlerName} ( event ) { function ${handlerName}(event) {
${handlerBody} ${handlerBody}
}; };
window.addEventListener( '${attribute.name}', ${handlerName} ); window.addEventListener("${attribute.name}", ${handlerName});
`); `);
block.builders.destroy.addBlock(deindent` block.builders.destroy.addBlock(deindent`
window.removeEventListener( '${attribute.name}', ${handlerName} ); window.removeEventListener("${attribute.name}", ${handlerName});
`); `);
} }
@ -122,14 +122,14 @@ export default function visitWindow(
`; `;
block.builders.init.addBlock(deindent` block.builders.init.addBlock(deindent`
function ${handlerName} ( event ) { function ${handlerName}(event) {
${handlerBody} ${handlerBody}
}; };
window.addEventListener( '${event}', ${handlerName} ); window.addEventListener("${event}", ${handlerName});
`); `);
block.builders.destroy.addBlock(deindent` block.builders.destroy.addBlock(deindent`
window.removeEventListener( '${event}', ${handlerName} ); window.removeEventListener("${event}", ${handlerName});
`); `);
}); });
@ -138,34 +138,33 @@ export default function visitWindow(
const observerCallback = block.getUniqueName(`scrollobserver`); const observerCallback = block.getUniqueName(`scrollobserver`);
block.builders.init.addBlock(deindent` block.builders.init.addBlock(deindent`
function ${observerCallback} () { function ${observerCallback}() {
if ( ${lock} ) return; if (${lock}) return;
var x = ${bindings.scrollX var x = ${bindings.scrollX
? `#component.get( '${bindings.scrollX}' )` ? `#component.get("${bindings.scrollX}")`
: `window.scrollX`}; : `window.scrollX`};
var y = ${bindings.scrollY var y = ${bindings.scrollY
? `#component.get( '${bindings.scrollY}' )` ? `#component.get("${bindings.scrollY}")`
: `window.scrollY`}; : `window.scrollY`};
window.scrollTo( x, y ); window.scrollTo(x, y);
}; };
`); `);
if (bindings.scrollX) if (bindings.scrollX)
block.builders.init.addLine( block.builders.init.addLine(
`#component.observe( '${bindings.scrollX}', ${observerCallback} );` `#component.observe("${bindings.scrollX}", ${observerCallback});`
); );
if (bindings.scrollY) if (bindings.scrollY)
block.builders.init.addLine( block.builders.init.addLine(
`#component.observe( '${bindings.scrollY}', ${observerCallback} );` `#component.observe("${bindings.scrollY}", ${observerCallback});`
); );
} else if (bindings.scrollX || bindings.scrollY) { } else if (bindings.scrollX || bindings.scrollY) {
const isX = !!bindings.scrollX; const isX = !!bindings.scrollX;
block.builders.init.addBlock(deindent` block.builders.init.addBlock(deindent`
#component.observe( '${bindings.scrollX || #component.observe("${bindings.scrollX || bindings.scrollY}", function(${isX ? 'x' : 'y'}) {
bindings.scrollY}', function ( ${isX ? 'x' : 'y'} ) { if (${lock}) return;
if ( ${lock} ) return; window.scrollTo(${isX ? 'x, window.scrollY' : 'window.scrollX, y'});
window.scrollTo( ${isX ? 'x, window.scrollY' : 'window.scrollX, y'} );
}); });
`); `);
} }
@ -174,11 +173,11 @@ export default function visitWindow(
if (bindings.online) { if (bindings.online) {
const handlerName = block.getUniqueName(`onlinestatuschanged`); const handlerName = block.getUniqueName(`onlinestatuschanged`);
block.builders.init.addBlock(deindent` block.builders.init.addBlock(deindent`
function ${handlerName} ( event ) { function ${handlerName}(event) {
#component.set({ ${bindings.online}: navigator.onLine }); #component.set({ ${bindings.online}: navigator.onLine });
}; };
window.addEventListener( 'online', ${handlerName} ); window.addEventListener("online", ${handlerName});
window.addEventListener( 'offline', ${handlerName} ); window.addEventListener("offline", ${handlerName});
`); `);
// add initial value // add initial value
@ -187,8 +186,8 @@ export default function visitWindow(
); );
block.builders.destroy.addBlock(deindent` block.builders.destroy.addBlock(deindent`
window.removeEventListener( 'online', ${handlerName} ); window.removeEventListener("online", ${handlerName});
window.removeEventListener( 'offline', ${handlerName} ); window.removeEventListener("offline", ${handlerName});
`); `);
} }
} }

@ -89,7 +89,7 @@ export default function visitIfBlock(
const branches = getBranches(generator, block, state, node, elementStack, componentStack); const branches = getBranches(generator, block, state, node, elementStack, componentStack);
const hasElse = isElseBranch(branches[branches.length - 1]); const hasElse = isElseBranch(branches[branches.length - 1]);
const if_name = hasElse ? '' : `if ( ${name} ) `; const if_name = hasElse ? '' : `if (${name}) `;
const dynamic = branches[0].hasUpdateMethod; // can use [0] as proxy for all, since they necessarily have the same value const dynamic = branches[0].hasUpdateMethod; // can use [0] as proxy for all, since they necessarily have the same value
const hasOutros = branches[0].hasOutroMethod; const hasOutros = branches[0].hasOutroMethod;
@ -117,7 +117,7 @@ export default function visitIfBlock(
block.builders.create.addLine(`${if_name}${name}.create();`); block.builders.create.addLine(`${if_name}${name}.create();`);
block.builders.claim.addLine( block.builders.claim.addLine(
`${if_name}${name}.claim( ${state.parentNodes} );` `${if_name}${name}.claim(${state.parentNodes});`
); );
if (needsAnchor) { if (needsAnchor) {
@ -140,7 +140,7 @@ function simple(
{ name, anchor, params, if_name } { name, anchor, params, if_name }
) { ) {
block.builders.init.addBlock(deindent` block.builders.init.addBlock(deindent`
var ${name} = (${branch.condition}) && ${branch.block}( ${params}, #component ); var ${name} = (${branch.condition}) && ${branch.block}(${params}, #component);
`); `);
const isTopLevel = !state.parentNode; const isTopLevel = !state.parentNode;
@ -149,7 +149,7 @@ function simple(
const anchorNode = state.parentNode ? 'null' : 'anchor'; const anchorNode = state.parentNode ? 'null' : 'anchor';
block.builders.mount.addLine( block.builders.mount.addLine(
`if ( ${name} ) ${name}.${mountOrIntro}( ${targetNode}, ${anchorNode} );` `if (${name}) ${name}.${mountOrIntro}(${targetNode}, ${anchorNode});`
); );
const parentNode = state.parentNode || `${anchor}.parentNode`; const parentNode = state.parentNode || `${anchor}.parentNode`;
@ -157,37 +157,37 @@ function simple(
const enter = dynamic const enter = dynamic
? branch.hasIntroMethod ? branch.hasIntroMethod
? deindent` ? deindent`
if ( ${name} ) { if (${name}) {
${name}.update( changed, ${params} ); ${name}.update(changed, ${params});
} else { } else {
${name} = ${branch.block}( ${params}, #component ); ${name} = ${branch.block}(${params}, #component);
if ( ${name} ) ${name}.create(); if (${name}) ${name}.create();
} }
${name}.intro( ${parentNode}, ${anchor} ); ${name}.intro(${parentNode}, ${anchor});
` `
: deindent` : deindent`
if ( ${name} ) { if (${name}) {
${name}.update( changed, ${params} ); ${name}.update(changed, ${params});
} else { } else {
${name} = ${branch.block}( ${params}, #component ); ${name} = ${branch.block}(${params}, #component);
${name}.create(); ${name}.create();
${name}.mount( ${parentNode}, ${anchor} ); ${name}.mount(${parentNode}, ${anchor});
} }
` `
: branch.hasIntroMethod : branch.hasIntroMethod
? deindent` ? deindent`
if ( !${name} ) { if (!${name}) {
${name} = ${branch.block}( ${params}, #component ); ${name} = ${branch.block}(${params}, #component);
${name}.create(); ${name}.create();
} }
${name}.intro( ${parentNode}, ${anchor} ); ${name}.intro(${parentNode}, ${anchor});
` `
: deindent` : deindent`
if ( !${name} ) { if (!${name}) {
${name} = ${branch.block}( ${params}, #component ); ${name} = ${branch.block}(${params}, #component);
${name}.create(); ${name}.create();
${name}.mount( ${parentNode}, ${anchor} ); ${name}.mount(${parentNode}, ${anchor});
} }
`; `;
@ -195,7 +195,7 @@ function simple(
// as that will typically result in glitching // as that will typically result in glitching
const exit = branch.hasOutroMethod const exit = branch.hasOutroMethod
? deindent` ? deindent`
${name}.outro( function () { ${name}.outro(function() {
${name}.unmount(); ${name}.unmount();
${name}.destroy(); ${name}.destroy();
${name} = null; ${name} = null;
@ -208,9 +208,9 @@ function simple(
`; `;
block.builders.update.addBlock(deindent` block.builders.update.addBlock(deindent`
if ( ${branch.condition} ) { if (${branch.condition}) {
${enter} ${enter}
} else if ( ${name} ) { } else if (${name}) {
${exit} ${exit}
} }
`); `);
@ -234,18 +234,16 @@ function compound(
const current_block_type_and = hasElse ? '' : `${current_block_type} && `; const current_block_type_and = hasElse ? '' : `${current_block_type} && `;
generator.blocks.push(deindent` generator.blocks.push(deindent`
function ${select_block_type} ( ${params} ) { function ${select_block_type}(${params}) {
${branches ${branches
.map(({ condition, block }) => { .map(({ condition, block }) => `${condition ? `if (${condition}) ` : ''}return ${block};`)
return `${condition ? `if ( ${condition} ) ` : ''}return ${block};`;
})
.join('\n')} .join('\n')}
} }
`); `);
block.builders.init.addBlock(deindent` block.builders.init.addBlock(deindent`
var ${current_block_type} = ${select_block_type}( ${params} ); var ${current_block_type} = ${select_block_type}(${params});
var ${name} = ${current_block_type_and}${current_block_type}( ${params}, #component ); var ${name} = ${current_block_type_and}${current_block_type}(${params}, #component);
`); `);
const isTopLevel = !state.parentNode; const isTopLevel = !state.parentNode;
@ -254,7 +252,7 @@ function compound(
const targetNode = state.parentNode || '#target'; const targetNode = state.parentNode || '#target';
const anchorNode = state.parentNode ? 'null' : 'anchor'; const anchorNode = state.parentNode ? 'null' : 'anchor';
block.builders.mount.addLine( block.builders.mount.addLine(
`${if_name}${name}.${mountOrIntro}( ${targetNode}, ${anchorNode} );` `${if_name}${name}.${mountOrIntro}(${targetNode}, ${anchorNode});`
); );
const parentNode = state.parentNode || `${anchor}.parentNode`; const parentNode = state.parentNode || `${anchor}.parentNode`;
@ -266,26 +264,26 @@ function compound(
${name}.destroy(); ${name}.destroy();
` `
: deindent` : deindent`
if ( ${name} ) { if (${name}) {
${name}.unmount(); ${name}.unmount();
${name}.destroy(); ${name}.destroy();
}`} }`}
${name} = ${current_block_type_and}${current_block_type}( ${params}, #component ); ${name} = ${current_block_type_and}${current_block_type}(${params}, #component);
${if_name}${name}.create(); ${if_name}${name}.create();
${if_name}${name}.${mountOrIntro}( ${parentNode}, ${anchor} ); ${if_name}${name}.${mountOrIntro}(${parentNode}, ${anchor});
`; `;
if (dynamic) { if (dynamic) {
block.builders.update.addBlock(deindent` block.builders.update.addBlock(deindent`
if ( ${current_block_type} === ( ${current_block_type} = ${select_block_type}( ${params} ) ) && ${name} ) { if (${current_block_type} === (${current_block_type} = ${select_block_type}(${params})) && ${name}) {
${name}.update( changed, ${params} ); ${name}.update(changed, ${params});
} else { } else {
${changeBlock} ${changeBlock}
} }
`); `);
} else { } else {
block.builders.update.addBlock(deindent` block.builders.update.addBlock(deindent`
if ( ${current_block_type} !== ( ${current_block_type} = ${select_block_type}( ${params} ) ) ) { if (${current_block_type} !== (${current_block_type} = ${select_block_type}(${params}))) {
${changeBlock} ${changeBlock}
} }
`); `);
@ -315,7 +313,7 @@ function compoundWithOutros(
const if_current_block_type_index = hasElse const if_current_block_type_index = hasElse
? '' ? ''
: `if ( ~${current_block_type_index} ) `; : `if (~${current_block_type_index}) `;
block.addVariable(current_block_type_index); block.addVariable(current_block_type_index);
block.addVariable(name); block.addVariable(name);
@ -327,26 +325,22 @@ function compoundWithOutros(
var ${if_blocks} = []; var ${if_blocks} = [];
function ${select_block_type} ( ${params} ) { function ${select_block_type}(${params}) {
${branches ${branches
.map(({ condition, block }, i) => { .map(({ condition, block }, i) => `${condition ? `if (${condition}) ` : ''}return ${block ? i : -1};`)
return `${condition ? `if ( ${condition} ) ` : ''}return ${block
? i
: -1};`;
})
.join('\n')} .join('\n')}
} }
`); `);
if (hasElse) { if (hasElse) {
block.builders.init.addBlock(deindent` block.builders.init.addBlock(deindent`
${current_block_type_index} = ${select_block_type}( ${params} ); ${current_block_type_index} = ${select_block_type}(${params});
${name} = ${if_blocks}[ ${current_block_type_index} ] = ${if_block_creators}[ ${current_block_type_index} ]( ${params}, #component ); ${name} = ${if_blocks}[${current_block_type_index}] = ${if_block_creators}[${current_block_type_index}](${params}, #component);
`); `);
} else { } else {
block.builders.init.addBlock(deindent` block.builders.init.addBlock(deindent`
if ( ~( ${current_block_type_index} = ${select_block_type}( ${params} ) ) ) { if (~(${current_block_type_index} = ${select_block_type}(${params}))) {
${name} = ${if_blocks}[ ${current_block_type_index} ] = ${if_block_creators}[ ${current_block_type_index} ]( ${params}, #component ); ${name} = ${if_blocks}[${current_block_type_index}] = ${if_block_creators}[${current_block_type_index}](${params}, #component);
} }
`); `);
} }
@ -357,13 +351,13 @@ function compoundWithOutros(
const anchorNode = state.parentNode ? 'null' : 'anchor'; const anchorNode = state.parentNode ? 'null' : 'anchor';
block.builders.mount.addLine( block.builders.mount.addLine(
`${if_current_block_type_index}${if_blocks}[ ${current_block_type_index} ].${mountOrIntro}( ${targetNode}, ${anchorNode} );` `${if_current_block_type_index}${if_blocks}[${current_block_type_index}].${mountOrIntro}(${targetNode}, ${anchorNode});`
); );
const parentNode = state.parentNode || `${anchor}.parentNode`; const parentNode = state.parentNode || `${anchor}.parentNode`;
const destroyOldBlock = deindent` const destroyOldBlock = deindent`
${name}.outro( function () { ${name}.outro(function() {
${if_blocks}[ ${previous_block_index} ].unmount(); ${if_blocks}[ ${previous_block_index} ].unmount();
${if_blocks}[ ${previous_block_index} ].destroy(); ${if_blocks}[ ${previous_block_index} ].destroy();
${if_blocks}[ ${previous_block_index} ] = null; ${if_blocks}[ ${previous_block_index} ] = null;
@ -371,12 +365,12 @@ function compoundWithOutros(
`; `;
const createNewBlock = deindent` const createNewBlock = deindent`
${name} = ${if_blocks}[ ${current_block_type_index} ]; ${name} = ${if_blocks}[${current_block_type_index}];
if ( !${name} ) { if (!${name}) {
${name} = ${if_blocks}[ ${current_block_type_index} ] = ${if_block_creators}[ ${current_block_type_index} ]( ${params}, #component ); ${name} = ${if_blocks}[${current_block_type_index}] = ${if_block_creators}[${current_block_type_index}](${params}, #component);
${name}.create(); ${name}.create();
} }
${name}.${mountOrIntro}( ${parentNode}, ${anchor} ); ${name}.${mountOrIntro}(${parentNode}, ${anchor});
`; `;
const changeBlock = hasElse const changeBlock = hasElse
@ -386,11 +380,11 @@ function compoundWithOutros(
${createNewBlock} ${createNewBlock}
` `
: deindent` : deindent`
if ( ${name} ) { if (${name}) {
${destroyOldBlock} ${destroyOldBlock}
} }
if ( ~${current_block_type_index} ) { if (~${current_block_type_index}) {
${createNewBlock} ${createNewBlock}
} else { } else {
${name} = null; ${name} = null;
@ -400,9 +394,9 @@ function compoundWithOutros(
if (dynamic) { if (dynamic) {
block.builders.update.addBlock(deindent` block.builders.update.addBlock(deindent`
var ${previous_block_index} = ${current_block_type_index}; var ${previous_block_index} = ${current_block_type_index};
${current_block_type_index} = ${select_block_type}( ${params} ); ${current_block_type_index} = ${select_block_type}(${params});
if ( ${current_block_type_index} === ${previous_block_index} ) { if (${current_block_type_index} === ${previous_block_index}) {
${if_current_block_type_index}${if_blocks}[ ${current_block_type_index} ].update( changed, ${params} ); ${if_current_block_type_index}${if_blocks}[${current_block_type_index}].update(changed, ${params});
} else { } else {
${changeBlock} ${changeBlock}
} }
@ -410,8 +404,8 @@ function compoundWithOutros(
} else { } else {
block.builders.update.addBlock(deindent` block.builders.update.addBlock(deindent`
var ${previous_block_index} = ${current_block_type_index}; var ${previous_block_index} = ${current_block_type_index};
${current_block_type_index} = ${select_block_type}( ${params} ); ${current_block_type_index} = ${select_block_type}(${params});
if ( ${current_block_type_index} !== ${previous_block_index} ) { if (${current_block_type_index} !== ${previous_block_index}) {
${changeBlock} ${changeBlock}
} }
`); `);
@ -419,8 +413,8 @@ function compoundWithOutros(
block.builders.destroy.addLine(deindent` block.builders.destroy.addLine(deindent`
${if_current_block_type_index}{ ${if_current_block_type_index}{
${if_blocks}[ ${current_block_type_index} ].unmount(); ${if_blocks}[${current_block_type_index}].unmount();
${if_blocks}[ ${current_block_type_index} ].destroy(); ${if_blocks}[${current_block_type_index}].destroy();
} }
`); `);
} }

@ -22,8 +22,8 @@ export default function visitMustacheTag(
block.addElement( block.addElement(
node.var, node.var,
`@createText( ${init} )`, `@createText(${init})`,
`@claimText( ${state.parentNodes}, ${init} )`, `@claimText(${state.parentNodes}, ${init})`,
state.parentNode state.parentNode
); );
} }

@ -34,13 +34,13 @@ export default function visitRawMustacheTag(
insert = content => `${state.parentNode}.innerHTML = ${content};`; insert = content => `${state.parentNode}.innerHTML = ${content};`;
} else if (anchorBefore === 'null') { } else if (anchorBefore === 'null') {
detach = `@detachBefore(${anchorAfter});`; detach = `@detachBefore(${anchorAfter});`;
insert = content => `${anchorAfter}.insertAdjacentHTML('beforebegin', ${content});`; insert = content => `${anchorAfter}.insertAdjacentHTML("beforebegin", ${content});`;
} else if (anchorAfter === 'null') { } else if (anchorAfter === 'null') {
detach = `@detachAfter(${anchorBefore});`; detach = `@detachAfter(${anchorBefore});`;
insert = content => `${anchorBefore}.insertAdjacentHTML('afterend', ${content});`; insert = content => `${anchorBefore}.insertAdjacentHTML("afterend", ${content});`;
} else { } else {
detach = `@detachBetween(${anchorBefore}, ${anchorAfter});`; detach = `@detachBetween(${anchorBefore}, ${anchorAfter});`;
insert = content => `${anchorBefore}.insertAdjacentHTML('afterend', ${content});`; insert = content => `${anchorBefore}.insertAdjacentHTML("afterend", ${content});`;
} }
const { init } = visitTag( const { init } = visitTag(
@ -60,8 +60,8 @@ export default function visitRawMustacheTag(
if (needsAnchorBefore) { if (needsAnchorBefore) {
block.addElement( block.addElement(
anchorBefore, anchorBefore,
`@createElement( 'noscript' )`, `@createElement('noscript')`,
`@createElement( 'noscript' )`, `@createElement('noscript')`,
state.parentNode state.parentNode
); );
} }
@ -69,8 +69,8 @@ export default function visitRawMustacheTag(
function addAnchorAfter() { function addAnchorAfter() {
block.addElement( block.addElement(
anchorAfter, anchorAfter,
`@createElement( 'noscript' )`, `@createElement('noscript')`,
`@createElement( 'noscript' )`, `@createElement('noscript')`,
state.parentNode state.parentNode
); );
} }

@ -14,8 +14,8 @@ export default function visitText(
block.addElement( block.addElement(
node.var, node.var,
`@createText( ${stringify(node.data)} )`, `@createText(${stringify(node.data)})`,
`@claimText( ${state.parentNodes}, ${stringify(node.data)} )`, `@claimText(${state.parentNodes}, ${stringify(node.data)})`,
state.parentNode state.parentNode
); );
} }

@ -29,14 +29,14 @@ export default function visitTag(
if (dependencies.length || hasChangeableIndex) { if (dependencies.length || hasChangeableIndex) {
const changedCheck = ( const changedCheck = (
( block.hasOutroMethod ? `#outroing || ` : '' ) + (block.hasOutroMethod ? `#outroing || ` : '') +
dependencies.map(dependency => `changed.${dependency}`).join(' || ') dependencies.map(dependency => `changed.${dependency}`).join(' || ')
); );
const updateCachedValue = `${value} !== ( ${value} = ${snippet} )`; const updateCachedValue = `${value} !== (${value} = ${snippet})`;
const condition = shouldCache ? const condition = shouldCache ?
( dependencies.length ? `( ${changedCheck} ) && ${updateCachedValue}` : updateCachedValue ) : (dependencies.length ? `(${changedCheck}) && ${updateCachedValue}` : updateCachedValue) :
changedCheck; changedCheck;
block.builders.update.addConditional( block.builders.update.addConditional(

@ -21,7 +21,7 @@ export default class Block {
} }
addBinding(binding: Node, name: string) { addBinding(binding: Node, name: string) {
const conditions = [`!( '${binding.name}' in state )`].concat( const conditions = [`!('${binding.name}' in state)`].concat(
// TODO handle contextual bindings... // TODO handle contextual bindings...
this.conditions.map(c => `(${c})`) this.conditions.map(c => `(${c})`)
); );
@ -29,9 +29,9 @@ export default class Block {
const { name: prop } = getObject(binding.value); const { name: prop } = getObject(binding.value);
this.generator.bindings.push(deindent` this.generator.bindings.push(deindent`
if ( ${conditions.join('&&')} ) { if (${conditions.join('&&')}) {
tmp = ${name}.data(); tmp = ${name}.data();
if ( '${prop}' in tmp ) { if ('${prop}' in tmp) {
state.${binding.name} = tmp.${prop}; state.${binding.name} = tmp.${prop};
settled = false; settled = false;
} }

@ -105,20 +105,18 @@ export default function ssr(
${name}.filename = ${stringify(options.filename)}; ${name}.filename = ${stringify(options.filename)};
${name}.data = function () { ${name}.data = function() {
return ${templateProperties.data ? `@template.data()` : `{}`}; return ${templateProperties.data ? `@template.data()` : `{}`};
}; };
${name}.render = function ( state, options ) { ${name}.render = function(state, options) {
${templateProperties.data ${templateProperties.data
? `state = Object.assign( @template.data(), state || {} );` ? `state = Object.assign(@template.data(), state || {});`
: `state = state || {};`} : `state = state || {};`}
${computations.map( ${computations.map(
({ key, deps }) => ({ key, deps }) =>
`state.${key} = @template.computed.${key}( ${deps `state.${key} = @template.computed.${key}(${deps.map(dep => `state.${dep}`).join(', ')});`
.map(dep => `state.${dep}`)
.join(', ')} );`
)} )}
${generator.bindings.length && ${generator.bindings.length &&
@ -126,7 +124,7 @@ export default function ssr(
var settled = false; var settled = false;
var tmp; var tmp;
while ( !settled ) { while (!settled) {
settled = true; settled = true;
${generator.bindings.join('\n\n')} ${generator.bindings.join('\n\n')}
@ -136,7 +134,7 @@ export default function ssr(
return \`${generator.renderCode}\`.trim(); return \`${generator.renderCode}\`.trim();
}; };
${name}.renderCss = function () { ${name}.renderCss = function() {
var components = []; var components = [];
${generator.stylesheet.hasStyles && ${generator.stylesheet.hasStyles &&
@ -152,26 +150,24 @@ export default function ssr(
deindent` deindent`
var seen = {}; var seen = {};
function addComponent ( component ) { function addComponent(component) {
var result = component.renderCss(); var result = component.renderCss();
result.components.forEach( x => { result.components.forEach(x => {
if ( seen[ x.filename ] ) return; if (seen[x.filename]) return;
seen[ x.filename ] = true; seen[x.filename] = true;
components.push( x ); components.push(x);
}); });
} }
${templateProperties.components.value.properties.map(prop => { ${templateProperties.components.value.properties.map(prop => {
const { name } = prop.key; const { name } = prop.key;
const expression = const expression = generator.importedComponents.get(name) || `@template.components.${name}`;
generator.importedComponents.get(name) || return `addComponent(${expression});`;
`@template.components.${name}`;
return `addComponent( ${expression} );`;
})} })}
`} `}
return { return {
css: components.map( x => x.css ).join( '\\n' ), css: components.map(x => x.css).join('\\n'),
map: null, map: null,
components components
}; };
@ -185,8 +181,8 @@ export default function ssr(
'>': '&gt;' '>': '&gt;'
}; };
function __escape ( html ) { function __escape(html) {
return String( html ).replace( /["'&<>]/g, match => escaped[ match ] ); return String(html).replace(/["'&<>]/g, match => escaped[match]);
} }
`.replace(/(@+|#+)(\w*)/g, (match: string, sigil: string, name: string) => { `.replace(/(@+|#+)(\w*)/g, (match: string, sigil: string, name: string) => {
return sigil === '@' ? generator.alias(name) : sigil.slice(1) + name; return sigil === '@' ? generator.alias(name) : sigil.slice(1) + name;

@ -10,11 +10,7 @@ export default function visitEachBlock(
) { ) {
const { dependencies, snippet } = block.contextualise(node.expression); const { dependencies, snippet } = block.contextualise(node.expression);
const open = `\${ ${node.else const open = `\${ ${node.else ? `${snippet}.length ? ` : ''}${snippet}.map(${node.index ? `(${node.context}, ${node.index})` : node.context} => \``;
? `${snippet}.length ? `
: ''}${snippet}.map( ${node.index
? `( ${node.context}, ${node.index} )`
: node.context} => \``;
generator.append(open); generator.append(open);
// TODO should this be the generator's job? It's duplicated between // TODO should this be the generator's job? It's duplicated between
@ -38,7 +34,7 @@ export default function visitEachBlock(
visit(generator, childBlock, child); visit(generator, childBlock, child);
}); });
const close = `\` ).join( '' )`; const close = `\`).join("")`;
generator.append(close); generator.append(close);
if (node.else) { if (node.else) {

@ -8,5 +8,5 @@ export default function visitMustacheTag(
node: Node node: Node
) { ) {
const { snippet } = block.contextualise(node.expression); const { snippet } = block.contextualise(node.expression);
generator.append('${__escape( ' + snippet + ' )}'); generator.append('${__escape(' + snippet + ')}');
} }

@ -1,4 +1,4 @@
import { Node } from '../../../../interfaces'; import { Node } from '../../interfaces';
export default function getStaticAttributeValue(node: Node, name: string) { export default function getStaticAttributeValue(node: Node, name: string) {
const attribute = node.attributes.find( const attribute = node.attributes.find(

@ -11,8 +11,7 @@ export default function getGlobals(imports: Node[], options: CompileOptions) {
if (!name) { if (!name) {
if (x.name.startsWith('__import')) { if (x.name.startsWith('__import')) {
const error = new Error( const error = new Error(
`Could not determine name for imported module '${x.source `Could not determine name for imported module '${x.source.value}' use options.globals`
.value}' use options.globals`
); );
if (onerror) { if (onerror) {
onerror(error); onerror(error);
@ -21,8 +20,7 @@ export default function getGlobals(imports: Node[], options: CompileOptions) {
} }
} else { } else {
const warning = { const warning = {
message: `No name was supplied for imported module '${x.source message: `No name was supplied for imported module '${x.source.value}'. Guessing '${x.name}', but you should use options.globals`,
.value}'. Guessing '${x.name}', but you should use options.globals`,
}; };
if (onwarn) { if (onwarn) {

@ -19,23 +19,23 @@ export default function getIntro(
function getAmdIntro(options: CompileOptions, imports: Node[]) { function getAmdIntro(options: CompileOptions, imports: Node[]) {
const sourceString = imports.length const sourceString = imports.length
? `[ ${imports ? `[${imports
.map(declaration => `'${removeExtension(declaration.source.value)}'`) .map(declaration => `'${removeExtension(declaration.source.value)}'`)
.join(', ')} ], ` .join(', ')}], `
: ''; : '';
const id = options.amd && options.amd.id; const id = options.amd && options.amd.id;
return `define(${id return `define(${id
? ` '${id}', ` ? `"${id}", `
: ''}${sourceString}function (${paramString(imports)}) { 'use strict';\n\n`; : ''}${sourceString}function(${paramString(imports)}) { 'use strict';\n\n`;
} }
function getCjsIntro(options: CompileOptions, imports: Node[]) { function getCjsIntro(options: CompileOptions, imports: Node[]) {
const requireBlock = imports const requireBlock = imports
.map( .map(
declaration => declaration =>
`var ${declaration.name} = require( '${declaration.source.value}' );` `var ${declaration.name} = require('${declaration.source.value}');`
) )
.join('\n\n'); .join('\n\n');
@ -51,9 +51,7 @@ function getIifeIntro(options: CompileOptions, imports: Node[]) {
throw new Error(`Missing required 'name' option for IIFE export`); throw new Error(`Missing required 'name' option for IIFE export`);
} }
return `var ${options.name} = (function (${paramString( return `var ${options.name} = (function(${paramString(imports)}) { 'use strict';\n\n`;
imports
)}) { 'use strict';\n\n`;
} }
function getUmdIntro(options: CompileOptions, imports: Node[]) { function getUmdIntro(options: CompileOptions, imports: Node[]) {
@ -75,7 +73,7 @@ function getUmdIntro(options: CompileOptions, imports: Node[]) {
return ( return (
deindent` deindent`
(function ( global, factory ) { (function(global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(${cjsDeps}) : typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(${cjsDeps}) :
typeof define === 'function' && define.amd ? define(${amdId}${amdDeps}factory) : typeof define === 'function' && define.amd ? define(${amdId}${amdDeps}factory) :
(global.${options.name} = factory(${globalDeps})); (global.${options.name} = factory(${globalDeps}));
@ -88,7 +86,7 @@ function getEvalIntro(options: CompileOptions, imports: Node[]) {
} }
function paramString(imports: Node[]) { function paramString(imports: Node[]) {
return imports.length ? ` ${imports.map(dep => dep.name).join(', ')} ` : ''; return imports.map(dep => dep.name).join(', ');
} }
function removeExtension(file: string) { function removeExtension(file: string) {

@ -175,7 +175,7 @@ var proto = {
_unmount: _unmount _unmount: _unmount
}; };
var template = (function () { var template = (function() {
return { return {
data: function () { data: function () {
return { foo: 42 } return { foo: 42 }
@ -183,43 +183,43 @@ var template = (function () {
}; };
}()); }());
function encapsulateStyles ( node ) { function encapsulateStyles(node) {
setAttribute( node, 'svelte-3590263702', '' ); setAttribute(node, "svelte-3590263702", "");
} }
function add_css () { function add_css() {
var style = createElement( 'style' ); var style = createElement("style");
style.id = 'svelte-3590263702-style'; style.id = 'svelte-3590263702-style';
style.textContent = "p[svelte-3590263702],[svelte-3590263702] p{color:red}"; style.textContent = "p[svelte-3590263702],[svelte-3590263702] p{color:red}";
appendNode( style, document.head ); appendNode(style, document.head);
} }
function create_main_fragment ( state, component ) { function create_main_fragment(state, component) {
var p, text; var p, text;
return { return {
create: function () { create: function() {
p = createElement( 'p' ); p = createElement( 'p' );
text = createText( state.foo ); text = createText(state.foo);
this.hydrate(); this.hydrate();
}, },
hydrate: function ( nodes ) { hydrate: function(nodes) {
encapsulateStyles( p ); encapsulateStyles( p );
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( p, target, anchor ); insertNode( p, target, anchor );
appendNode( text, p ); appendNode(text, p);
}, },
update: function ( changed, state ) { update: function(changed, state) {
if ( changed.foo ) { if ( changed.foo ) {
text.data = state.foo; text.data = state.foo;
} }
}, },
unmount: function () { unmount: function() {
detachNode( p ); detachNode( p );
}, },
@ -227,31 +227,31 @@ function create_main_fragment ( state, component ) {
}; };
} }
function SvelteComponent ( options ) { function SvelteComponent(options) {
this.options = options; this.options = options;
this._state = assign( template.data(), options.data ); this._state = assign(template.data(), options.data);
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
this._root = options._root || this; this._root = options._root || this;
this._yield = options._yield; this._yield = options._yield;
this._bind = options._bind; this._bind = options._bind;
if ( !document.getElementById( 'svelte-3590263702-style' ) ) add_css(); if (!document.getElementById("svelte-3590263702-style")) add_css();
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, options.anchor || null ); this._fragment.mount(options.target, options.anchor || null);
} }
} }
assign( SvelteComponent.prototype, proto ); assign(SvelteComponent.prototype, proto );
export default SvelteComponent; export default SvelteComponent;

@ -1,6 +1,6 @@
import { appendNode, assign, createElement, createText, detachNode, insertNode, noop, proto, setAttribute } from "svelte/shared.js"; import { appendNode, assign, createElement, createText, detachNode, insertNode, noop, proto, setAttribute } from "svelte/shared.js";
var template = (function () { var template = (function() {
return { return {
data: function () { data: function () {
return { foo: 42 } return { foo: 42 }
@ -8,43 +8,43 @@ var template = (function () {
}; };
}()); }());
function encapsulateStyles ( node ) { function encapsulateStyles(node) {
setAttribute( node, 'svelte-3590263702', '' ); setAttribute(node, "svelte-3590263702", "");
} }
function add_css () { function add_css() {
var style = createElement( 'style' ); var style = createElement("style");
style.id = 'svelte-3590263702-style'; style.id = 'svelte-3590263702-style';
style.textContent = "p[svelte-3590263702],[svelte-3590263702] p{color:red}"; style.textContent = "p[svelte-3590263702],[svelte-3590263702] p{color:red}";
appendNode( style, document.head ); appendNode(style, document.head);
} }
function create_main_fragment ( state, component ) { function create_main_fragment(state, component) {
var p, text; var p, text;
return { return {
create: function () { create: function() {
p = createElement( 'p' ); p = createElement( 'p' );
text = createText( state.foo ); text = createText(state.foo);
this.hydrate(); this.hydrate();
}, },
hydrate: function ( nodes ) { hydrate: function(nodes) {
encapsulateStyles( p ); encapsulateStyles( p );
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( p, target, anchor ); insertNode( p, target, anchor );
appendNode( text, p ); appendNode(text, p);
}, },
update: function ( changed, state ) { update: function(changed, state) {
if ( changed.foo ) { if ( changed.foo ) {
text.data = state.foo; text.data = state.foo;
} }
}, },
unmount: function () { unmount: function() {
detachNode( p ); detachNode( p );
}, },
@ -52,31 +52,31 @@ function create_main_fragment ( state, component ) {
}; };
} }
function SvelteComponent ( options ) { function SvelteComponent(options) {
this.options = options; this.options = options;
this._state = assign( template.data(), options.data ); this._state = assign(template.data(), options.data);
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
this._root = options._root || this; this._root = options._root || this;
this._yield = options._yield; this._yield = options._yield;
this._bind = options._bind; this._bind = options._bind;
if ( !document.getElementById( 'svelte-3590263702-style' ) ) add_css(); if (!document.getElementById("svelte-3590263702-style")) add_css();
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, options.anchor || null ); this._fragment.mount(options.target, options.anchor || null);
} }
} }
assign( SvelteComponent.prototype, proto ); assign(SvelteComponent.prototype, proto );
export default SvelteComponent; export default SvelteComponent;

@ -151,7 +151,7 @@ var proto = {
_unmount: _unmount _unmount: _unmount
}; };
var template = (function () { var template = (function() {
return { return {
computed: { computed: {
a: x => x * 2, a: x => x * 2,
@ -160,7 +160,7 @@ var template = (function () {
}; };
}()); }());
function create_main_fragment ( state, component ) { function create_main_fragment(state, component) {
return { return {
create: noop, create: noop,
@ -175,36 +175,36 @@ function create_main_fragment ( state, component ) {
}; };
} }
function SvelteComponent ( options ) { function SvelteComponent(options) {
this.options = options; this.options = options;
this._state = options.data || {}; this._state = options.data || {};
this._recompute( {}, this._state, {}, true ); this._recompute({}, this._state, {}, true);
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
this._root = options._root || this; this._root = options._root || this;
this._yield = options._yield; this._yield = options._yield;
this._bind = options._bind; this._bind = options._bind;
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, options.anchor || null ); this._fragment.mount(options.target, options.anchor || null);
} }
} }
assign( SvelteComponent.prototype, proto ); assign(SvelteComponent.prototype, proto );
SvelteComponent.prototype._recompute = function _recompute ( changed, state, oldState, isInitial ) { SvelteComponent.prototype._recompute = function _recompute(changed, state, oldState, isInitial) {
if ( isInitial || changed.x ) { if ( isInitial || changed.x ) {
if ( differs( ( state.a = template.computed.a( state.x ) ), oldState.a ) ) changed.a = true; if (differs((state.a = template.computed.a(state.x)), oldState.a)) changed.a = true;
if ( differs( ( state.b = template.computed.b( state.x ) ), oldState.b ) ) changed.b = true; if (differs((state.b = template.computed.b(state.x)), oldState.b)) changed.b = true;
} }
}; };

@ -1,6 +1,6 @@
import { assign, differs, noop, proto } from "svelte/shared.js"; import { assign, differs, noop, proto } from "svelte/shared.js";
var template = (function () { var template = (function() {
return { return {
computed: { computed: {
a: x => x * 2, a: x => x * 2,
@ -9,7 +9,7 @@ var template = (function () {
}; };
}()); }());
function create_main_fragment ( state, component ) { function create_main_fragment(state, component) {
return { return {
create: noop, create: noop,
@ -24,36 +24,36 @@ function create_main_fragment ( state, component ) {
}; };
} }
function SvelteComponent ( options ) { function SvelteComponent(options) {
this.options = options; this.options = options;
this._state = options.data || {}; this._state = options.data || {};
this._recompute( {}, this._state, {}, true ); this._recompute({}, this._state, {}, true);
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
this._root = options._root || this; this._root = options._root || this;
this._yield = options._yield; this._yield = options._yield;
this._bind = options._bind; this._bind = options._bind;
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, options.anchor || null ); this._fragment.mount(options.target, options.anchor || null);
} }
} }
assign( SvelteComponent.prototype, proto ); assign(SvelteComponent.prototype, proto );
SvelteComponent.prototype._recompute = function _recompute ( changed, state, oldState, isInitial ) { SvelteComponent.prototype._recompute = function _recompute(changed, state, oldState, isInitial) {
if ( isInitial || changed.x ) { if ( isInitial || changed.x ) {
if ( differs( ( state.a = template.computed.a( state.x ) ), oldState.a ) ) changed.a = true; if (differs((state.a = template.computed.a(state.x)), oldState.a)) changed.a = true;
if ( differs( ( state.b = template.computed.b( state.x ) ), oldState.b ) ) changed.b = true; if (differs((state.b = template.computed.b(state.x)), oldState.b)) changed.b = true;
} }
} }

@ -171,37 +171,37 @@ var proto = {
_unmount: _unmount _unmount: _unmount
}; };
function encapsulateStyles ( node ) { function encapsulateStyles(node) {
setAttribute( node, 'svelte-2363328337', '' ); setAttribute(node, "svelte-2363328337", "");
} }
function add_css () { function add_css() {
var style = createElement( 'style' ); var style = createElement("style");
style.id = 'svelte-2363328337-style'; style.id = 'svelte-2363328337-style';
style.textContent = "@media(min-width: 1px){div[svelte-2363328337],[svelte-2363328337] div{color:red}}"; style.textContent = "@media(min-width: 1px){div[svelte-2363328337],[svelte-2363328337] div{color:red}}";
appendNode( style, document.head ); appendNode(style, document.head);
} }
function create_main_fragment ( state, component ) { function create_main_fragment(state, component) {
var div; var div;
return { return {
create: function () { create: function() {
div = createElement( 'div' ); div = createElement( 'div' );
this.hydrate(); this.hydrate();
}, },
hydrate: function ( nodes ) { hydrate: function(nodes) {
encapsulateStyles( div ); encapsulateStyles( div );
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( div, target, anchor ); insertNode( div, target, anchor );
}, },
update: noop, update: noop,
unmount: function () { unmount: function() {
detachNode( div ); detachNode( div );
}, },
@ -209,31 +209,31 @@ function create_main_fragment ( state, component ) {
}; };
} }
function SvelteComponent ( options ) { function SvelteComponent(options) {
this.options = options; this.options = options;
this._state = options.data || {}; this._state = options.data || {};
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
this._root = options._root || this; this._root = options._root || this;
this._yield = options._yield; this._yield = options._yield;
this._bind = options._bind; this._bind = options._bind;
if ( !document.getElementById( 'svelte-2363328337-style' ) ) add_css(); if (!document.getElementById("svelte-2363328337-style")) add_css();
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, options.anchor || null ); this._fragment.mount(options.target, options.anchor || null);
} }
} }
assign( SvelteComponent.prototype, proto ); assign(SvelteComponent.prototype, proto );
export default SvelteComponent; export default SvelteComponent;

@ -1,36 +1,36 @@
import { appendNode, assign, createElement, detachNode, insertNode, noop, proto, setAttribute } from "svelte/shared.js"; import { appendNode, assign, createElement, detachNode, insertNode, noop, proto, setAttribute } from "svelte/shared.js";
function encapsulateStyles ( node ) { function encapsulateStyles(node) {
setAttribute( node, 'svelte-2363328337', '' ); setAttribute(node, "svelte-2363328337", "");
} }
function add_css () { function add_css() {
var style = createElement( 'style' ); var style = createElement("style");
style.id = 'svelte-2363328337-style'; style.id = 'svelte-2363328337-style';
style.textContent = "@media(min-width: 1px){div[svelte-2363328337],[svelte-2363328337] div{color:red}}"; style.textContent = "@media(min-width: 1px){div[svelte-2363328337],[svelte-2363328337] div{color:red}}";
appendNode( style, document.head ); appendNode(style, document.head);
} }
function create_main_fragment ( state, component ) { function create_main_fragment(state, component) {
var div; var div;
return { return {
create: function () { create: function() {
div = createElement( 'div' ); div = createElement( 'div' );
this.hydrate(); this.hydrate();
}, },
hydrate: function ( nodes ) { hydrate: function(nodes) {
encapsulateStyles( div ); encapsulateStyles( div );
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( div, target, anchor ); insertNode( div, target, anchor );
}, },
update: noop, update: noop,
unmount: function () { unmount: function() {
detachNode( div ); detachNode( div );
}, },
@ -38,31 +38,31 @@ function create_main_fragment ( state, component ) {
}; };
} }
function SvelteComponent ( options ) { function SvelteComponent(options) {
this.options = options; this.options = options;
this._state = options.data || {}; this._state = options.data || {};
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
this._root = options._root || this; this._root = options._root || this;
this._yield = options._yield; this._yield = options._yield;
this._bind = options._bind; this._bind = options._bind;
if ( !document.getElementById( 'svelte-2363328337-style' ) ) add_css(); if (!document.getElementById("svelte-2363328337-style")) add_css();
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, options.anchor || null ); this._fragment.mount(options.target, options.anchor || null);
} }
} }
assign( SvelteComponent.prototype, proto ); assign(SvelteComponent.prototype, proto );
export default SvelteComponent; export default SvelteComponent;

@ -171,31 +171,31 @@ var proto = {
_unmount: _unmount _unmount: _unmount
}; };
function create_main_fragment ( state, component ) { function create_main_fragment(state, component) {
var h1, text, text_1, text_2; var h1, text, text_1, text_2;
return { return {
create: function () { create: function() {
h1 = createElement( 'h1' ); h1 = createElement( 'h1' );
text = createText( "Hello " ); text = createText("Hello ");
text_1 = createText( state.name ); text_1 = createText(state.name);
text_2 = createText( "!" ); text_2 = createText("!");
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( h1, target, anchor ); insertNode( h1, target, anchor );
appendNode( text, h1 ); appendNode(text, h1);
appendNode( text_1, h1 ); appendNode(text_1, h1);
appendNode( text_2, h1 ); appendNode(text_2, h1);
}, },
update: function ( changed, state ) { update: function(changed, state) {
if ( changed.name ) { if ( changed.name ) {
text_1.data = state.name; text_1.data = state.name;
} }
}, },
unmount: function () { unmount: function() {
detachNode( h1 ); detachNode( h1 );
}, },
@ -210,11 +210,11 @@ class SvelteComponent extends HTMLElement {
this._state = options.data || {}; this._state = options.data || {};
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
this._root = options._root || this; this._root = options._root || this;
this._yield = options._yield; this._yield = options._yield;
@ -222,11 +222,11 @@ class SvelteComponent extends HTMLElement {
this.attachShadow({ mode: 'open' }); this.attachShadow({ mode: 'open' });
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
this._fragment.create(); this._fragment.create();
this._mount( options.target, options.anchor || null ); this._mount(options.target, options.anchor || null);
} }
} }
@ -242,13 +242,13 @@ class SvelteComponent extends HTMLElement {
this.set({ name: value }); this.set({ name: value });
} }
attributeChangedCallback ( attr, oldValue, newValue ) { attributeChangedCallback(attr, oldValue, newValue) {
this.set({ [attr]: newValue }); this.set({ [attr]: newValue });
} }
} }
customElements.define('custom-element', SvelteComponent); customElements.define("custom-element", SvelteComponent);
assign( SvelteComponent.prototype, proto , { assign(SvelteComponent.prototype, proto , {
_mount(target, anchor) { _mount(target, anchor) {
this._fragment.mount(this.shadowRoot, null); this._fragment.mount(this.shadowRoot, null);
target.insertBefore(this, anchor); target.insertBefore(this, anchor);

@ -1,30 +1,30 @@
import { appendNode, assign, createElement, createText, detachNode, insertNode, noop, proto } from "svelte/shared.js"; import { appendNode, assign, createElement, createText, detachNode, insertNode, noop, proto } from "svelte/shared.js";
function create_main_fragment ( state, component ) { function create_main_fragment(state, component) {
var h1, text, text_1, text_2; var h1, text, text_1, text_2;
return { return {
create: function () { create: function() {
h1 = createElement( 'h1' ); h1 = createElement( 'h1' );
text = createText( "Hello " ); text = createText("Hello ");
text_1 = createText( state.name ); text_1 = createText(state.name);
text_2 = createText( "!" ); text_2 = createText("!");
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( h1, target, anchor ); insertNode( h1, target, anchor );
appendNode( text, h1 ); appendNode(text, h1);
appendNode( text_1, h1 ); appendNode(text_1, h1);
appendNode( text_2, h1 ); appendNode(text_2, h1);
}, },
update: function ( changed, state ) { update: function(changed, state) {
if ( changed.name ) { if ( changed.name ) {
text_1.data = state.name; text_1.data = state.name;
} }
}, },
unmount: function () { unmount: function() {
detachNode( h1 ); detachNode( h1 );
}, },
@ -39,11 +39,11 @@ class SvelteComponent extends HTMLElement {
this._state = options.data || {}; this._state = options.data || {};
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
this._root = options._root || this; this._root = options._root || this;
this._yield = options._yield; this._yield = options._yield;
@ -51,11 +51,11 @@ class SvelteComponent extends HTMLElement {
this.attachShadow({ mode: 'open' }); this.attachShadow({ mode: 'open' });
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
this._fragment.create(); this._fragment.create();
this._mount( options.target, options.anchor || null ); this._mount(options.target, options.anchor || null);
} }
} }
@ -71,13 +71,13 @@ class SvelteComponent extends HTMLElement {
this.set({ name: value }); this.set({ name: value });
} }
attributeChangedCallback ( attr, oldValue, newValue ) { attributeChangedCallback(attr, oldValue, newValue) {
this.set({ [attr]: newValue }); this.set({ [attr]: newValue });
} }
} }
customElements.define('custom-element', SvelteComponent); customElements.define("custom-element", SvelteComponent);
assign( SvelteComponent.prototype, proto , { assign(SvelteComponent.prototype, proto , {
_mount(target, anchor) { _mount(target, anchor) {
this._fragment.mount(this.shadowRoot, null); this._fragment.mount(this.shadowRoot, null);
target.insertBefore(this, anchor); target.insertBefore(this, anchor);

@ -175,40 +175,40 @@ var proto = {
_unmount: _unmount _unmount: _unmount
}; };
function create_main_fragment ( state, component ) { function create_main_fragment(state, component) {
var div, slot, p, text, text_2, slot_1, p_1, text_3; var div, slot, p, text, text_2, slot_1, p_1, text_3;
return { return {
create: function () { create: function() {
div = createElement( 'div' ); div = createElement( 'div' );
slot = createElement( 'slot' ); slot = createElement( 'slot' );
p = createElement( 'p' ); p = createElement( 'p' );
text = createText( "default fallback content" ); text = createText("default fallback content");
text_2 = createText( "\n\n\t" ); text_2 = createText("\n\n\t");
slot_1 = createElement( 'slot' ); slot_1 = createElement( 'slot' );
p_1 = createElement( 'p' ); p_1 = createElement( 'p' );
text_3 = createText( "foo fallback content" ); text_3 = createText("foo fallback content");
this.hydrate(); this.hydrate();
}, },
hydrate: function ( nodes ) { hydrate: function(nodes) {
setAttribute( slot_1, 'name', "foo" ); setAttribute(slot_1, "name", "foo");
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( div, target, anchor ); insertNode( div, target, anchor );
appendNode( slot, div ); appendNode( slot, div );
appendNode( p, slot ); appendNode( p, slot );
appendNode( text, p ); appendNode(text, p);
appendNode( text_2, div ); appendNode(text_2, div);
appendNode( slot_1, div ); appendNode( slot_1, div );
appendNode( p_1, slot_1 ); appendNode( p_1, slot_1 );
appendNode( text_3, p_1 ); appendNode(text_3, p_1);
}, },
update: noop, update: noop,
unmount: function () { unmount: function() {
detachNode( div ); detachNode( div );
}, },
@ -223,11 +223,11 @@ class SvelteComponent extends HTMLElement {
this._state = options.data || {}; this._state = options.data || {};
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
this._root = options._root || this; this._root = options._root || this;
this._yield = options._yield; this._yield = options._yield;
@ -238,11 +238,11 @@ class SvelteComponent extends HTMLElement {
this.slots = {}; this.slots = {};
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
this._fragment.create(); this._fragment.create();
this._mount( options.target, options.anchor || null ); this._mount(options.target, options.anchor || null);
} }
} }
@ -258,13 +258,13 @@ class SvelteComponent extends HTMLElement {
}); });
} }
attributeChangedCallback ( attr, oldValue, newValue ) { attributeChangedCallback(attr, oldValue, newValue) {
this.set({ [attr]: newValue }); this.set({ [attr]: newValue });
} }
} }
customElements.define('custom-element', SvelteComponent); customElements.define("custom-element", SvelteComponent);
assign( SvelteComponent.prototype, proto , { assign(SvelteComponent.prototype, proto , {
_mount(target, anchor) { _mount(target, anchor) {
this._fragment.mount(this.shadowRoot, null); this._fragment.mount(this.shadowRoot, null);
target.insertBefore(this, anchor); target.insertBefore(this, anchor);

@ -1,39 +1,39 @@
import { appendNode, assign, createElement, createText, detachNode, insertNode, noop, proto, setAttribute } from "svelte/shared.js"; import { appendNode, assign, createElement, createText, detachNode, insertNode, noop, proto, setAttribute } from "svelte/shared.js";
function create_main_fragment ( state, component ) { function create_main_fragment(state, component) {
var div, slot, p, text, text_2, slot_1, p_1, text_3; var div, slot, p, text, text_2, slot_1, p_1, text_3;
return { return {
create: function () { create: function() {
div = createElement( 'div' ); div = createElement( 'div' );
slot = createElement( 'slot' ); slot = createElement( 'slot' );
p = createElement( 'p' ); p = createElement( 'p' );
text = createText( "default fallback content" ); text = createText("default fallback content");
text_2 = createText( "\n\n\t" ); text_2 = createText("\n\n\t");
slot_1 = createElement( 'slot' ); slot_1 = createElement( 'slot' );
p_1 = createElement( 'p' ); p_1 = createElement( 'p' );
text_3 = createText( "foo fallback content" ); text_3 = createText("foo fallback content");
this.hydrate(); this.hydrate();
}, },
hydrate: function ( nodes ) { hydrate: function(nodes) {
setAttribute( slot_1, 'name', "foo" ); setAttribute(slot_1, "name", "foo");
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( div, target, anchor ); insertNode( div, target, anchor );
appendNode( slot, div ); appendNode( slot, div );
appendNode( p, slot ); appendNode( p, slot );
appendNode( text, p ); appendNode(text, p);
appendNode( text_2, div ); appendNode(text_2, div);
appendNode( slot_1, div ); appendNode( slot_1, div );
appendNode( p_1, slot_1 ); appendNode( p_1, slot_1 );
appendNode( text_3, p_1 ); appendNode(text_3, p_1);
}, },
update: noop, update: noop,
unmount: function () { unmount: function() {
detachNode( div ); detachNode( div );
}, },
@ -48,11 +48,11 @@ class SvelteComponent extends HTMLElement {
this._state = options.data || {}; this._state = options.data || {};
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
this._root = options._root || this; this._root = options._root || this;
this._yield = options._yield; this._yield = options._yield;
@ -63,11 +63,11 @@ class SvelteComponent extends HTMLElement {
this.slots = {}; this.slots = {};
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
this._fragment.create(); this._fragment.create();
this._mount( options.target, options.anchor || null ); this._mount(options.target, options.anchor || null);
} }
} }
@ -83,13 +83,13 @@ class SvelteComponent extends HTMLElement {
}); });
} }
attributeChangedCallback ( attr, oldValue, newValue ) { attributeChangedCallback(attr, oldValue, newValue) {
this.set({ [attr]: newValue }); this.set({ [attr]: newValue });
} }
} }
customElements.define('custom-element', SvelteComponent); customElements.define("custom-element", SvelteComponent);
assign( SvelteComponent.prototype, proto , { assign(SvelteComponent.prototype, proto , {
_mount(target, anchor) { _mount(target, anchor) {
this._fragment.mount(this.shadowRoot, null); this._fragment.mount(this.shadowRoot, null);
target.insertBefore(this, anchor); target.insertBefore(this, anchor);

@ -171,31 +171,31 @@ var proto = {
_unmount: _unmount _unmount: _unmount
}; };
function create_main_fragment ( state, component ) { function create_main_fragment(state, component) {
var h1, text, text_1, text_2; var h1, text, text_1, text_2;
return { return {
create: function () { create: function() {
h1 = createElement( 'h1' ); h1 = createElement( 'h1' );
text = createText( "Hello " ); text = createText("Hello ");
text_1 = createText( state.name ); text_1 = createText(state.name);
text_2 = createText( "!" ); text_2 = createText("!");
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( h1, target, anchor ); insertNode( h1, target, anchor );
appendNode( text, h1 ); appendNode(text, h1);
appendNode( text_1, h1 ); appendNode(text_1, h1);
appendNode( text_2, h1 ); appendNode(text_2, h1);
}, },
update: function ( changed, state ) { update: function(changed, state) {
if ( changed.name ) { if ( changed.name ) {
text_1.data = state.name; text_1.data = state.name;
} }
}, },
unmount: function () { unmount: function() {
detachNode( h1 ); detachNode( h1 );
}, },
@ -210,11 +210,11 @@ class SvelteComponent extends HTMLElement {
this._state = options.data || {}; this._state = options.data || {};
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
this._root = options._root || this; this._root = options._root || this;
this._yield = options._yield; this._yield = options._yield;
@ -223,11 +223,11 @@ class SvelteComponent extends HTMLElement {
this.attachShadow({ mode: 'open' }); this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `<style>h1{color:red}</style>`; this.shadowRoot.innerHTML = `<style>h1{color:red}</style>`;
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
this._fragment.create(); this._fragment.create();
this._mount( options.target, options.anchor || null ); this._mount(options.target, options.anchor || null);
} }
} }
@ -243,13 +243,13 @@ class SvelteComponent extends HTMLElement {
this.set({ name: value }); this.set({ name: value });
} }
attributeChangedCallback ( attr, oldValue, newValue ) { attributeChangedCallback(attr, oldValue, newValue) {
this.set({ [attr]: newValue }); this.set({ [attr]: newValue });
} }
} }
customElements.define('custom-element', SvelteComponent); customElements.define("custom-element", SvelteComponent);
assign( SvelteComponent.prototype, proto , { assign(SvelteComponent.prototype, proto , {
_mount(target, anchor) { _mount(target, anchor) {
this._fragment.mount(this.shadowRoot, null); this._fragment.mount(this.shadowRoot, null);
target.insertBefore(this, anchor); target.insertBefore(this, anchor);

@ -1,30 +1,30 @@
import { appendNode, assign, createElement, createText, detachNode, insertNode, noop, proto } from "svelte/shared.js"; import { appendNode, assign, createElement, createText, detachNode, insertNode, noop, proto } from "svelte/shared.js";
function create_main_fragment ( state, component ) { function create_main_fragment(state, component) {
var h1, text, text_1, text_2; var h1, text, text_1, text_2;
return { return {
create: function () { create: function() {
h1 = createElement( 'h1' ); h1 = createElement( 'h1' );
text = createText( "Hello " ); text = createText("Hello ");
text_1 = createText( state.name ); text_1 = createText(state.name);
text_2 = createText( "!" ); text_2 = createText("!");
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( h1, target, anchor ); insertNode( h1, target, anchor );
appendNode( text, h1 ); appendNode(text, h1);
appendNode( text_1, h1 ); appendNode(text_1, h1);
appendNode( text_2, h1 ); appendNode(text_2, h1);
}, },
update: function ( changed, state ) { update: function(changed, state) {
if ( changed.name ) { if ( changed.name ) {
text_1.data = state.name; text_1.data = state.name;
} }
}, },
unmount: function () { unmount: function() {
detachNode( h1 ); detachNode( h1 );
}, },
@ -39,11 +39,11 @@ class SvelteComponent extends HTMLElement {
this._state = options.data || {}; this._state = options.data || {};
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
this._root = options._root || this; this._root = options._root || this;
this._yield = options._yield; this._yield = options._yield;
@ -52,11 +52,11 @@ class SvelteComponent extends HTMLElement {
this.attachShadow({ mode: 'open' }); this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `<style>h1{color:red}</style>`; this.shadowRoot.innerHTML = `<style>h1{color:red}</style>`;
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
this._fragment.create(); this._fragment.create();
this._mount( options.target, options.anchor || null ); this._mount(options.target, options.anchor || null);
} }
} }
@ -72,13 +72,13 @@ class SvelteComponent extends HTMLElement {
this.set({ name: value }); this.set({ name: value });
} }
attributeChangedCallback ( attr, oldValue, newValue ) { attributeChangedCallback(attr, oldValue, newValue) {
this.set({ [attr]: newValue }); this.set({ [attr]: newValue });
} }
} }
customElements.define('custom-element', SvelteComponent); customElements.define("custom-element", SvelteComponent);
assign( SvelteComponent.prototype, proto , { assign(SvelteComponent.prototype, proto , {
_mount(target, anchor) { _mount(target, anchor) {
this._fragment.mount(this.shadowRoot, null); this._fragment.mount(this.shadowRoot, null);
target.insertBefore(this, anchor); target.insertBefore(this, anchor);

@ -184,53 +184,53 @@ var proto = {
_unmount: _unmount _unmount: _unmount
}; };
function create_main_fragment ( state, component ) { function create_main_fragment(state, component) {
var text, p, text_1; var text, p, text_1;
var each_block_value = state.comments; var each_block_value = state.comments;
var each_block_iterations = []; var each_block_iterations = [];
for ( var i = 0; i < each_block_value.length; i += 1 ) { for (var i = 0; i < each_block_value.length; i += 1) {
each_block_iterations[i] = create_each_block( state, each_block_value, each_block_value[i], i, component ); each_block_iterations[i] = create_each_block(state, each_block_value, each_block_value[i], i, component);
} }
return { return {
create: function () { create: function() {
for ( var i = 0; i < each_block_iterations.length; i += 1 ) { for (var i = 0; i < each_block_iterations.length; i += 1) {
each_block_iterations[i].create(); each_block_iterations[i].create();
} }
text = createText( "\n\n" ); text = createText("\n\n");
p = createElement( 'p' ); p = createElement( 'p' );
text_1 = createText( state.foo ); text_1 = createText(state.foo);
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
for ( var i = 0; i < each_block_iterations.length; i += 1 ) { for (var i = 0; i < each_block_iterations.length; i += 1) {
each_block_iterations[i].mount( target, anchor ); each_block_iterations[i].mount(target, anchor);
} }
insertNode( text, target, anchor ); insertNode(text, target, anchor);
insertNode( p, target, anchor ); insertNode( p, target, anchor );
appendNode( text_1, p ); appendNode(text_1, p);
}, },
update: function ( changed, state ) { update: function(changed, state) {
var each_block_value = state.comments; var each_block_value = state.comments;
if ( changed.comments || changed.elapsed || changed.time ) { if (changed.comments || changed.elapsed || changed.time) {
for ( var i = 0; i < each_block_value.length; i += 1 ) { for (var i = 0; i < each_block_value.length; i += 1) {
if ( each_block_iterations[i] ) { if (each_block_iterations[i]) {
each_block_iterations[i].update( changed, state, each_block_value, each_block_value[i], i ); each_block_iterations[i].update(changed, state, each_block_value, each_block_value[i], i);
} else { } else {
each_block_iterations[i] = create_each_block( state, each_block_value, each_block_value[i], i, component ); each_block_iterations[i] = create_each_block(state, each_block_value, each_block_value[i], i, component);
each_block_iterations[i].create(); each_block_iterations[i].create();
each_block_iterations[i].mount( text.parentNode, text ); each_block_iterations[i].mount(text.parentNode, text);
} }
} }
for ( ; i < each_block_iterations.length; i += 1 ) { for (; i < each_block_iterations.length; i += 1) {
each_block_iterations[i].unmount(); each_block_iterations[i].unmount();
each_block_iterations[i].destroy(); each_block_iterations[i].destroy();
} }
@ -242,76 +242,76 @@ function create_main_fragment ( state, component ) {
} }
}, },
unmount: function () { unmount: function() {
for ( var i = 0; i < each_block_iterations.length; i += 1 ) { for (var i = 0; i < each_block_iterations.length; i += 1) {
each_block_iterations[i].unmount(); each_block_iterations[i].unmount();
} }
detachNode( text ); detachNode(text);
detachNode( p ); detachNode( p );
}, },
destroy: function () { destroy: function() {
destroyEach( each_block_iterations, false, 0 ); destroyEach(each_block_iterations, false, 0);
} }
}; };
} }
function create_each_block ( state, each_block_value, comment, i, component ) { function create_each_block(state, each_block_value, comment, i, component) {
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; 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 { return {
create: function () { create: function() {
div = createElement( 'div' ); div = createElement( 'div' );
strong = createElement( 'strong' ); strong = createElement( 'strong' );
text = createText( i ); text = createText(i);
text_1 = createText( "\n\n\t\t" ); text_1 = createText("\n\n\t\t");
span = createElement( 'span' ); span = createElement( 'span' );
text_2 = createText( text_2_value ); text_2 = createText(text_2_value);
text_3 = createText( " wrote " ); text_3 = createText(" wrote ");
text_4 = createText( text_4_value ); text_4 = createText(text_4_value);
text_5 = createText( " ago:" ); text_5 = createText(" ago:");
text_6 = createText( "\n\n\t\t" ); text_6 = createText("\n\n\t\t");
raw_before = createElement( 'noscript' ); raw_before = createElement('noscript');
this.hydrate(); this.hydrate();
}, },
hydrate: function ( nodes ) { hydrate: function(nodes) {
div.className = "comment"; div.className = "comment";
span.className = "meta"; span.className = "meta";
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( div, target, anchor ); insertNode( div, target, anchor );
appendNode( strong, div ); appendNode( strong, div );
appendNode( text, strong ); appendNode(text, strong);
appendNode( text_1, div ); appendNode(text_1, div);
appendNode( span, div ); appendNode( span, div );
appendNode( text_2, span ); appendNode(text_2, span);
appendNode( text_3, span ); appendNode(text_3, span);
appendNode( text_4, span ); appendNode(text_4, span);
appendNode( text_5, span ); appendNode(text_5, span);
appendNode( text_6, div ); appendNode(text_6, div);
appendNode( raw_before, div ); appendNode(raw_before, div);
raw_before.insertAdjacentHTML('afterend', raw_value); raw_before.insertAdjacentHTML("afterend", raw_value);
}, },
update: function ( changed, state, each_block_value, comment, i ) { update: function(changed, state, each_block_value, comment, i) {
if ( ( changed.comments ) && text_2_value !== ( text_2_value = comment.author ) ) { if ( (changed.comments) && text_2_value !== (text_2_value = comment.author) ) {
text_2.data = text_2_value; text_2.data = text_2_value;
} }
if ( ( changed.elapsed || changed.comments || changed.time ) && text_4_value !== ( text_4_value = state.elapsed(comment.time, state.time) ) ) { if ( (changed.elapsed || changed.comments || changed.time) && text_4_value !== (text_4_value = state.elapsed(comment.time, state.time)) ) {
text_4.data = text_4_value; text_4.data = text_4_value;
} }
if ( ( changed.comments ) && raw_value !== ( raw_value = comment.html ) ) { if ( (changed.comments) && raw_value !== (raw_value = comment.html) ) {
detachAfter(raw_before); detachAfter(raw_before);
raw_before.insertAdjacentHTML('afterend', raw_value); raw_before.insertAdjacentHTML("afterend", raw_value);
} }
}, },
unmount: function () { unmount: function() {
detachAfter(raw_before); detachAfter(raw_before);
detachNode( div ); detachNode( div );
@ -321,29 +321,29 @@ function create_each_block ( state, each_block_value, comment, i, component ) {
}; };
} }
function SvelteComponent ( options ) { function SvelteComponent(options) {
this.options = options; this.options = options;
this._state = options.data || {}; this._state = options.data || {};
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
this._root = options._root || this; this._root = options._root || this;
this._yield = options._yield; this._yield = options._yield;
this._bind = options._bind; this._bind = options._bind;
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, options.anchor || null ); this._fragment.mount(options.target, options.anchor || null);
} }
} }
assign( SvelteComponent.prototype, proto ); assign(SvelteComponent.prototype, proto );
export default SvelteComponent; export default SvelteComponent;

@ -1,52 +1,52 @@
import { appendNode, assign, createElement, createText, destroyEach, detachAfter, detachNode, insertNode, noop, proto } from "svelte/shared.js"; import { appendNode, assign, createElement, createText, destroyEach, detachAfter, detachNode, insertNode, noop, proto } from "svelte/shared.js";
function create_main_fragment ( state, component ) { function create_main_fragment(state, component) {
var text, p, text_1; var text, p, text_1;
var each_block_value = state.comments; var each_block_value = state.comments;
var each_block_iterations = []; var each_block_iterations = [];
for ( var i = 0; i < each_block_value.length; i += 1 ) { for (var i = 0; i < each_block_value.length; i += 1) {
each_block_iterations[i] = create_each_block( state, each_block_value, each_block_value[i], i, component ); each_block_iterations[i] = create_each_block(state, each_block_value, each_block_value[i], i, component);
} }
return { return {
create: function () { create: function() {
for ( var i = 0; i < each_block_iterations.length; i += 1 ) { for (var i = 0; i < each_block_iterations.length; i += 1) {
each_block_iterations[i].create(); each_block_iterations[i].create();
} }
text = createText( "\n\n" ); text = createText("\n\n");
p = createElement( 'p' ); p = createElement( 'p' );
text_1 = createText( state.foo ); text_1 = createText(state.foo);
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
for ( var i = 0; i < each_block_iterations.length; i += 1 ) { for (var i = 0; i < each_block_iterations.length; i += 1) {
each_block_iterations[i].mount( target, anchor ); each_block_iterations[i].mount(target, anchor);
} }
insertNode( text, target, anchor ); insertNode(text, target, anchor);
insertNode( p, target, anchor ); insertNode( p, target, anchor );
appendNode( text_1, p ); appendNode(text_1, p);
}, },
update: function ( changed, state ) { update: function(changed, state) {
var each_block_value = state.comments; var each_block_value = state.comments;
if ( changed.comments || changed.elapsed || changed.time ) { if (changed.comments || changed.elapsed || changed.time) {
for ( var i = 0; i < each_block_value.length; i += 1 ) { for (var i = 0; i < each_block_value.length; i += 1) {
if ( each_block_iterations[i] ) { if (each_block_iterations[i]) {
each_block_iterations[i].update( changed, state, each_block_value, each_block_value[i], i ); each_block_iterations[i].update(changed, state, each_block_value, each_block_value[i], i);
} else { } else {
each_block_iterations[i] = create_each_block( state, each_block_value, each_block_value[i], i, component ); each_block_iterations[i] = create_each_block(state, each_block_value, each_block_value[i], i, component);
each_block_iterations[i].create(); each_block_iterations[i].create();
each_block_iterations[i].mount( text.parentNode, text ); each_block_iterations[i].mount(text.parentNode, text);
} }
} }
for ( ; i < each_block_iterations.length; i += 1 ) { for (; i < each_block_iterations.length; i += 1) {
each_block_iterations[i].unmount(); each_block_iterations[i].unmount();
each_block_iterations[i].destroy(); each_block_iterations[i].destroy();
} }
@ -58,76 +58,76 @@ function create_main_fragment ( state, component ) {
} }
}, },
unmount: function () { unmount: function() {
for ( var i = 0; i < each_block_iterations.length; i += 1 ) { for (var i = 0; i < each_block_iterations.length; i += 1) {
each_block_iterations[i].unmount(); each_block_iterations[i].unmount();
} }
detachNode( text ); detachNode(text);
detachNode( p ); detachNode( p );
}, },
destroy: function () { destroy: function() {
destroyEach( each_block_iterations, false, 0 ); destroyEach(each_block_iterations, false, 0);
} }
}; };
} }
function create_each_block ( state, each_block_value, comment, i, component ) { function create_each_block(state, each_block_value, comment, i, component) {
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; 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 { return {
create: function () { create: function() {
div = createElement( 'div' ); div = createElement( 'div' );
strong = createElement( 'strong' ); strong = createElement( 'strong' );
text = createText( i ); text = createText(i);
text_1 = createText( "\n\n\t\t" ); text_1 = createText("\n\n\t\t");
span = createElement( 'span' ); span = createElement( 'span' );
text_2 = createText( text_2_value ); text_2 = createText(text_2_value);
text_3 = createText( " wrote " ); text_3 = createText(" wrote ");
text_4 = createText( text_4_value ); text_4 = createText(text_4_value);
text_5 = createText( " ago:" ); text_5 = createText(" ago:");
text_6 = createText( "\n\n\t\t" ); text_6 = createText("\n\n\t\t");
raw_before = createElement( 'noscript' ); raw_before = createElement('noscript');
this.hydrate(); this.hydrate();
}, },
hydrate: function ( nodes ) { hydrate: function(nodes) {
div.className = "comment"; div.className = "comment";
span.className = "meta"; span.className = "meta";
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( div, target, anchor ); insertNode( div, target, anchor );
appendNode( strong, div ); appendNode( strong, div );
appendNode( text, strong ); appendNode(text, strong);
appendNode( text_1, div ); appendNode(text_1, div);
appendNode( span, div ); appendNode( span, div );
appendNode( text_2, span ); appendNode(text_2, span);
appendNode( text_3, span ); appendNode(text_3, span);
appendNode( text_4, span ); appendNode(text_4, span);
appendNode( text_5, span ); appendNode(text_5, span);
appendNode( text_6, div ); appendNode(text_6, div);
appendNode( raw_before, div ); appendNode(raw_before, div);
raw_before.insertAdjacentHTML('afterend', raw_value); raw_before.insertAdjacentHTML("afterend", raw_value);
}, },
update: function ( changed, state, each_block_value, comment, i ) { update: function(changed, state, each_block_value, comment, i) {
if ( ( changed.comments ) && text_2_value !== ( text_2_value = comment.author ) ) { if ( (changed.comments) && text_2_value !== (text_2_value = comment.author) ) {
text_2.data = text_2_value; text_2.data = text_2_value;
} }
if ( ( changed.elapsed || changed.comments || changed.time ) && text_4_value !== ( text_4_value = state.elapsed(comment.time, state.time) ) ) { if ( (changed.elapsed || changed.comments || changed.time) && text_4_value !== (text_4_value = state.elapsed(comment.time, state.time)) ) {
text_4.data = text_4_value; text_4.data = text_4_value;
} }
if ( ( changed.comments ) && raw_value !== ( raw_value = comment.html ) ) { if ( (changed.comments) && raw_value !== (raw_value = comment.html) ) {
detachAfter(raw_before); detachAfter(raw_before);
raw_before.insertAdjacentHTML('afterend', raw_value); raw_before.insertAdjacentHTML("afterend", raw_value);
} }
}, },
unmount: function () { unmount: function() {
detachAfter(raw_before); detachAfter(raw_before);
detachNode( div ); detachNode( div );
@ -137,29 +137,29 @@ function create_each_block ( state, each_block_value, comment, i, component ) {
}; };
} }
function SvelteComponent ( options ) { function SvelteComponent(options) {
this.options = options; this.options = options;
this._state = options.data || {}; this._state = options.data || {};
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
this._root = options._root || this; this._root = options._root || this;
this._yield = options._yield; this._yield = options._yield;
this._bind = options._bind; this._bind = options._bind;
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, options.anchor || null ); this._fragment.mount(options.target, options.anchor || null);
} }
} }
assign( SvelteComponent.prototype, proto ); assign(SvelteComponent.prototype, proto );
export default SvelteComponent; export default SvelteComponent;

@ -171,7 +171,7 @@ var proto = {
_unmount: _unmount _unmount: _unmount
}; };
var template = (function () { var template = (function() {
return { return {
methods: { methods: {
foo ( bar ) { foo ( bar ) {
@ -186,63 +186,63 @@ var template = (function () {
}; };
}()); }());
function create_main_fragment ( state, component ) { function create_main_fragment(state, component) {
var button, foo_handler, text; var button, foo_handler, text;
return { return {
create: function () { create: function() {
button = createElement( 'button' ); button = createElement( 'button' );
text = createText( "foo" ); text = createText("foo");
this.hydrate(); this.hydrate();
}, },
hydrate: function ( nodes ) { hydrate: function(nodes) {
foo_handler = template.events.foo.call( component, button, function ( event ) { foo_handler = template.events.foo.call(component, button, function(event) {
var state = component.get(); var state = component.get();
component.foo( state.bar ); component.foo( state.bar );
}); });
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( button, target, anchor ); insertNode( button, target, anchor );
appendNode( text, button ); appendNode(text, button);
}, },
update: noop, update: noop,
unmount: function () { unmount: function() {
detachNode( button ); detachNode( button );
}, },
destroy: function () { destroy: function() {
foo_handler.teardown(); foo_handler.teardown();
} }
}; };
} }
function SvelteComponent ( options ) { function SvelteComponent(options) {
this.options = options; this.options = options;
this._state = options.data || {}; this._state = options.data || {};
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
this._root = options._root || this; this._root = options._root || this;
this._yield = options._yield; this._yield = options._yield;
this._bind = options._bind; this._bind = options._bind;
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, options.anchor || null ); this._fragment.mount(options.target, options.anchor || null);
} }
} }
assign( SvelteComponent.prototype, template.methods, proto ); assign(SvelteComponent.prototype, template.methods, proto );
export default SvelteComponent; export default SvelteComponent;

@ -1,6 +1,6 @@
import { appendNode, assign, createElement, createText, detachNode, insertNode, noop, proto } from "svelte/shared.js"; import { appendNode, assign, createElement, createText, detachNode, insertNode, noop, proto } from "svelte/shared.js";
var template = (function () { var template = (function() {
return { return {
methods: { methods: {
foo ( bar ) { foo ( bar ) {
@ -15,63 +15,63 @@ var template = (function () {
}; };
}()); }());
function create_main_fragment ( state, component ) { function create_main_fragment(state, component) {
var button, foo_handler, text; var button, foo_handler, text;
return { return {
create: function () { create: function() {
button = createElement( 'button' ); button = createElement( 'button' );
text = createText( "foo" ); text = createText("foo");
this.hydrate(); this.hydrate();
}, },
hydrate: function ( nodes ) { hydrate: function(nodes) {
foo_handler = template.events.foo.call( component, button, function ( event ) { foo_handler = template.events.foo.call(component, button, function(event) {
var state = component.get(); var state = component.get();
component.foo( state.bar ); component.foo( state.bar );
}); });
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( button, target, anchor ); insertNode( button, target, anchor );
appendNode( text, button ); appendNode(text, button);
}, },
update: noop, update: noop,
unmount: function () { unmount: function() {
detachNode( button ); detachNode( button );
}, },
destroy: function () { destroy: function() {
foo_handler.teardown(); foo_handler.teardown();
} }
}; };
} }
function SvelteComponent ( options ) { function SvelteComponent(options) {
this.options = options; this.options = options;
this._state = options.data || {}; this._state = options.data || {};
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
this._root = options._root || this; this._root = options._root || this;
this._yield = options._yield; this._yield = options._yield;
this._bind = options._bind; this._bind = options._bind;
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, options.anchor || null ); this._fragment.mount(options.target, options.anchor || null);
} }
} }
assign( SvelteComponent.prototype, template.methods, proto ); assign(SvelteComponent.prototype, template.methods, proto );
export default SvelteComponent; export default SvelteComponent;

@ -175,59 +175,59 @@ var proto = {
_unmount: _unmount _unmount: _unmount
}; };
function create_main_fragment ( state, component ) { function create_main_fragment(state, component) {
var if_block_anchor; var if_block_anchor;
var current_block_type = select_block_type( state ); var current_block_type = select_block_type(state);
var if_block = current_block_type( state, component ); var if_block = current_block_type(state, component);
return { return {
create: function () { create: function() {
if_block.create(); if_block.create();
if_block_anchor = createComment(); if_block_anchor = createComment();
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
if_block.mount( target, anchor ); if_block.mount(target, anchor);
insertNode( if_block_anchor, target, anchor ); insertNode(if_block_anchor, target, anchor);
}, },
update: function ( changed, state ) { update: function(changed, state) {
if ( current_block_type !== ( current_block_type = select_block_type( state ) ) ) { if (current_block_type !== (current_block_type = select_block_type(state))) {
if_block.unmount(); if_block.unmount();
if_block.destroy(); if_block.destroy();
if_block = current_block_type( state, component ); if_block = current_block_type(state, component);
if_block.create(); if_block.create();
if_block.mount( if_block_anchor.parentNode, if_block_anchor ); if_block.mount(if_block_anchor.parentNode, if_block_anchor);
} }
}, },
unmount: function () { unmount: function() {
if_block.unmount(); if_block.unmount();
detachNode( if_block_anchor ); detachNode(if_block_anchor);
}, },
destroy: function () { destroy: function() {
if_block.destroy(); if_block.destroy();
} }
}; };
} }
function create_if_block ( state, component ) { function create_if_block(state, component) {
var p, text; var p, text;
return { return {
create: function () { create: function() {
p = createElement( 'p' ); p = createElement( 'p' );
text = createText( "foo!" ); text = createText("foo!");
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( p, target, anchor ); insertNode( p, target, anchor );
appendNode( text, p ); appendNode(text, p);
}, },
unmount: function () { unmount: function() {
detachNode( p ); detachNode( p );
}, },
@ -235,21 +235,21 @@ function create_if_block ( state, component ) {
}; };
} }
function create_if_block_1 ( state, component ) { function create_if_block_1(state, component) {
var p, text; var p, text;
return { return {
create: function () { create: function() {
p = createElement( 'p' ); p = createElement( 'p' );
text = createText( "not foo!" ); text = createText("not foo!");
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( p, target, anchor ); insertNode( p, target, anchor );
appendNode( text, p ); appendNode(text, p);
}, },
unmount: function () { unmount: function() {
detachNode( p ); detachNode( p );
}, },
@ -257,34 +257,34 @@ function create_if_block_1 ( state, component ) {
}; };
} }
function select_block_type ( state ) { function select_block_type(state) {
if ( state.foo ) return create_if_block; if (state.foo) return create_if_block;
return create_if_block_1; return create_if_block_1;
} }
function SvelteComponent ( options ) { function SvelteComponent(options) {
this.options = options; this.options = options;
this._state = options.data || {}; this._state = options.data || {};
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
this._root = options._root || this; this._root = options._root || this;
this._yield = options._yield; this._yield = options._yield;
this._bind = options._bind; this._bind = options._bind;
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, options.anchor || null ); this._fragment.mount(options.target, options.anchor || null);
} }
} }
assign( SvelteComponent.prototype, proto ); assign(SvelteComponent.prototype, proto );
export default SvelteComponent; export default SvelteComponent;

@ -1,58 +1,58 @@
import { appendNode, assign, createComment, createElement, createText, detachNode, insertNode, noop, proto } from "svelte/shared.js"; import { appendNode, assign, createComment, createElement, createText, detachNode, insertNode, noop, proto } from "svelte/shared.js";
function create_main_fragment ( state, component ) { function create_main_fragment(state, component) {
var if_block_anchor; var if_block_anchor;
var current_block_type = select_block_type( state ); var current_block_type = select_block_type(state);
var if_block = current_block_type( state, component ); var if_block = current_block_type(state, component);
return { return {
create: function () { create: function() {
if_block.create(); if_block.create();
if_block_anchor = createComment(); if_block_anchor = createComment();
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
if_block.mount( target, anchor ); if_block.mount(target, anchor);
insertNode( if_block_anchor, target, anchor ); insertNode(if_block_anchor, target, anchor);
}, },
update: function ( changed, state ) { update: function(changed, state) {
if ( current_block_type !== ( current_block_type = select_block_type( state ) ) ) { if (current_block_type !== (current_block_type = select_block_type(state))) {
if_block.unmount(); if_block.unmount();
if_block.destroy(); if_block.destroy();
if_block = current_block_type( state, component ); if_block = current_block_type(state, component);
if_block.create(); if_block.create();
if_block.mount( if_block_anchor.parentNode, if_block_anchor ); if_block.mount(if_block_anchor.parentNode, if_block_anchor);
} }
}, },
unmount: function () { unmount: function() {
if_block.unmount(); if_block.unmount();
detachNode( if_block_anchor ); detachNode(if_block_anchor);
}, },
destroy: function () { destroy: function() {
if_block.destroy(); if_block.destroy();
} }
}; };
} }
function create_if_block ( state, component ) { function create_if_block(state, component) {
var p, text; var p, text;
return { return {
create: function () { create: function() {
p = createElement( 'p' ); p = createElement( 'p' );
text = createText( "foo!" ); text = createText("foo!");
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( p, target, anchor ); insertNode( p, target, anchor );
appendNode( text, p ); appendNode(text, p);
}, },
unmount: function () { unmount: function() {
detachNode( p ); detachNode( p );
}, },
@ -60,21 +60,21 @@ function create_if_block ( state, component ) {
}; };
} }
function create_if_block_1 ( state, component ) { function create_if_block_1(state, component) {
var p, text; var p, text;
return { return {
create: function () { create: function() {
p = createElement( 'p' ); p = createElement( 'p' );
text = createText( "not foo!" ); text = createText("not foo!");
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( p, target, anchor ); insertNode( p, target, anchor );
appendNode( text, p ); appendNode(text, p);
}, },
unmount: function () { unmount: function() {
detachNode( p ); detachNode( p );
}, },
@ -82,34 +82,34 @@ function create_if_block_1 ( state, component ) {
}; };
} }
function select_block_type ( state ) { function select_block_type(state) {
if ( state.foo ) return create_if_block; if (state.foo) return create_if_block;
return create_if_block_1; return create_if_block_1;
} }
function SvelteComponent ( options ) { function SvelteComponent(options) {
this.options = options; this.options = options;
this._state = options.data || {}; this._state = options.data || {};
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
this._root = options._root || this; this._root = options._root || this;
this._yield = options._yield; this._yield = options._yield;
this._bind = options._bind; this._bind = options._bind;
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, options.anchor || null ); this._fragment.mount(options.target, options.anchor || null);
} }
} }
assign( SvelteComponent.prototype, proto ); assign(SvelteComponent.prototype, proto );
export default SvelteComponent; export default SvelteComponent;

@ -175,62 +175,62 @@ var proto = {
_unmount: _unmount _unmount: _unmount
}; };
function create_main_fragment ( state, component ) { function create_main_fragment(state, component) {
var if_block_anchor; var if_block_anchor;
var if_block = (state.foo) && create_if_block( state, component ); var if_block = (state.foo) && create_if_block(state, component);
return { return {
create: function () { create: function() {
if ( if_block ) if_block.create(); if (if_block) if_block.create();
if_block_anchor = createComment(); if_block_anchor = createComment();
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
if ( if_block ) if_block.mount( target, anchor ); if (if_block) if_block.mount(target, anchor);
insertNode( if_block_anchor, target, anchor ); insertNode(if_block_anchor, target, anchor);
}, },
update: function ( changed, state ) { update: function(changed, state) {
if ( state.foo ) { if (state.foo) {
if ( !if_block ) { if (!if_block) {
if_block = create_if_block( state, component ); if_block = create_if_block(state, component);
if_block.create(); if_block.create();
if_block.mount( if_block_anchor.parentNode, if_block_anchor ); if_block.mount(if_block_anchor.parentNode, if_block_anchor);
} }
} else if ( if_block ) { } else if (if_block) {
if_block.unmount(); if_block.unmount();
if_block.destroy(); if_block.destroy();
if_block = null; if_block = null;
} }
}, },
unmount: function () { unmount: function() {
if ( if_block ) if_block.unmount(); if (if_block) if_block.unmount();
detachNode( if_block_anchor ); detachNode(if_block_anchor);
}, },
destroy: function () { destroy: function() {
if ( if_block ) if_block.destroy(); if (if_block) if_block.destroy();
} }
}; };
} }
function create_if_block ( state, component ) { function create_if_block(state, component) {
var p, text; var p, text;
return { return {
create: function () { create: function() {
p = createElement( 'p' ); p = createElement( 'p' );
text = createText( "foo!" ); text = createText("foo!");
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( p, target, anchor ); insertNode( p, target, anchor );
appendNode( text, p ); appendNode(text, p);
}, },
unmount: function () { unmount: function() {
detachNode( p ); detachNode( p );
}, },
@ -238,29 +238,29 @@ function create_if_block ( state, component ) {
}; };
} }
function SvelteComponent ( options ) { function SvelteComponent(options) {
this.options = options; this.options = options;
this._state = options.data || {}; this._state = options.data || {};
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
this._root = options._root || this; this._root = options._root || this;
this._yield = options._yield; this._yield = options._yield;
this._bind = options._bind; this._bind = options._bind;
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, options.anchor || null ); this._fragment.mount(options.target, options.anchor || null);
} }
} }
assign( SvelteComponent.prototype, proto ); assign(SvelteComponent.prototype, proto );
export default SvelteComponent; export default SvelteComponent;

@ -1,61 +1,61 @@
import { appendNode, assign, createComment, createElement, createText, detachNode, insertNode, noop, proto } from "svelte/shared.js"; import { appendNode, assign, createComment, createElement, createText, detachNode, insertNode, noop, proto } from "svelte/shared.js";
function create_main_fragment ( state, component ) { function create_main_fragment(state, component) {
var if_block_anchor; var if_block_anchor;
var if_block = (state.foo) && create_if_block( state, component ); var if_block = (state.foo) && create_if_block(state, component);
return { return {
create: function () { create: function() {
if ( if_block ) if_block.create(); if (if_block) if_block.create();
if_block_anchor = createComment(); if_block_anchor = createComment();
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
if ( if_block ) if_block.mount( target, anchor ); if (if_block) if_block.mount(target, anchor);
insertNode( if_block_anchor, target, anchor ); insertNode(if_block_anchor, target, anchor);
}, },
update: function ( changed, state ) { update: function(changed, state) {
if ( state.foo ) { if (state.foo) {
if ( !if_block ) { if (!if_block) {
if_block = create_if_block( state, component ); if_block = create_if_block(state, component);
if_block.create(); if_block.create();
if_block.mount( if_block_anchor.parentNode, if_block_anchor ); if_block.mount(if_block_anchor.parentNode, if_block_anchor);
} }
} else if ( if_block ) { } else if (if_block) {
if_block.unmount(); if_block.unmount();
if_block.destroy(); if_block.destroy();
if_block = null; if_block = null;
} }
}, },
unmount: function () { unmount: function() {
if ( if_block ) if_block.unmount(); if (if_block) if_block.unmount();
detachNode( if_block_anchor ); detachNode(if_block_anchor);
}, },
destroy: function () { destroy: function() {
if ( if_block ) if_block.destroy(); if (if_block) if_block.destroy();
} }
}; };
} }
function create_if_block ( state, component ) { function create_if_block(state, component) {
var p, text; var p, text;
return { return {
create: function () { create: function() {
p = createElement( 'p' ); p = createElement( 'p' );
text = createText( "foo!" ); text = createText("foo!");
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( p, target, anchor ); insertNode( p, target, anchor );
appendNode( text, p ); appendNode(text, p);
}, },
unmount: function () { unmount: function() {
detachNode( p ); detachNode( p );
}, },
@ -63,29 +63,29 @@ function create_if_block ( state, component ) {
}; };
} }
function SvelteComponent ( options ) { function SvelteComponent(options) {
this.options = options; this.options = options;
this._state = options.data || {}; this._state = options.data || {};
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
this._root = options._root || this; this._root = options._root || this;
this._yield = options._yield; this._yield = options._yield;
this._bind = options._bind; this._bind = options._bind;
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, options.anchor || null ); this._fragment.mount(options.target, options.anchor || null);
} }
} }
assign( SvelteComponent.prototype, proto ); assign(SvelteComponent.prototype, proto );
export default SvelteComponent; export default SvelteComponent;

@ -167,35 +167,35 @@ var proto = {
_unmount: _unmount _unmount: _unmount
}; };
function create_main_fragment ( state, component ) { function create_main_fragment(state, component) {
var div; var div;
return { return {
create: function () { create: function() {
div = createElement( 'div' ); div = createElement( 'div' );
this.hydrate(); this.hydrate();
}, },
hydrate: function ( nodes ) { hydrate: function(nodes) {
setStyle(div, 'color', state.color); setStyle(div, "color", state.color);
setStyle(div, 'transform', "translate(" + state.x + "px," + state.y + "px)"); setStyle(div, "transform", "translate(" + state.x + "px," + state.y + "px)");
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( div, target, anchor ); insertNode( div, target, anchor );
}, },
update: function ( changed, state ) { update: function(changed, state) {
if ( changed.color ) { if ( changed.color ) {
setStyle(div, 'color', state.color); setStyle(div, "color", state.color);
} }
if ( changed.x || changed.y ) { if ( changed.x || changed.y ) {
setStyle(div, 'transform', "translate(" + state.x + "px," + state.y + "px)"); setStyle(div, "transform", "translate(" + state.x + "px," + state.y + "px)");
} }
}, },
unmount: function () { unmount: function() {
detachNode( div ); detachNode( div );
}, },
@ -203,29 +203,29 @@ function create_main_fragment ( state, component ) {
}; };
} }
function SvelteComponent ( options ) { function SvelteComponent(options) {
this.options = options; this.options = options;
this._state = options.data || {}; this._state = options.data || {};
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
this._root = options._root || this; this._root = options._root || this;
this._yield = options._yield; this._yield = options._yield;
this._bind = options._bind; this._bind = options._bind;
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, options.anchor || null ); this._fragment.mount(options.target, options.anchor || null);
} }
} }
assign( SvelteComponent.prototype, proto ); assign(SvelteComponent.prototype, proto );
export default SvelteComponent; export default SvelteComponent;

@ -1,34 +1,34 @@
import { assign, createElement, detachNode, insertNode, noop, proto, setStyle } from "svelte/shared.js"; import { assign, createElement, detachNode, insertNode, noop, proto, setStyle } from "svelte/shared.js";
function create_main_fragment ( state, component ) { function create_main_fragment(state, component) {
var div; var div;
return { return {
create: function () { create: function() {
div = createElement( 'div' ); div = createElement( 'div' );
this.hydrate(); this.hydrate();
}, },
hydrate: function ( nodes ) { hydrate: function(nodes) {
setStyle(div, 'color', state.color); setStyle(div, "color", state.color);
setStyle(div, 'transform', "translate(" + state.x + "px," + state.y + "px)"); setStyle(div, "transform", "translate(" + state.x + "px," + state.y + "px)");
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( div, target, anchor ); insertNode( div, target, anchor );
}, },
update: function ( changed, state ) { update: function(changed, state) {
if ( changed.color ) { if ( changed.color ) {
setStyle(div, 'color', state.color); setStyle(div, "color", state.color);
} }
if ( changed.x || changed.y ) { if ( changed.x || changed.y ) {
setStyle(div, 'transform', "translate(" + state.x + "px," + state.y + "px)"); setStyle(div, "transform", "translate(" + state.x + "px," + state.y + "px)");
} }
}, },
unmount: function () { unmount: function() {
detachNode( div ); detachNode( div );
}, },
@ -36,29 +36,29 @@ function create_main_fragment ( state, component ) {
}; };
} }
function SvelteComponent ( options ) { function SvelteComponent(options) {
this.options = options; this.options = options;
this._state = options.data || {}; this._state = options.data || {};
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
this._root = options._root || this; this._root = options._root || this;
this._yield = options._yield; this._yield = options._yield;
this._bind = options._bind; this._bind = options._bind;
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, options.anchor || null ); this._fragment.mount(options.target, options.anchor || null);
} }
} }
assign( SvelteComponent.prototype, proto ); assign(SvelteComponent.prototype, proto );
export default SvelteComponent; export default SvelteComponent;

@ -167,30 +167,30 @@ var proto = {
_unmount: _unmount _unmount: _unmount
}; };
function create_main_fragment ( state, component ) { function create_main_fragment(state, component) {
var div; var div;
return { return {
create: function () { create: function() {
div = createElement( 'div' ); div = createElement( 'div' );
this.hydrate(); this.hydrate();
}, },
hydrate: function ( nodes ) { hydrate: function(nodes) {
setStyle(div, 'background', "url(data:image/png;base64," + state.data + ")"); setStyle(div, "background", "url(data:image/png;base64," + state.data + ")");
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( div, target, anchor ); insertNode( div, target, anchor );
}, },
update: function ( changed, state ) { update: function(changed, state) {
if ( changed.data ) { if ( changed.data ) {
setStyle(div, 'background', "url(data:image/png;base64," + state.data + ")"); setStyle(div, "background", "url(data:image/png;base64," + state.data + ")");
} }
}, },
unmount: function () { unmount: function() {
detachNode( div ); detachNode( div );
}, },
@ -198,29 +198,29 @@ function create_main_fragment ( state, component ) {
}; };
} }
function SvelteComponent ( options ) { function SvelteComponent(options) {
this.options = options; this.options = options;
this._state = options.data || {}; this._state = options.data || {};
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
this._root = options._root || this; this._root = options._root || this;
this._yield = options._yield; this._yield = options._yield;
this._bind = options._bind; this._bind = options._bind;
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, options.anchor || null ); this._fragment.mount(options.target, options.anchor || null);
} }
} }
assign( SvelteComponent.prototype, proto ); assign(SvelteComponent.prototype, proto );
export default SvelteComponent; export default SvelteComponent;

@ -1,29 +1,29 @@
import { assign, createElement, detachNode, insertNode, noop, proto, setStyle } from "svelte/shared.js"; import { assign, createElement, detachNode, insertNode, noop, proto, setStyle } from "svelte/shared.js";
function create_main_fragment ( state, component ) { function create_main_fragment(state, component) {
var div; var div;
return { return {
create: function () { create: function() {
div = createElement( 'div' ); div = createElement( 'div' );
this.hydrate(); this.hydrate();
}, },
hydrate: function ( nodes ) { hydrate: function(nodes) {
setStyle(div, 'background', "url(data:image/png;base64," + state.data + ")"); setStyle(div, "background", "url(data:image/png;base64," + state.data + ")");
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( div, target, anchor ); insertNode( div, target, anchor );
}, },
update: function ( changed, state ) { update: function(changed, state) {
if ( changed.data ) { if ( changed.data ) {
setStyle(div, 'background', "url(data:image/png;base64," + state.data + ")"); setStyle(div, "background", "url(data:image/png;base64," + state.data + ")");
} }
}, },
unmount: function () { unmount: function() {
detachNode( div ); detachNode( div );
}, },
@ -31,29 +31,29 @@ function create_main_fragment ( state, component ) {
}; };
} }
function SvelteComponent ( options ) { function SvelteComponent(options) {
this.options = options; this.options = options;
this._state = options.data || {}; this._state = options.data || {};
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
this._root = options._root || this; this._root = options._root || this;
this._yield = options._yield; this._yield = options._yield;
this._bind = options._bind; this._bind = options._bind;
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, options.anchor || null ); this._fragment.mount(options.target, options.anchor || null);
} }
} }
assign( SvelteComponent.prototype, proto ); assign(SvelteComponent.prototype, proto );
export default SvelteComponent; export default SvelteComponent;

@ -167,30 +167,30 @@ var proto = {
_unmount: _unmount _unmount: _unmount
}; };
function create_main_fragment ( state, component ) { function create_main_fragment(state, component) {
var div; var div;
return { return {
create: function () { create: function() {
div = createElement( 'div' ); div = createElement( 'div' );
this.hydrate(); this.hydrate();
}, },
hydrate: function ( nodes ) { hydrate: function(nodes) {
setStyle(div, 'color', state.color); setStyle(div, "color", state.color);
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( div, target, anchor ); insertNode( div, target, anchor );
}, },
update: function ( changed, state ) { update: function(changed, state) {
if ( changed.color ) { if ( changed.color ) {
setStyle(div, 'color', state.color); setStyle(div, "color", state.color);
} }
}, },
unmount: function () { unmount: function() {
detachNode( div ); detachNode( div );
}, },
@ -198,29 +198,29 @@ function create_main_fragment ( state, component ) {
}; };
} }
function SvelteComponent ( options ) { function SvelteComponent(options) {
this.options = options; this.options = options;
this._state = options.data || {}; this._state = options.data || {};
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
this._root = options._root || this; this._root = options._root || this;
this._yield = options._yield; this._yield = options._yield;
this._bind = options._bind; this._bind = options._bind;
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, options.anchor || null ); this._fragment.mount(options.target, options.anchor || null);
} }
} }
assign( SvelteComponent.prototype, proto ); assign(SvelteComponent.prototype, proto );
export default SvelteComponent; export default SvelteComponent;

@ -1,29 +1,29 @@
import { assign, createElement, detachNode, insertNode, noop, proto, setStyle } from "svelte/shared.js"; import { assign, createElement, detachNode, insertNode, noop, proto, setStyle } from "svelte/shared.js";
function create_main_fragment ( state, component ) { function create_main_fragment(state, component) {
var div; var div;
return { return {
create: function () { create: function() {
div = createElement( 'div' ); div = createElement( 'div' );
this.hydrate(); this.hydrate();
}, },
hydrate: function ( nodes ) { hydrate: function(nodes) {
setStyle(div, 'color', state.color); setStyle(div, "color", state.color);
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( div, target, anchor ); insertNode( div, target, anchor );
}, },
update: function ( changed, state ) { update: function(changed, state) {
if ( changed.color ) { if ( changed.color ) {
setStyle(div, 'color', state.color); setStyle(div, "color", state.color);
} }
}, },
unmount: function () { unmount: function() {
detachNode( div ); detachNode( div );
}, },
@ -31,29 +31,29 @@ function create_main_fragment ( state, component ) {
}; };
} }
function SvelteComponent ( options ) { function SvelteComponent(options) {
this.options = options; this.options = options;
this._state = options.data || {}; this._state = options.data || {};
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
this._root = options._root || this; this._root = options._root || this;
this._yield = options._yield; this._yield = options._yield;
this._bind = options._bind; this._bind = options._bind;
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, options.anchor || null ); this._fragment.mount(options.target, options.anchor || null);
} }
} }
assign( SvelteComponent.prototype, proto ); assign(SvelteComponent.prototype, proto );
export default SvelteComponent; export default SvelteComponent;

@ -167,41 +167,41 @@ var proto = {
_unmount: _unmount _unmount: _unmount
}; };
function create_main_fragment ( state, component ) { function create_main_fragment(state, component) {
var div, text, div_1, div_1_style_value; var div, text, div_1, div_1_style_value;
return { return {
create: function () { create: function() {
div = createElement( 'div' ); div = createElement( 'div' );
text = createText( "\n" ); text = createText("\n");
div_1 = createElement( 'div' ); div_1 = createElement( 'div' );
this.hydrate(); this.hydrate();
}, },
hydrate: function ( nodes ) { hydrate: function(nodes) {
div.style.cssText = state.style; div.style.cssText = state.style;
div_1.style.cssText = div_1_style_value = "" + ( state.key ) + ": " + ( state.value ); div_1.style.cssText = div_1_style_value = "" + state.key + ": " + state.value;
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( div, target, anchor ); insertNode( div, target, anchor );
insertNode( text, target, anchor ); insertNode(text, target, anchor);
insertNode( div_1, target, anchor ); insertNode( div_1, target, anchor );
}, },
update: function ( changed, state ) { update: function(changed, state) {
if ( changed.style ) { if ( changed.style ) {
div.style.cssText = state.style; div.style.cssText = state.style;
} }
if ( ( changed.key || changed.value ) && div_1_style_value !== ( div_1_style_value = "" + ( state.key ) + ": " + ( state.value ) ) ) { if ( (changed.key || changed.value) && div_1_style_value !== (div_1_style_value = "" + state.key + ": " + state.value) ) {
div_1.style.cssText = div_1_style_value; div_1.style.cssText = div_1_style_value;
} }
}, },
unmount: function () { unmount: function() {
detachNode( div ); detachNode( div );
detachNode( text ); detachNode(text);
detachNode( div_1 ); detachNode( div_1 );
}, },
@ -209,29 +209,29 @@ function create_main_fragment ( state, component ) {
}; };
} }
function SvelteComponent ( options ) { function SvelteComponent(options) {
this.options = options; this.options = options;
this._state = options.data || {}; this._state = options.data || {};
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
this._root = options._root || this; this._root = options._root || this;
this._yield = options._yield; this._yield = options._yield;
this._bind = options._bind; this._bind = options._bind;
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, options.anchor || null ); this._fragment.mount(options.target, options.anchor || null);
} }
} }
assign( SvelteComponent.prototype, proto ); assign(SvelteComponent.prototype, proto );
export default SvelteComponent; export default SvelteComponent;

@ -1,40 +1,40 @@
import { assign, createElement, createText, detachNode, insertNode, noop, proto } from "svelte/shared.js"; import { assign, createElement, createText, detachNode, insertNode, noop, proto } from "svelte/shared.js";
function create_main_fragment ( state, component ) { function create_main_fragment(state, component) {
var div, text, div_1, div_1_style_value; var div, text, div_1, div_1_style_value;
return { return {
create: function () { create: function() {
div = createElement( 'div' ); div = createElement( 'div' );
text = createText( "\n" ); text = createText("\n");
div_1 = createElement( 'div' ); div_1 = createElement( 'div' );
this.hydrate(); this.hydrate();
}, },
hydrate: function ( nodes ) { hydrate: function(nodes) {
div.style.cssText = state.style; div.style.cssText = state.style;
div_1.style.cssText = div_1_style_value = "" + ( state.key ) + ": " + ( state.value ); div_1.style.cssText = div_1_style_value = "" + state.key + ": " + state.value;
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( div, target, anchor ); insertNode( div, target, anchor );
insertNode( text, target, anchor ); insertNode(text, target, anchor);
insertNode( div_1, target, anchor ); insertNode( div_1, target, anchor );
}, },
update: function ( changed, state ) { update: function(changed, state) {
if ( changed.style ) { if ( changed.style ) {
div.style.cssText = state.style; div.style.cssText = state.style;
} }
if ( ( changed.key || changed.value ) && div_1_style_value !== ( div_1_style_value = "" + ( state.key ) + ": " + ( state.value ) ) ) { if ( (changed.key || changed.value) && div_1_style_value !== (div_1_style_value = "" + state.key + ": " + state.value) ) {
div_1.style.cssText = div_1_style_value; div_1.style.cssText = div_1_style_value;
} }
}, },
unmount: function () { unmount: function() {
detachNode( div ); detachNode( div );
detachNode( text ); detachNode(text);
detachNode( div_1 ); detachNode( div_1 );
}, },
@ -42,29 +42,29 @@ function create_main_fragment ( state, component ) {
}; };
} }
function SvelteComponent ( options ) { function SvelteComponent(options) {
this.options = options; this.options = options;
this._state = options.data || {}; this._state = options.data || {};
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
this._root = options._root || this; this._root = options._root || this;
this._yield = options._yield; this._yield = options._yield;
this._bind = options._bind; this._bind = options._bind;
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, options.anchor || null ); this._fragment.mount(options.target, options.anchor || null);
} }
} }
assign( SvelteComponent.prototype, proto ); assign(SvelteComponent.prototype, proto );
export default SvelteComponent; export default SvelteComponent;

@ -169,26 +169,26 @@ var proto = {
_unmount: _unmount _unmount: _unmount
}; };
function create_main_fragment ( state, component ) { function create_main_fragment(state, component) {
var input; var input;
return { return {
create: function () { create: function() {
input = createElement( 'input' ); input = createElement( 'input' );
this.hydrate(); this.hydrate();
}, },
hydrate: function ( nodes ) { hydrate: function(nodes) {
setInputType( input, "search" ); setInputType(input, "search");
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( input, target, anchor ); insertNode( input, target, anchor );
}, },
update: noop, update: noop,
unmount: function () { unmount: function() {
detachNode( input ); detachNode( input );
}, },
@ -196,29 +196,29 @@ function create_main_fragment ( state, component ) {
}; };
} }
function SvelteComponent ( options ) { function SvelteComponent(options) {
this.options = options; this.options = options;
this._state = options.data || {}; this._state = options.data || {};
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
this._root = options._root || this; this._root = options._root || this;
this._yield = options._yield; this._yield = options._yield;
this._bind = options._bind; this._bind = options._bind;
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, options.anchor || null ); this._fragment.mount(options.target, options.anchor || null);
} }
} }
assign( SvelteComponent.prototype, proto ); assign(SvelteComponent.prototype, proto );
export default SvelteComponent; export default SvelteComponent;

@ -1,25 +1,25 @@
import { assign, createElement, detachNode, insertNode, noop, proto, setInputType } from "svelte/shared.js"; import { assign, createElement, detachNode, insertNode, noop, proto, setInputType } from "svelte/shared.js";
function create_main_fragment ( state, component ) { function create_main_fragment(state, component) {
var input; var input;
return { return {
create: function () { create: function() {
input = createElement( 'input' ); input = createElement( 'input' );
this.hydrate(); this.hydrate();
}, },
hydrate: function ( nodes ) { hydrate: function(nodes) {
setInputType( input, "search" ); setInputType(input, "search");
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( input, target, anchor ); insertNode( input, target, anchor );
}, },
update: noop, update: noop,
unmount: function () { unmount: function() {
detachNode( input ); detachNode( input );
}, },
@ -27,29 +27,29 @@ function create_main_fragment ( state, component ) {
}; };
} }
function SvelteComponent ( options ) { function SvelteComponent(options) {
this.options = options; this.options = options;
this._state = options.data || {}; this._state = options.data || {};
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
this._root = options._root || this; this._root = options._root || this;
this._yield = options._yield; this._yield = options._yield;
this._bind = options._bind; this._bind = options._bind;
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, options.anchor || null ); this._fragment.mount(options.target, options.anchor || null);
} }
} }
assign( SvelteComponent.prototype, proto ); assign(SvelteComponent.prototype, proto );
export default SvelteComponent; export default SvelteComponent;

@ -165,7 +165,7 @@ var proto = {
_unmount: _unmount _unmount: _unmount
}; };
var template = (function () { var template = (function() {
return { return {
components: { components: {
NonImported NonImported
@ -173,7 +173,7 @@ var template = (function () {
}; };
}()); }());
function create_main_fragment ( state, component ) { function create_main_fragment(state, component) {
var text; var text;
var imported = new Imported({ var imported = new Imported({
@ -185,59 +185,59 @@ function create_main_fragment ( state, component ) {
}); });
return { return {
create: function () { create: function() {
imported._fragment.create(); imported._fragment.create();
text = createText( "\n" ); text = createText("\n");
nonimported._fragment.create(); nonimported._fragment.create();
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
imported._mount( target, anchor ); imported._mount(target, anchor);
insertNode( text, target, anchor ); insertNode(text, target, anchor);
nonimported._mount( target, anchor ); nonimported._mount(target, anchor);
}, },
update: noop, update: noop,
unmount: function () { unmount: function() {
imported._unmount(); imported._unmount();
detachNode( text ); detachNode(text);
nonimported._unmount(); nonimported._unmount();
}, },
destroy: function () { destroy: function() {
imported.destroy( false ); imported.destroy(false);
nonimported.destroy( false ); nonimported.destroy(false);
} }
}; };
} }
function SvelteComponent ( options ) { function SvelteComponent(options) {
this.options = options; this.options = options;
this._state = options.data || {}; this._state = options.data || {};
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
this._root = options._root || this; this._root = options._root || this;
this._yield = options._yield; this._yield = options._yield;
this._bind = options._bind; this._bind = options._bind;
if ( !options._root ) { if (!options._root) {
this._oncreate = []; this._oncreate = [];
this._beforecreate = []; this._beforecreate = [];
this._aftercreate = []; this._aftercreate = [];
} }
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, options.anchor || null ); this._fragment.mount(options.target, options.anchor || null);
this._lock = true; this._lock = true;
callAll(this._beforecreate); callAll(this._beforecreate);
@ -247,6 +247,6 @@ function SvelteComponent ( options ) {
} }
} }
assign( SvelteComponent.prototype, proto ); assign(SvelteComponent.prototype, proto );
export default SvelteComponent; export default SvelteComponent;

@ -2,7 +2,7 @@ import Imported from 'Imported.html';
import { assign, callAll, createText, detachNode, insertNode, noop, proto } from "svelte/shared.js"; import { assign, callAll, createText, detachNode, insertNode, noop, proto } from "svelte/shared.js";
var template = (function () { var template = (function() {
return { return {
components: { components: {
NonImported NonImported
@ -10,7 +10,7 @@ var template = (function () {
}; };
}()); }());
function create_main_fragment ( state, component ) { function create_main_fragment(state, component) {
var text; var text;
var imported = new Imported({ var imported = new Imported({
@ -22,59 +22,59 @@ function create_main_fragment ( state, component ) {
}); });
return { return {
create: function () { create: function() {
imported._fragment.create(); imported._fragment.create();
text = createText( "\n" ); text = createText("\n");
nonimported._fragment.create(); nonimported._fragment.create();
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
imported._mount( target, anchor ); imported._mount(target, anchor);
insertNode( text, target, anchor ); insertNode(text, target, anchor);
nonimported._mount( target, anchor ); nonimported._mount(target, anchor);
}, },
update: noop, update: noop,
unmount: function () { unmount: function() {
imported._unmount(); imported._unmount();
detachNode( text ); detachNode(text);
nonimported._unmount(); nonimported._unmount();
}, },
destroy: function () { destroy: function() {
imported.destroy( false ); imported.destroy(false);
nonimported.destroy( false ); nonimported.destroy(false);
} }
}; };
} }
function SvelteComponent ( options ) { function SvelteComponent(options) {
this.options = options; this.options = options;
this._state = options.data || {}; this._state = options.data || {};
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
this._root = options._root || this; this._root = options._root || this;
this._yield = options._yield; this._yield = options._yield;
this._bind = options._bind; this._bind = options._bind;
if ( !options._root ) { if (!options._root) {
this._oncreate = []; this._oncreate = [];
this._beforecreate = []; this._beforecreate = [];
this._aftercreate = []; this._aftercreate = [];
} }
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, options.anchor || null ); this._fragment.mount(options.target, options.anchor || null);
this._lock = true; this._lock = true;
callAll(this._beforecreate); callAll(this._beforecreate);
@ -84,6 +84,6 @@ function SvelteComponent ( options ) {
} }
} }
assign( SvelteComponent.prototype, proto ); assign(SvelteComponent.prototype, proto );
export default SvelteComponent; export default SvelteComponent;

@ -151,7 +151,7 @@ var proto = {
_unmount: _unmount _unmount: _unmount
}; };
var template = (function () { var template = (function() {
return { return {
// this test should be removed in v2 // this test should be removed in v2
oncreate () {}, oncreate () {},
@ -159,7 +159,7 @@ var template = (function () {
}; };
}()); }());
function create_main_fragment ( state, component ) { function create_main_fragment(state, component) {
return { return {
create: noop, create: noop,
@ -174,40 +174,40 @@ function create_main_fragment ( state, component ) {
}; };
} }
function SvelteComponent ( options ) { function SvelteComponent(options) {
this.options = options; this.options = options;
this._state = options.data || {}; this._state = options.data || {};
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
this._handlers.destroy = [template.ondestroy]; this._handlers.destroy = [template.ondestroy];
this._root = options._root || this; this._root = options._root || this;
this._yield = options._yield; this._yield = options._yield;
this._bind = options._bind; this._bind = options._bind;
var oncreate = template.oncreate.bind( this ); var oncreate = template.oncreate.bind(this);
if ( !options._root ) { if (!options._root) {
this._oncreate = [oncreate]; this._oncreate = [oncreate];
} else { } else {
this._root._oncreate.push(oncreate); this._root._oncreate.push(oncreate);
} }
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, options.anchor || null ); this._fragment.mount(options.target, options.anchor || null);
callAll(this._oncreate); callAll(this._oncreate);
} }
} }
assign( SvelteComponent.prototype, proto ); assign(SvelteComponent.prototype, proto );
export default SvelteComponent; export default SvelteComponent;

@ -1,6 +1,6 @@
import { assign, callAll, noop, proto } from "svelte/shared.js"; import { assign, callAll, noop, proto } from "svelte/shared.js";
var template = (function () { var template = (function() {
return { return {
// this test should be removed in v2 // this test should be removed in v2
oncreate () {}, oncreate () {},
@ -8,7 +8,7 @@ var template = (function () {
}; };
}()); }());
function create_main_fragment ( state, component ) { function create_main_fragment(state, component) {
return { return {
create: noop, create: noop,
@ -23,40 +23,40 @@ function create_main_fragment ( state, component ) {
}; };
} }
function SvelteComponent ( options ) { function SvelteComponent(options) {
this.options = options; this.options = options;
this._state = options.data || {}; this._state = options.data || {};
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
this._handlers.destroy = [template.ondestroy] this._handlers.destroy = [template.ondestroy]
this._root = options._root || this; this._root = options._root || this;
this._yield = options._yield; this._yield = options._yield;
this._bind = options._bind; this._bind = options._bind;
var oncreate = template.oncreate.bind( this ); var oncreate = template.oncreate.bind(this);
if ( !options._root ) { if (!options._root) {
this._oncreate = [oncreate]; this._oncreate = [oncreate];
} else { } else {
this._root._oncreate.push(oncreate); this._root._oncreate.push(oncreate);
} }
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, options.anchor || null ); this._fragment.mount(options.target, options.anchor || null);
callAll(this._oncreate); callAll(this._oncreate);
} }
} }
assign( SvelteComponent.prototype, proto ); assign(SvelteComponent.prototype, proto );
export default SvelteComponent; export default SvelteComponent;

@ -151,7 +151,7 @@ var proto = {
_unmount: _unmount _unmount: _unmount
}; };
var template = (function () { var template = (function() {
return { return {
methods: { methods: {
foo ( bar ) { foo ( bar ) {
@ -170,7 +170,7 @@ var template = (function () {
}; };
}()); }());
function create_main_fragment ( state, component ) { function create_main_fragment(state, component) {
return { return {
create: noop, create: noop,
@ -185,31 +185,31 @@ function create_main_fragment ( state, component ) {
}; };
} }
function SvelteComponent ( options ) { function SvelteComponent(options) {
this.options = options; this.options = options;
this._state = options.data || {}; this._state = options.data || {};
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
this._root = options._root || this; this._root = options._root || this;
this._yield = options._yield; this._yield = options._yield;
this._bind = options._bind; this._bind = options._bind;
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, options.anchor || null ); this._fragment.mount(options.target, options.anchor || null);
} }
} }
assign( SvelteComponent.prototype, template.methods, proto ); assign(SvelteComponent.prototype, template.methods, proto );
template.setup( SvelteComponent ); template.setup(SvelteComponent);
export default SvelteComponent; export default SvelteComponent;

@ -1,6 +1,6 @@
import { assign, noop, proto } from "svelte/shared.js"; import { assign, noop, proto } from "svelte/shared.js";
var template = (function () { var template = (function() {
return { return {
methods: { methods: {
foo ( bar ) { foo ( bar ) {
@ -19,7 +19,7 @@ var template = (function () {
}; };
}()); }());
function create_main_fragment ( state, component ) { function create_main_fragment(state, component) {
return { return {
create: noop, create: noop,
@ -34,31 +34,31 @@ function create_main_fragment ( state, component ) {
}; };
} }
function SvelteComponent ( options ) { function SvelteComponent(options) {
this.options = options; this.options = options;
this._state = options.data || {}; this._state = options.data || {};
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
this._root = options._root || this; this._root = options._root || this;
this._yield = options._yield; this._yield = options._yield;
this._bind = options._bind; this._bind = options._bind;
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, options.anchor || null ); this._fragment.mount(options.target, options.anchor || null);
} }
} }
assign( SvelteComponent.prototype, template.methods, proto ); assign(SvelteComponent.prototype, template.methods, proto );
template.setup( SvelteComponent ); template.setup(SvelteComponent);
export default SvelteComponent; export default SvelteComponent;

@ -175,158 +175,158 @@ var proto = {
_unmount: _unmount _unmount: _unmount
}; };
function create_main_fragment ( state, component ) { function create_main_fragment(state, component) {
var div, text, p, text_1, text_2, text_3, text_4, p_1, text_5, text_6, text_8, if_block_4_anchor; var div, text, p, text_1, text_2, text_3, text_4, p_1, text_5, text_6, text_8, if_block_4_anchor;
var if_block = (state.a) && create_if_block( state, component ); var if_block = (state.a) && create_if_block(state, component);
var if_block_1 = (state.b) && create_if_block_1( state, component ); var if_block_1 = (state.b) && create_if_block_1(state, component);
var if_block_2 = (state.c) && create_if_block_2( state, component ); var if_block_2 = (state.c) && create_if_block_2(state, component);
var if_block_3 = (state.d) && create_if_block_3( state, component ); var if_block_3 = (state.d) && create_if_block_3(state, component);
var if_block_4 = (state.e) && create_if_block_4( state, component ); var if_block_4 = (state.e) && create_if_block_4(state, component);
return { return {
create: function () { create: function() {
div = createElement( 'div' ); div = createElement( 'div' );
if ( if_block ) if_block.create(); if (if_block) if_block.create();
text = createText( "\n\n\t" ); text = createText("\n\n\t");
p = createElement( 'p' ); p = createElement( 'p' );
text_1 = createText( "this can be used as an anchor" ); text_1 = createText("this can be used as an anchor");
text_2 = createText( "\n\n\t" ); text_2 = createText("\n\n\t");
if ( if_block_1 ) if_block_1.create(); if (if_block_1) if_block_1.create();
text_3 = createText( "\n\n\t" ); text_3 = createText("\n\n\t");
if ( if_block_2 ) if_block_2.create(); if (if_block_2) if_block_2.create();
text_4 = createText( "\n\n\t" ); text_4 = createText("\n\n\t");
p_1 = createElement( 'p' ); p_1 = createElement( 'p' );
text_5 = createText( "so can this" ); text_5 = createText("so can this");
text_6 = createText( "\n\n\t" ); text_6 = createText("\n\n\t");
if ( if_block_3 ) if_block_3.create(); if (if_block_3) if_block_3.create();
text_8 = createText( "\n\n" ); text_8 = createText("\n\n");
if ( if_block_4 ) if_block_4.create(); if (if_block_4) if_block_4.create();
if_block_4_anchor = createComment(); if_block_4_anchor = createComment();
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( div, target, anchor ); insertNode( div, target, anchor );
if ( if_block ) if_block.mount( div, null ); if (if_block) if_block.mount(div, null);
appendNode( text, div ); appendNode(text, div);
appendNode( p, div ); appendNode( p, div );
appendNode( text_1, p ); appendNode(text_1, p);
appendNode( text_2, div ); appendNode(text_2, div);
if ( if_block_1 ) if_block_1.mount( div, null ); if (if_block_1) if_block_1.mount(div, null);
appendNode( text_3, div ); appendNode(text_3, div);
if ( if_block_2 ) if_block_2.mount( div, null ); if (if_block_2) if_block_2.mount(div, null);
appendNode( text_4, div ); appendNode(text_4, div);
appendNode( p_1, div ); appendNode( p_1, div );
appendNode( text_5, p_1 ); appendNode(text_5, p_1);
appendNode( text_6, div ); appendNode(text_6, div);
if ( if_block_3 ) if_block_3.mount( div, null ); if (if_block_3) if_block_3.mount(div, null);
insertNode( text_8, target, anchor ); insertNode(text_8, target, anchor);
if ( if_block_4 ) if_block_4.mount( target, anchor ); if (if_block_4) if_block_4.mount(target, anchor);
insertNode( if_block_4_anchor, target, anchor ); insertNode(if_block_4_anchor, target, anchor);
}, },
update: function ( changed, state ) { update: function(changed, state) {
if ( state.a ) { if (state.a) {
if ( !if_block ) { if (!if_block) {
if_block = create_if_block( state, component ); if_block = create_if_block(state, component);
if_block.create(); if_block.create();
if_block.mount( div, text ); if_block.mount(div, text);
} }
} else if ( if_block ) { } else if (if_block) {
if_block.unmount(); if_block.unmount();
if_block.destroy(); if_block.destroy();
if_block = null; if_block = null;
} }
if ( state.b ) { if (state.b) {
if ( !if_block_1 ) { if (!if_block_1) {
if_block_1 = create_if_block_1( state, component ); if_block_1 = create_if_block_1(state, component);
if_block_1.create(); if_block_1.create();
if_block_1.mount( div, text_3 ); if_block_1.mount(div, text_3);
} }
} else if ( if_block_1 ) { } else if (if_block_1) {
if_block_1.unmount(); if_block_1.unmount();
if_block_1.destroy(); if_block_1.destroy();
if_block_1 = null; if_block_1 = null;
} }
if ( state.c ) { if (state.c) {
if ( !if_block_2 ) { if (!if_block_2) {
if_block_2 = create_if_block_2( state, component ); if_block_2 = create_if_block_2(state, component);
if_block_2.create(); if_block_2.create();
if_block_2.mount( div, text_4 ); if_block_2.mount(div, text_4);
} }
} else if ( if_block_2 ) { } else if (if_block_2) {
if_block_2.unmount(); if_block_2.unmount();
if_block_2.destroy(); if_block_2.destroy();
if_block_2 = null; if_block_2 = null;
} }
if ( state.d ) { if (state.d) {
if ( !if_block_3 ) { if (!if_block_3) {
if_block_3 = create_if_block_3( state, component ); if_block_3 = create_if_block_3(state, component);
if_block_3.create(); if_block_3.create();
if_block_3.mount( div, null ); if_block_3.mount(div, null);
} }
} else if ( if_block_3 ) { } else if (if_block_3) {
if_block_3.unmount(); if_block_3.unmount();
if_block_3.destroy(); if_block_3.destroy();
if_block_3 = null; if_block_3 = null;
} }
if ( state.e ) { if (state.e) {
if ( !if_block_4 ) { if (!if_block_4) {
if_block_4 = create_if_block_4( state, component ); if_block_4 = create_if_block_4(state, component);
if_block_4.create(); if_block_4.create();
if_block_4.mount( if_block_4_anchor.parentNode, if_block_4_anchor ); if_block_4.mount(if_block_4_anchor.parentNode, if_block_4_anchor);
} }
} else if ( if_block_4 ) { } else if (if_block_4) {
if_block_4.unmount(); if_block_4.unmount();
if_block_4.destroy(); if_block_4.destroy();
if_block_4 = null; if_block_4 = null;
} }
}, },
unmount: function () { unmount: function() {
detachNode( div ); detachNode( div );
if ( if_block ) if_block.unmount(); if (if_block) if_block.unmount();
if ( if_block_1 ) if_block_1.unmount(); if (if_block_1) if_block_1.unmount();
if ( if_block_2 ) if_block_2.unmount(); if (if_block_2) if_block_2.unmount();
if ( if_block_3 ) if_block_3.unmount(); if (if_block_3) if_block_3.unmount();
detachNode( text_8 ); detachNode(text_8);
if ( if_block_4 ) if_block_4.unmount(); if (if_block_4) if_block_4.unmount();
detachNode( if_block_4_anchor ); detachNode(if_block_4_anchor);
}, },
destroy: function () { destroy: function() {
if ( if_block ) if_block.destroy(); if (if_block) if_block.destroy();
if ( if_block_1 ) if_block_1.destroy(); if (if_block_1) if_block_1.destroy();
if ( if_block_2 ) if_block_2.destroy(); if (if_block_2) if_block_2.destroy();
if ( if_block_3 ) if_block_3.destroy(); if (if_block_3) if_block_3.destroy();
if ( if_block_4 ) if_block_4.destroy(); if (if_block_4) if_block_4.destroy();
} }
}; };
} }
function create_if_block ( state, component ) { function create_if_block(state, component) {
var p, text; var p, text;
return { return {
create: function () { create: function() {
p = createElement( 'p' ); p = createElement( 'p' );
text = createText( "a" ); text = createText("a");
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( p, target, anchor ); insertNode( p, target, anchor );
appendNode( text, p ); appendNode(text, p);
}, },
unmount: function () { unmount: function() {
detachNode( p ); detachNode( p );
}, },
@ -334,21 +334,21 @@ function create_if_block ( state, component ) {
}; };
} }
function create_if_block_1 ( state, component ) { function create_if_block_1(state, component) {
var p, text; var p, text;
return { return {
create: function () { create: function() {
p = createElement( 'p' ); p = createElement( 'p' );
text = createText( "b" ); text = createText("b");
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( p, target, anchor ); insertNode( p, target, anchor );
appendNode( text, p ); appendNode(text, p);
}, },
unmount: function () { unmount: function() {
detachNode( p ); detachNode( p );
}, },
@ -356,21 +356,21 @@ function create_if_block_1 ( state, component ) {
}; };
} }
function create_if_block_2 ( state, component ) { function create_if_block_2(state, component) {
var p, text; var p, text;
return { return {
create: function () { create: function() {
p = createElement( 'p' ); p = createElement( 'p' );
text = createText( "c" ); text = createText("c");
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( p, target, anchor ); insertNode( p, target, anchor );
appendNode( text, p ); appendNode(text, p);
}, },
unmount: function () { unmount: function() {
detachNode( p ); detachNode( p );
}, },
@ -378,21 +378,21 @@ function create_if_block_2 ( state, component ) {
}; };
} }
function create_if_block_3 ( state, component ) { function create_if_block_3(state, component) {
var p, text; var p, text;
return { return {
create: function () { create: function() {
p = createElement( 'p' ); p = createElement( 'p' );
text = createText( "d" ); text = createText("d");
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( p, target, anchor ); insertNode( p, target, anchor );
appendNode( text, p ); appendNode(text, p);
}, },
unmount: function () { unmount: function() {
detachNode( p ); detachNode( p );
}, },
@ -400,21 +400,21 @@ function create_if_block_3 ( state, component ) {
}; };
} }
function create_if_block_4 ( state, component ) { function create_if_block_4(state, component) {
var p, text; var p, text;
return { return {
create: function () { create: function() {
p = createElement( 'p' ); p = createElement( 'p' );
text = createText( "e" ); text = createText("e");
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( p, target, anchor ); insertNode( p, target, anchor );
appendNode( text, p ); appendNode(text, p);
}, },
unmount: function () { unmount: function() {
detachNode( p ); detachNode( p );
}, },
@ -422,29 +422,29 @@ function create_if_block_4 ( state, component ) {
}; };
} }
function SvelteComponent ( options ) { function SvelteComponent(options) {
this.options = options; this.options = options;
this._state = options.data || {}; this._state = options.data || {};
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
this._root = options._root || this; this._root = options._root || this;
this._yield = options._yield; this._yield = options._yield;
this._bind = options._bind; this._bind = options._bind;
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, options.anchor || null ); this._fragment.mount(options.target, options.anchor || null);
} }
} }
assign( SvelteComponent.prototype, proto ); assign(SvelteComponent.prototype, proto );
export default SvelteComponent; export default SvelteComponent;

@ -1,157 +1,157 @@
import { appendNode, assign, createComment, createElement, createText, detachNode, insertNode, noop, proto } from "svelte/shared.js"; import { appendNode, assign, createComment, createElement, createText, detachNode, insertNode, noop, proto } from "svelte/shared.js";
function create_main_fragment ( state, component ) { function create_main_fragment(state, component) {
var div, text, p, text_1, text_2, text_3, text_4, p_1, text_5, text_6, text_8, if_block_4_anchor; var div, text, p, text_1, text_2, text_3, text_4, p_1, text_5, text_6, text_8, if_block_4_anchor;
var if_block = (state.a) && create_if_block( state, component ); var if_block = (state.a) && create_if_block(state, component);
var if_block_1 = (state.b) && create_if_block_1( state, component ); var if_block_1 = (state.b) && create_if_block_1(state, component);
var if_block_2 = (state.c) && create_if_block_2( state, component ); var if_block_2 = (state.c) && create_if_block_2(state, component);
var if_block_3 = (state.d) && create_if_block_3( state, component ); var if_block_3 = (state.d) && create_if_block_3(state, component);
var if_block_4 = (state.e) && create_if_block_4( state, component ); var if_block_4 = (state.e) && create_if_block_4(state, component);
return { return {
create: function () { create: function() {
div = createElement( 'div' ); div = createElement( 'div' );
if ( if_block ) if_block.create(); if (if_block) if_block.create();
text = createText( "\n\n\t" ); text = createText("\n\n\t");
p = createElement( 'p' ); p = createElement( 'p' );
text_1 = createText( "this can be used as an anchor" ); text_1 = createText("this can be used as an anchor");
text_2 = createText( "\n\n\t" ); text_2 = createText("\n\n\t");
if ( if_block_1 ) if_block_1.create(); if (if_block_1) if_block_1.create();
text_3 = createText( "\n\n\t" ); text_3 = createText("\n\n\t");
if ( if_block_2 ) if_block_2.create(); if (if_block_2) if_block_2.create();
text_4 = createText( "\n\n\t" ); text_4 = createText("\n\n\t");
p_1 = createElement( 'p' ); p_1 = createElement( 'p' );
text_5 = createText( "so can this" ); text_5 = createText("so can this");
text_6 = createText( "\n\n\t" ); text_6 = createText("\n\n\t");
if ( if_block_3 ) if_block_3.create(); if (if_block_3) if_block_3.create();
text_8 = createText( "\n\n" ); text_8 = createText("\n\n");
if ( if_block_4 ) if_block_4.create(); if (if_block_4) if_block_4.create();
if_block_4_anchor = createComment(); if_block_4_anchor = createComment();
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( div, target, anchor ); insertNode( div, target, anchor );
if ( if_block ) if_block.mount( div, null ); if (if_block) if_block.mount(div, null);
appendNode( text, div ); appendNode(text, div);
appendNode( p, div ); appendNode( p, div );
appendNode( text_1, p ); appendNode(text_1, p);
appendNode( text_2, div ); appendNode(text_2, div);
if ( if_block_1 ) if_block_1.mount( div, null ); if (if_block_1) if_block_1.mount(div, null);
appendNode( text_3, div ); appendNode(text_3, div);
if ( if_block_2 ) if_block_2.mount( div, null ); if (if_block_2) if_block_2.mount(div, null);
appendNode( text_4, div ); appendNode(text_4, div);
appendNode( p_1, div ); appendNode( p_1, div );
appendNode( text_5, p_1 ); appendNode(text_5, p_1);
appendNode( text_6, div ); appendNode(text_6, div);
if ( if_block_3 ) if_block_3.mount( div, null ); if (if_block_3) if_block_3.mount(div, null);
insertNode( text_8, target, anchor ); insertNode(text_8, target, anchor);
if ( if_block_4 ) if_block_4.mount( target, anchor ); if (if_block_4) if_block_4.mount(target, anchor);
insertNode( if_block_4_anchor, target, anchor ); insertNode(if_block_4_anchor, target, anchor);
}, },
update: function ( changed, state ) { update: function(changed, state) {
if ( state.a ) { if (state.a) {
if ( !if_block ) { if (!if_block) {
if_block = create_if_block( state, component ); if_block = create_if_block(state, component);
if_block.create(); if_block.create();
if_block.mount( div, text ); if_block.mount(div, text);
} }
} else if ( if_block ) { } else if (if_block) {
if_block.unmount(); if_block.unmount();
if_block.destroy(); if_block.destroy();
if_block = null; if_block = null;
} }
if ( state.b ) { if (state.b) {
if ( !if_block_1 ) { if (!if_block_1) {
if_block_1 = create_if_block_1( state, component ); if_block_1 = create_if_block_1(state, component);
if_block_1.create(); if_block_1.create();
if_block_1.mount( div, text_3 ); if_block_1.mount(div, text_3);
} }
} else if ( if_block_1 ) { } else if (if_block_1) {
if_block_1.unmount(); if_block_1.unmount();
if_block_1.destroy(); if_block_1.destroy();
if_block_1 = null; if_block_1 = null;
} }
if ( state.c ) { if (state.c) {
if ( !if_block_2 ) { if (!if_block_2) {
if_block_2 = create_if_block_2( state, component ); if_block_2 = create_if_block_2(state, component);
if_block_2.create(); if_block_2.create();
if_block_2.mount( div, text_4 ); if_block_2.mount(div, text_4);
} }
} else if ( if_block_2 ) { } else if (if_block_2) {
if_block_2.unmount(); if_block_2.unmount();
if_block_2.destroy(); if_block_2.destroy();
if_block_2 = null; if_block_2 = null;
} }
if ( state.d ) { if (state.d) {
if ( !if_block_3 ) { if (!if_block_3) {
if_block_3 = create_if_block_3( state, component ); if_block_3 = create_if_block_3(state, component);
if_block_3.create(); if_block_3.create();
if_block_3.mount( div, null ); if_block_3.mount(div, null);
} }
} else if ( if_block_3 ) { } else if (if_block_3) {
if_block_3.unmount(); if_block_3.unmount();
if_block_3.destroy(); if_block_3.destroy();
if_block_3 = null; if_block_3 = null;
} }
if ( state.e ) { if (state.e) {
if ( !if_block_4 ) { if (!if_block_4) {
if_block_4 = create_if_block_4( state, component ); if_block_4 = create_if_block_4(state, component);
if_block_4.create(); if_block_4.create();
if_block_4.mount( if_block_4_anchor.parentNode, if_block_4_anchor ); if_block_4.mount(if_block_4_anchor.parentNode, if_block_4_anchor);
} }
} else if ( if_block_4 ) { } else if (if_block_4) {
if_block_4.unmount(); if_block_4.unmount();
if_block_4.destroy(); if_block_4.destroy();
if_block_4 = null; if_block_4 = null;
} }
}, },
unmount: function () { unmount: function() {
detachNode( div ); detachNode( div );
if ( if_block ) if_block.unmount(); if (if_block) if_block.unmount();
if ( if_block_1 ) if_block_1.unmount(); if (if_block_1) if_block_1.unmount();
if ( if_block_2 ) if_block_2.unmount(); if (if_block_2) if_block_2.unmount();
if ( if_block_3 ) if_block_3.unmount(); if (if_block_3) if_block_3.unmount();
detachNode( text_8 ); detachNode(text_8);
if ( if_block_4 ) if_block_4.unmount(); if (if_block_4) if_block_4.unmount();
detachNode( if_block_4_anchor ); detachNode(if_block_4_anchor);
}, },
destroy: function () { destroy: function() {
if ( if_block ) if_block.destroy(); if (if_block) if_block.destroy();
if ( if_block_1 ) if_block_1.destroy(); if (if_block_1) if_block_1.destroy();
if ( if_block_2 ) if_block_2.destroy(); if (if_block_2) if_block_2.destroy();
if ( if_block_3 ) if_block_3.destroy(); if (if_block_3) if_block_3.destroy();
if ( if_block_4 ) if_block_4.destroy(); if (if_block_4) if_block_4.destroy();
} }
}; };
} }
function create_if_block ( state, component ) { function create_if_block(state, component) {
var p, text; var p, text;
return { return {
create: function () { create: function() {
p = createElement( 'p' ); p = createElement( 'p' );
text = createText( "a" ); text = createText("a");
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( p, target, anchor ); insertNode( p, target, anchor );
appendNode( text, p ); appendNode(text, p);
}, },
unmount: function () { unmount: function() {
detachNode( p ); detachNode( p );
}, },
@ -159,21 +159,21 @@ function create_if_block ( state, component ) {
}; };
} }
function create_if_block_1 ( state, component ) { function create_if_block_1(state, component) {
var p, text; var p, text;
return { return {
create: function () { create: function() {
p = createElement( 'p' ); p = createElement( 'p' );
text = createText( "b" ); text = createText("b");
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( p, target, anchor ); insertNode( p, target, anchor );
appendNode( text, p ); appendNode(text, p);
}, },
unmount: function () { unmount: function() {
detachNode( p ); detachNode( p );
}, },
@ -181,21 +181,21 @@ function create_if_block_1 ( state, component ) {
}; };
} }
function create_if_block_2 ( state, component ) { function create_if_block_2(state, component) {
var p, text; var p, text;
return { return {
create: function () { create: function() {
p = createElement( 'p' ); p = createElement( 'p' );
text = createText( "c" ); text = createText("c");
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( p, target, anchor ); insertNode( p, target, anchor );
appendNode( text, p ); appendNode(text, p);
}, },
unmount: function () { unmount: function() {
detachNode( p ); detachNode( p );
}, },
@ -203,21 +203,21 @@ function create_if_block_2 ( state, component ) {
}; };
} }
function create_if_block_3 ( state, component ) { function create_if_block_3(state, component) {
var p, text; var p, text;
return { return {
create: function () { create: function() {
p = createElement( 'p' ); p = createElement( 'p' );
text = createText( "d" ); text = createText("d");
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( p, target, anchor ); insertNode( p, target, anchor );
appendNode( text, p ); appendNode(text, p);
}, },
unmount: function () { unmount: function() {
detachNode( p ); detachNode( p );
}, },
@ -225,21 +225,21 @@ function create_if_block_3 ( state, component ) {
}; };
} }
function create_if_block_4 ( state, component ) { function create_if_block_4(state, component) {
var p, text; var p, text;
return { return {
create: function () { create: function() {
p = createElement( 'p' ); p = createElement( 'p' );
text = createText( "e" ); text = createText("e");
}, },
mount: function ( target, anchor ) { mount: function(target, anchor) {
insertNode( p, target, anchor ); insertNode( p, target, anchor );
appendNode( text, p ); appendNode(text, p);
}, },
unmount: function () { unmount: function() {
detachNode( p ); detachNode( p );
}, },
@ -247,29 +247,29 @@ function create_if_block_4 ( state, component ) {
}; };
} }
function SvelteComponent ( options ) { function SvelteComponent(options) {
this.options = options; this.options = options;
this._state = options.data || {}; this._state = options.data || {};
this._observers = { this._observers = {
pre: Object.create( null ), pre: Object.create(null),
post: Object.create( null ) post: Object.create(null)
}; };
this._handlers = Object.create( null ); this._handlers = Object.create(null);
this._root = options._root || this; this._root = options._root || this;
this._yield = options._yield; this._yield = options._yield;
this._bind = options._bind; this._bind = options._bind;
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment(this._state, this);
if ( options.target ) { if (options.target) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, options.anchor || null ); this._fragment.mount(options.target, options.anchor || null);
} }
} }
assign( SvelteComponent.prototype, proto ); assign(SvelteComponent.prototype, proto );
export default SvelteComponent; export default SvelteComponent;
Loading…
Cancel
Save