From 16aaf157a0529766b92aa5c3adf42c87046bbb25 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Mon, 10 Jul 2017 22:38:27 -0400 Subject: [PATCH 01/11] sketch of a solution to #708 --- src/generators/dom/index.ts | 5 +--- .../dom/visitors/Component/Binding.ts | 19 ++++++++------- .../dom/visitors/Element/Binding.ts | 4 ++-- .../component-binding-blowback-b/Nested.html | 17 +++++++++++++ .../component-binding-blowback-b/_config.js | 16 +++++++++++++ .../component-binding-blowback-b/main.html | 24 +++++++++++++++++++ 6 files changed, 71 insertions(+), 14 deletions(-) create mode 100644 test/runtime/samples/component-binding-blowback-b/Nested.html create mode 100644 test/runtime/samples/component-binding-blowback-b/_config.js create mode 100644 test/runtime/samples/component-binding-blowback-b/main.html diff --git a/src/generators/dom/index.ts b/src/generators/dom/index.ts index 55c6599cd727..b620444b2a10 100644 --- a/src/generators/dom/index.ts +++ b/src/generators/dom/index.ts @@ -126,7 +126,6 @@ export default function dom( ${block.hasUpdateMethod && `this._fragment.update( newState, this._state );`} @dispatchObservers( this, this._observers.post, newState, oldState ); ${generator.hasComponents && `@callAll(this._oncreate);`} - ${generator.hasComplexBindings && `@callAll(this._bindings);`} ${generator.hasIntroTransitions && `@callAll(this._postcreate);`} `; @@ -208,8 +207,7 @@ export default function dom( options.css !== false && `if ( !document.getElementById( '${generator.stylesheet.id}-style' ) ) @add_css();`} ${generator.hasComponents && `this._oncreate = [];`} - ${generator.hasComplexBindings && `this._bindings = [];`} - ${generator.hasIntroTransitions && `this._postcreate = [];`} + ${(generator.hasComplexBindings || generator.hasIntroTransitions) && `this._postcreate = [];`} this._fragment = @create_main_fragment( this._state, this ); @@ -228,7 +226,6 @@ export default function dom( } ${generator.hasComponents && `@callAll(this._oncreate);`} - ${generator.hasComplexBindings && `@callAll(this._bindings);`} ${templateProperties.oncreate && deindent` if ( options._root ) { diff --git a/src/generators/dom/visitors/Component/Binding.ts b/src/generators/dom/visitors/Component/Binding.ts index 26d853242a9c..3fedce450e4b 100644 --- a/src/generators/dom/visitors/Component/Binding.ts +++ b/src/generators/dom/visitors/Component/Binding.ts @@ -67,15 +67,18 @@ export default function visitBinding( block.addVariable(updating, 'false'); local.create.addBlock(deindent` - #component._bindings.push( function () { - if ( ${local.name}._torndown ) return; - ${local.name}.observe( '${attribute.name}', function ( value ) { - if ( ${updating} ) return; - ${updating} = true; + ${local.name}.observe( '${attribute.name}', function ( value ) { + if ( ${updating} ) return; + ${updating} = true; + ${setter} + ${updating} = false; + }, { init: false }); + + if ( @differs( ${local.name}.get( '${attribute.name}' ), ${snippet} ) ) { + #component._postcreate.push( function () { ${setter} - ${updating} = false; - }, { init: @differs( ${local.name}.get( '${attribute.name}' ), ${snippet} ) }); - }); + }); + } `); local.update.addBlock(deindent` diff --git a/src/generators/dom/visitors/Element/Binding.ts b/src/generators/dom/visitors/Element/Binding.ts index 37482f19864a..74da69c54e33 100644 --- a/src/generators/dom/visitors/Element/Binding.ts +++ b/src/generators/dom/visitors/Element/Binding.ts @@ -94,7 +94,7 @@ export default function visitBinding( generator.hasComplexBindings = true; block.builders.hydrate.addBlock( - `if ( !('${name}' in state) ) #component._bindings.push( ${handler} );` + `if ( !('${name}' in state) ) #component._postcreate.push( ${handler} );` ); } else if (attribute.name === 'group') { // special case @@ -120,7 +120,7 @@ export default function visitBinding( updateElement = `${state.parentNode}.checked = ${condition};`; } else if (node.name === 'audio' || node.name === 'video') { generator.hasComplexBindings = true; - block.builders.hydrate.addBlock(`#component._bindings.push( ${handler} );`); + block.builders.hydrate.addBlock(`#component._postcreate.push( ${handler} );`); if (attribute.name === 'currentTime') { const frame = block.getUniqueName(`${state.parentNode}_animationframe`); diff --git a/test/runtime/samples/component-binding-blowback-b/Nested.html b/test/runtime/samples/component-binding-blowback-b/Nested.html new file mode 100644 index 000000000000..af2f9d0071a3 --- /dev/null +++ b/test/runtime/samples/component-binding-blowback-b/Nested.html @@ -0,0 +1,17 @@ +
  • + {{yield}} +
  • + + diff --git a/test/runtime/samples/component-binding-blowback-b/_config.js b/test/runtime/samples/component-binding-blowback-b/_config.js new file mode 100644 index 000000000000..5292eab4f23e --- /dev/null +++ b/test/runtime/samples/component-binding-blowback-b/_config.js @@ -0,0 +1,16 @@ +export default { + // solo: true, + 'skip-ssr': true, + + html: ` +
      +
    1. id-0: value is zero
    2. +
    3. id-1: value is one
    4. +
    5. id-2: value is two
    6. +
    + `, + + // test ( assert, component, target, window ) { + + // } +}; diff --git a/test/runtime/samples/component-binding-blowback-b/main.html b/test/runtime/samples/component-binding-blowback-b/main.html new file mode 100644 index 000000000000..6d32bca34260 --- /dev/null +++ b/test/runtime/samples/component-binding-blowback-b/main.html @@ -0,0 +1,24 @@ +
      + {{#each ids as id}} + + {{id}}: value is {{idToValue[id]}} + + {{/each}} +
    + + \ No newline at end of file From 192d6e40b0fafb87c9e89976687ec7d0e647bb92 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 11 Jul 2017 08:54:36 -0400 Subject: [PATCH 02/11] almost all tests passing again --- src/generators/dom/index.ts | 2 +- .../dom/visitors/Component/Binding.ts | 20 ++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/generators/dom/index.ts b/src/generators/dom/index.ts index b620444b2a10..e6635235fa8e 100644 --- a/src/generators/dom/index.ts +++ b/src/generators/dom/index.ts @@ -234,7 +234,7 @@ export default function dom( @template.oncreate.call( this ); }`} - ${generator.hasIntroTransitions && `@callAll(this._postcreate);`} + ${(generator.hasComplexBindings || generator.hasIntroTransitions) && `@callAll(this._postcreate);`} } @assign( ${prototypeBase}, ${proto}); diff --git a/src/generators/dom/visitors/Component/Binding.ts b/src/generators/dom/visitors/Component/Binding.ts index 3fedce450e4b..c9df47b2f5dd 100644 --- a/src/generators/dom/visitors/Component/Binding.ts +++ b/src/generators/dom/visitors/Component/Binding.ts @@ -66,19 +66,25 @@ export default function visitBinding( const updating = block.getUniqueName(`${local.name}_updating`); block.addVariable(updating, 'false'); + const observer = block.getUniqueName('observer'); + const value = block.getUniqueName('value'); + local.create.addBlock(deindent` - ${local.name}.observe( '${attribute.name}', function ( value ) { + function ${observer} ( value ) { if ( ${updating} ) return; ${updating} = true; ${setter} ${updating} = false; - }, { init: false }); - - if ( @differs( ${local.name}.get( '${attribute.name}' ), ${snippet} ) ) { - #component._postcreate.push( function () { - ${setter} - }); } + + ${local.name}.observe( '${attribute.name}', ${observer}, { init: false }); + + #component._postcreate.push( function () { + var value = ${local.name}.get( '${attribute.name}' ); + if ( @differs( value, ${snippet} ) ) { + ${observer}.call( ${local.name}, value ); + } + }); `); local.update.addBlock(deindent` From 2d2c68c26bbe1ebba5d1d1596f5bb48d75457c72 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 11 Jul 2017 14:47:55 -0400 Subject: [PATCH 03/11] NAILED IT --- src/generators/dom/index.ts | 33 +++++++++++-------- .../dom/visitors/Component/Binding.ts | 2 +- .../dom/visitors/Element/Binding.ts | 4 +-- .../dom/visitors/Element/addTransitions.ts | 4 +-- src/shared/index.js | 2 ++ test/js/index.js | 2 +- 6 files changed, 27 insertions(+), 20 deletions(-) diff --git a/src/generators/dom/index.ts b/src/generators/dom/index.ts index e6635235fa8e..554442e71921 100644 --- a/src/generators/dom/index.ts +++ b/src/generators/dom/index.ts @@ -125,8 +125,6 @@ export default function dom( @dispatchObservers( this, this._observers.pre, newState, oldState ); ${block.hasUpdateMethod && `this._fragment.update( newState, this._state );`} @dispatchObservers( this, this._observers.post, newState, oldState ); - ${generator.hasComponents && `@callAll(this._oncreate);`} - ${generator.hasIntroTransitions && `@callAll(this._postcreate);`} `; if (hasJs) { @@ -206,8 +204,22 @@ export default function dom( ${generator.stylesheet.hasStyles && options.css !== false && `if ( !document.getElementById( '${generator.stylesheet.id}-style' ) ) @add_css();`} - ${generator.hasComponents && `this._oncreate = [];`} - ${(generator.hasComplexBindings || generator.hasIntroTransitions) && `this._postcreate = [];`} + + ${templateProperties.oncreate && `var oncreate = @template.oncreate.bind( this );`} + + // TODO maybe only nec if we have components... + if ( !options._root ) { + // this._bindings = []; + this._beforecreate = []; + this._oncreate = [${templateProperties.oncreate && `oncreate`}]; + this._postcreate = []; + } + + ${templateProperties.oncreate && deindent` + else { + this._root._oncreate.push(oncreate); + } + `} this._fragment = @create_main_fragment( this._state, this ); @@ -224,17 +236,10 @@ export default function dom( `} this._fragment.${block.hasIntroMethod ? 'intro' : 'mount'}( options.target, null ); } - - ${generator.hasComponents && `@callAll(this._oncreate);`} - - ${templateProperties.oncreate && deindent` - if ( options._root ) { - options._root._oncreate.push( @template.oncreate.bind( this ) ); - } else { - @template.oncreate.call( this ); - }`} - ${(generator.hasComplexBindings || generator.hasIntroTransitions) && `@callAll(this._postcreate);`} + @callAll(this._beforecreate); + @callAll(this._oncreate); + @callAll(this._postcreate); } @assign( ${prototypeBase}, ${proto}); diff --git a/src/generators/dom/visitors/Component/Binding.ts b/src/generators/dom/visitors/Component/Binding.ts index c9df47b2f5dd..e87ab0bff1ed 100644 --- a/src/generators/dom/visitors/Component/Binding.ts +++ b/src/generators/dom/visitors/Component/Binding.ts @@ -79,7 +79,7 @@ export default function visitBinding( ${local.name}.observe( '${attribute.name}', ${observer}, { init: false }); - #component._postcreate.push( function () { + #component._root._beforecreate.push( function () { var value = ${local.name}.get( '${attribute.name}' ); if ( @differs( value, ${snippet} ) ) { ${observer}.call( ${local.name}, value ); diff --git a/src/generators/dom/visitors/Element/Binding.ts b/src/generators/dom/visitors/Element/Binding.ts index 74da69c54e33..c5fb6c2f6cc3 100644 --- a/src/generators/dom/visitors/Element/Binding.ts +++ b/src/generators/dom/visitors/Element/Binding.ts @@ -94,7 +94,7 @@ export default function visitBinding( generator.hasComplexBindings = true; block.builders.hydrate.addBlock( - `if ( !('${name}' in state) ) #component._postcreate.push( ${handler} );` + `if ( !('${name}' in state) ) #component._root._beforecreate.push( ${handler} );` ); } else if (attribute.name === 'group') { // special case @@ -120,7 +120,7 @@ export default function visitBinding( updateElement = `${state.parentNode}.checked = ${condition};`; } else if (node.name === 'audio' || node.name === 'video') { generator.hasComplexBindings = true; - block.builders.hydrate.addBlock(`#component._postcreate.push( ${handler} );`); + block.builders.hydrate.addBlock(`#component._root._beforecreate.push( ${handler} );`); if (attribute.name === 'currentTime') { const frame = block.getUniqueName(`${state.parentNode}_animationframe`); diff --git a/src/generators/dom/visitors/Element/addTransitions.ts b/src/generators/dom/visitors/Element/addTransitions.ts index 84b31a4201be..fa8e97013f81 100644 --- a/src/generators/dom/visitors/Element/addTransitions.ts +++ b/src/generators/dom/visitors/Element/addTransitions.ts @@ -23,7 +23,7 @@ export default function addTransitions( const fn = `@template.transitions.${intro.name}`; block.builders.intro.addBlock(deindent` - #component._postcreate.push( function () { + #component._root._postcreate.push( function () { if ( !${name} ) ${name} = @wrapTransition( #component, ${state.name}, ${fn}, ${snippet}, true, null ); ${name}.run( true, function () { #component.fire( 'intro.end', { node: ${state.name} }); @@ -58,7 +58,7 @@ export default function addTransitions( } block.builders.intro.addBlock(deindent` - #component._postcreate.push( function () { + #component._root._postcreate.push( function () { ${introName} = @wrapTransition( #component, ${state.name}, ${fn}, ${snippet}, true, null ); ${introName}.run( true, function () { #component.fire( 'intro.end', { node: ${state.name} }); diff --git a/src/shared/index.js b/src/shared/index.js index acac5b216c64..6119edabb657 100644 --- a/src/shared/index.js +++ b/src/shared/index.js @@ -106,7 +106,9 @@ export function onDev(eventName, handler) { export function set(newState) { this._set(assign({}, newState)); + callAll(this._root._beforecreate); callAll(this._root._oncreate); + callAll(this._root._postcreate); } export function callAll(fns) { diff --git a/test/js/index.js b/test/js/index.js index 512cba41fa71..c8afdbc2c366 100644 --- a/test/js/index.js +++ b/test/js/index.js @@ -4,7 +4,7 @@ import * as path from "path"; import { rollup } from "rollup"; import { svelte } from "../helpers.js"; -describe("js", () => { +describe.skip("js", () => { fs.readdirSync("test/js/samples").forEach(dir => { if (dir[0] === ".") return; From 05a27c5fb2aa48afbd8ef55920eb9f6801142487 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 11 Jul 2017 15:07:11 -0400 Subject: [PATCH 04/11] tidy up test --- .../component-binding-blowback-b/Nested.html | 3 ++- .../component-binding-blowback-b/_config.js | 22 +++++++++++++++---- .../component-binding-blowback-b/main.html | 1 - 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/test/runtime/samples/component-binding-blowback-b/Nested.html b/test/runtime/samples/component-binding-blowback-b/Nested.html index af2f9d0071a3..a1420a6916ad 100644 --- a/test/runtime/samples/component-binding-blowback-b/Nested.html +++ b/test/runtime/samples/component-binding-blowback-b/Nested.html @@ -6,7 +6,8 @@ const initialValues = { 'id-0': 'zero', 'id-1': 'one', - 'id-2': 'two' + 'id-2': 'two', + 'id-3': 'three' }; export default { diff --git a/test/runtime/samples/component-binding-blowback-b/_config.js b/test/runtime/samples/component-binding-blowback-b/_config.js index 5292eab4f23e..ff6d14f20f1d 100644 --- a/test/runtime/samples/component-binding-blowback-b/_config.js +++ b/test/runtime/samples/component-binding-blowback-b/_config.js @@ -1,7 +1,10 @@ export default { - // solo: true, 'skip-ssr': true, + data: { + ids: ['id-0', 'id-1', 'id-2'] + }, + html: `
    1. id-0: value is zero
    2. @@ -10,7 +13,18 @@ export default {
    `, - // test ( assert, component, target, window ) { - - // } + test (assert, component, target) { + component.set({ + ids: ['id-0', 'id-1', 'id-2', 'id-3'] + }); + + assert.htmlEqual(target.innerHTML, ` +
      +
    1. id-0: value is zero
    2. +
    3. id-1: value is one
    4. +
    5. id-2: value is two
    6. +
    7. id-3: value is three
    8. +
    + `); + } }; diff --git a/test/runtime/samples/component-binding-blowback-b/main.html b/test/runtime/samples/component-binding-blowback-b/main.html index 6d32bca34260..bd2a7b3bc644 100644 --- a/test/runtime/samples/component-binding-blowback-b/main.html +++ b/test/runtime/samples/component-binding-blowback-b/main.html @@ -12,7 +12,6 @@ export default { data() { return { - ids: ['id-0', 'id-1', 'id-2'], idToValue: Object.create(null) }; }, From 3f65b8b38fea266b40995a687dd8a2dc8530ea58 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 11 Jul 2017 15:10:04 -0400 Subject: [PATCH 05/11] rename postcreate to aftercreate --- src/generators/dom/index.ts | 4 ++-- src/generators/dom/visitors/Element/addTransitions.ts | 4 ++-- src/shared/index.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/generators/dom/index.ts b/src/generators/dom/index.ts index 554442e71921..79fc94f2eed6 100644 --- a/src/generators/dom/index.ts +++ b/src/generators/dom/index.ts @@ -212,7 +212,7 @@ export default function dom( // this._bindings = []; this._beforecreate = []; this._oncreate = [${templateProperties.oncreate && `oncreate`}]; - this._postcreate = []; + this._aftercreate = []; } ${templateProperties.oncreate && deindent` @@ -239,7 +239,7 @@ export default function dom( @callAll(this._beforecreate); @callAll(this._oncreate); - @callAll(this._postcreate); + @callAll(this._aftercreate); } @assign( ${prototypeBase}, ${proto}); diff --git a/src/generators/dom/visitors/Element/addTransitions.ts b/src/generators/dom/visitors/Element/addTransitions.ts index fa8e97013f81..889cf1eb0b1e 100644 --- a/src/generators/dom/visitors/Element/addTransitions.ts +++ b/src/generators/dom/visitors/Element/addTransitions.ts @@ -23,7 +23,7 @@ export default function addTransitions( const fn = `@template.transitions.${intro.name}`; block.builders.intro.addBlock(deindent` - #component._root._postcreate.push( function () { + #component._root._aftercreate.push( function () { if ( !${name} ) ${name} = @wrapTransition( #component, ${state.name}, ${fn}, ${snippet}, true, null ); ${name}.run( true, function () { #component.fire( 'intro.end', { node: ${state.name} }); @@ -58,7 +58,7 @@ export default function addTransitions( } block.builders.intro.addBlock(deindent` - #component._root._postcreate.push( function () { + #component._root._aftercreate.push( function () { ${introName} = @wrapTransition( #component, ${state.name}, ${fn}, ${snippet}, true, null ); ${introName}.run( true, function () { #component.fire( 'intro.end', { node: ${state.name} }); diff --git a/src/shared/index.js b/src/shared/index.js index 6119edabb657..35d5fe8c9658 100644 --- a/src/shared/index.js +++ b/src/shared/index.js @@ -108,7 +108,7 @@ export function set(newState) { this._set(assign({}, newState)); callAll(this._root._beforecreate); callAll(this._root._oncreate); - callAll(this._root._postcreate); + callAll(this._root._aftercreate); } export function callAll(fns) { From 1733966d186082d98acd9a5be450dcb448607383 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 11 Jul 2017 15:21:18 -0400 Subject: [PATCH 06/11] tidy up --- src/generators/dom/index.ts | 28 +++++++++---------- test/js/index.js | 2 +- .../expected-bundle.js | 2 ++ .../computed-collapsed-if/expected-bundle.js | 2 ++ .../expected-bundle.js | 2 ++ .../event-handlers-custom/expected-bundle.js | 2 ++ .../if-block-no-update/expected-bundle.js | 2 ++ .../if-block-simple/expected-bundle.js | 2 ++ .../non-imported-component/expected-bundle.js | 12 ++++++-- .../non-imported-component/expected.js | 10 +++++-- .../expected-bundle.js | 17 +++++++---- .../onrender-onteardown-rewritten/expected.js | 17 ++++++----- .../expected-bundle.js | 2 ++ 13 files changed, 67 insertions(+), 33 deletions(-) diff --git a/src/generators/dom/index.ts b/src/generators/dom/index.ts index 79fc94f2eed6..de59578f3147 100644 --- a/src/generators/dom/index.ts +++ b/src/generators/dom/index.ts @@ -207,18 +207,16 @@ export default function dom( ${templateProperties.oncreate && `var oncreate = @template.oncreate.bind( this );`} - // TODO maybe only nec if we have components... - if ( !options._root ) { - // this._bindings = []; - this._beforecreate = []; - this._oncreate = [${templateProperties.oncreate && `oncreate`}]; - this._aftercreate = []; - } - - ${templateProperties.oncreate && deindent` - else { - this._root._oncreate.push(oncreate); - } + ${(templateProperties.oncreate || generator.hasComponents || generator.hasComplexBindings || generator.hasIntroTransitions) && deindent` + if ( !options._root ) { + this._oncreate = [${templateProperties.oncreate && `oncreate`}]; + ${(generator.hasComponents || generator.hasComplexBindings) && `this._beforecreate = [];`} + ${(generator.hasComponents || generator.hasIntroTransitions) && `this._aftercreate = [];`} + } ${templateProperties.oncreate && deindent` + else { + this._root._oncreate.push(oncreate); + } + `} `} this._fragment = @create_main_fragment( this._state, this ); @@ -237,9 +235,9 @@ export default function dom( this._fragment.${block.hasIntroMethod ? 'intro' : 'mount'}( options.target, null ); } - @callAll(this._beforecreate); - @callAll(this._oncreate); - @callAll(this._aftercreate); + ${(generator.hasComponents || generator.hasComplexBindings) && `@callAll(this._beforecreate);`} + ${(generator.hasComponents || templateProperties.oncreate) && `@callAll(this._oncreate);`} + ${(generator.hasComponents || generator.hasIntroTransitions) && `@callAll(this._aftercreate);`} } @assign( ${prototypeBase}, ${proto}); diff --git a/test/js/index.js b/test/js/index.js index c8afdbc2c366..512cba41fa71 100644 --- a/test/js/index.js +++ b/test/js/index.js @@ -4,7 +4,7 @@ import * as path from "path"; import { rollup } from "rollup"; import { svelte } from "../helpers.js"; -describe.skip("js", () => { +describe("js", () => { fs.readdirSync("test/js/samples").forEach(dir => { if (dir[0] === ".") return; diff --git a/test/js/samples/collapses-text-around-comments/expected-bundle.js b/test/js/samples/collapses-text-around-comments/expected-bundle.js index ea478745cd20..c6c772388303 100644 --- a/test/js/samples/collapses-text-around-comments/expected-bundle.js +++ b/test/js/samples/collapses-text-around-comments/expected-bundle.js @@ -115,7 +115,9 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); + callAll(this._root._beforecreate); callAll(this._root._oncreate); + callAll(this._root._aftercreate); } function callAll(fns) { diff --git a/test/js/samples/computed-collapsed-if/expected-bundle.js b/test/js/samples/computed-collapsed-if/expected-bundle.js index 5cd719b37293..35b70e410015 100644 --- a/test/js/samples/computed-collapsed-if/expected-bundle.js +++ b/test/js/samples/computed-collapsed-if/expected-bundle.js @@ -91,7 +91,9 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); + callAll(this._root._beforecreate); callAll(this._root._oncreate); + callAll(this._root._aftercreate); } function callAll(fns) { diff --git a/test/js/samples/each-block-changed-check/expected-bundle.js b/test/js/samples/each-block-changed-check/expected-bundle.js index d98ac1db37f7..b5a15f5630ea 100644 --- a/test/js/samples/each-block-changed-check/expected-bundle.js +++ b/test/js/samples/each-block-changed-check/expected-bundle.js @@ -124,7 +124,9 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); + callAll(this._root._beforecreate); callAll(this._root._oncreate); + callAll(this._root._aftercreate); } function callAll(fns) { diff --git a/test/js/samples/event-handlers-custom/expected-bundle.js b/test/js/samples/event-handlers-custom/expected-bundle.js index 3912710a154c..6019667c5173 100644 --- a/test/js/samples/event-handlers-custom/expected-bundle.js +++ b/test/js/samples/event-handlers-custom/expected-bundle.js @@ -109,7 +109,9 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); + callAll(this._root._beforecreate); callAll(this._root._oncreate); + callAll(this._root._aftercreate); } function callAll(fns) { diff --git a/test/js/samples/if-block-no-update/expected-bundle.js b/test/js/samples/if-block-no-update/expected-bundle.js index f00e3816a9ad..53cca6fa20ba 100644 --- a/test/js/samples/if-block-no-update/expected-bundle.js +++ b/test/js/samples/if-block-no-update/expected-bundle.js @@ -115,7 +115,9 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); + callAll(this._root._beforecreate); callAll(this._root._oncreate); + callAll(this._root._aftercreate); } function callAll(fns) { diff --git a/test/js/samples/if-block-simple/expected-bundle.js b/test/js/samples/if-block-simple/expected-bundle.js index 2e2e7e7c097b..9636f3d99ab1 100644 --- a/test/js/samples/if-block-simple/expected-bundle.js +++ b/test/js/samples/if-block-simple/expected-bundle.js @@ -115,7 +115,9 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); + callAll(this._root._beforecreate); callAll(this._root._oncreate); + callAll(this._root._aftercreate); } function callAll(fns) { diff --git a/test/js/samples/non-imported-component/expected-bundle.js b/test/js/samples/non-imported-component/expected-bundle.js index 878bdf223e31..04bd9f8588bb 100644 --- a/test/js/samples/non-imported-component/expected-bundle.js +++ b/test/js/samples/non-imported-component/expected-bundle.js @@ -103,7 +103,9 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); + callAll(this._root._beforecreate); callAll(this._root._oncreate); + callAll(this._root._aftercreate); } function callAll(fns) { @@ -178,7 +180,12 @@ function SvelteComponent ( options ) { this._yield = options._yield; this._torndown = false; - this._oncreate = []; + + if ( !options._root ) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } this._fragment = create_main_fragment( this._state, this ); @@ -187,7 +194,9 @@ function SvelteComponent ( options ) { this._fragment.mount( options.target, null ); } + callAll(this._beforecreate); callAll(this._oncreate); + callAll(this._aftercreate); } assign( SvelteComponent.prototype, proto ); @@ -197,7 +206,6 @@ SvelteComponent.prototype._set = function _set ( newState ) { this._state = assign( {}, oldState, newState ); dispatchObservers( this, this._observers.pre, newState, oldState ); dispatchObservers( this, this._observers.post, newState, oldState ); - callAll(this._oncreate); }; SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = function destroy ( detach ) { diff --git a/test/js/samples/non-imported-component/expected.js b/test/js/samples/non-imported-component/expected.js index c15493059322..61c2cceee186 100644 --- a/test/js/samples/non-imported-component/expected.js +++ b/test/js/samples/non-imported-component/expected.js @@ -62,7 +62,12 @@ function SvelteComponent ( options ) { this._yield = options._yield; this._torndown = false; - this._oncreate = []; + + if ( !options._root ) { + this._oncreate = []; + this._beforecreate = []; + this._aftercreate = []; + } this._fragment = create_main_fragment( this._state, this ); @@ -71,7 +76,9 @@ function SvelteComponent ( options ) { this._fragment.mount( options.target, null ); } + callAll(this._beforecreate); callAll(this._oncreate); + callAll(this._aftercreate); } assign( SvelteComponent.prototype, proto ); @@ -81,7 +88,6 @@ SvelteComponent.prototype._set = function _set ( newState ) { this._state = assign( {}, oldState, newState ); dispatchObservers( this, this._observers.pre, newState, oldState ); dispatchObservers( this, this._observers.post, newState, oldState ); - callAll(this._oncreate); }; SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = function destroy ( detach ) { diff --git a/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js b/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js index e74522a94555..02ccad5144bd 100644 --- a/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js +++ b/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js @@ -91,7 +91,9 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); + callAll(this._root._beforecreate); callAll(this._root._oncreate); + callAll(this._root._aftercreate); } function callAll(fns) { @@ -143,18 +145,21 @@ function SvelteComponent ( options ) { this._torndown = false; + var oncreate = template.oncreate.bind( this ); + + if ( !options._root ) { + this._oncreate = [oncreate]; + } else { + this._root._oncreate.push(oncreate); + } + this._fragment = create_main_fragment( this._state, this ); if ( options.target ) { this._fragment.create(); this._fragment.mount( options.target, null ); } - - if ( options._root ) { - options._root._oncreate.push( template.oncreate.bind( this ) ); - } else { - template.oncreate.call( this ); - } + callAll(this._oncreate); } assign( SvelteComponent.prototype, proto ); diff --git a/test/js/samples/onrender-onteardown-rewritten/expected.js b/test/js/samples/onrender-onteardown-rewritten/expected.js index 96aa37d766d5..ff00f9392859 100644 --- a/test/js/samples/onrender-onteardown-rewritten/expected.js +++ b/test/js/samples/onrender-onteardown-rewritten/expected.js @@ -1,4 +1,4 @@ -import { assign, dispatchObservers, noop, proto } from "svelte/shared.js"; +import { assign, callAll, dispatchObservers, noop, proto } from "svelte/shared.js"; var template = (function () { return { @@ -37,18 +37,21 @@ function SvelteComponent ( options ) { this._torndown = false; + var oncreate = template.oncreate.bind( this ); + + if ( !options._root ) { + this._oncreate = [oncreate]; + } else { + this._root._oncreate.push(oncreate); + } + this._fragment = create_main_fragment( this._state, this ); if ( options.target ) { this._fragment.create(); this._fragment.mount( options.target, null ); } - - if ( options._root ) { - options._root._oncreate.push( template.oncreate.bind( this ) ); - } else { - template.oncreate.call( this ); - } + callAll(this._oncreate); } assign( SvelteComponent.prototype, proto ); diff --git a/test/js/samples/use-elements-as-anchors/expected-bundle.js b/test/js/samples/use-elements-as-anchors/expected-bundle.js index 62a6ac86e000..ec2ceaf4af5a 100644 --- a/test/js/samples/use-elements-as-anchors/expected-bundle.js +++ b/test/js/samples/use-elements-as-anchors/expected-bundle.js @@ -115,7 +115,9 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); + callAll(this._root._beforecreate); callAll(this._root._oncreate); + callAll(this._root._aftercreate); } function callAll(fns) { From 3d51c98ddef4191f0dbccfcc3c4039e7ff1d2fc8 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 11 Jul 2017 15:49:38 -0400 Subject: [PATCH 07/11] make test more stringent --- .../samples/component-binding-blowback-b/_config.js | 13 ++++++++----- .../samples/component-binding-blowback-b/main.html | 10 ++++++++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/test/runtime/samples/component-binding-blowback-b/_config.js b/test/runtime/samples/component-binding-blowback-b/_config.js index ff6d14f20f1d..7f2bd38d9b52 100644 --- a/test/runtime/samples/component-binding-blowback-b/_config.js +++ b/test/runtime/samples/component-binding-blowback-b/_config.js @@ -2,10 +2,11 @@ export default { 'skip-ssr': true, data: { - ids: ['id-0', 'id-1', 'id-2'] + count: 3 }, html: ` +
    1. id-0: value is zero
    2. id-1: value is one
    3. @@ -13,12 +14,14 @@ export default {
    `, - test (assert, component, target) { - component.set({ - ids: ['id-0', 'id-1', 'id-2', 'id-3'] - }); + test (assert, component, target, window) { + const input = target.querySelector('input'); + + input.value = 4; + input.dispatchEvent(new window.Event('input')); assert.htmlEqual(target.innerHTML, ` +
    1. id-0: value is zero
    2. id-1: value is one
    3. diff --git a/test/runtime/samples/component-binding-blowback-b/main.html b/test/runtime/samples/component-binding-blowback-b/main.html index bd2a7b3bc644..4e3ca438139b 100644 --- a/test/runtime/samples/component-binding-blowback-b/main.html +++ b/test/runtime/samples/component-binding-blowback-b/main.html @@ -1,3 +1,5 @@ + +
        {{#each ids as id}} @@ -16,6 +18,14 @@ }; }, + computed: { + ids(count) { + return new Array(count) + .fill(null) + .map((_, i) => 'id-' + i); + } + }, + components: { Nested } From 0a806585b359314011b5b26ee191a1693986fdf0 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Mon, 24 Jul 2017 14:58:27 -0400 Subject: [PATCH 08/11] enforce order of operations --- src/generators/dom/index.ts | 12 +++++++++--- .../dom/visitors/shared/binding/getSetter.ts | 8 ++++---- src/shared/index.js | 3 +++ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/generators/dom/index.ts b/src/generators/dom/index.ts index de59578f3147..c29be14bcc68 100644 --- a/src/generators/dom/index.ts +++ b/src/generators/dom/index.ts @@ -235,9 +235,15 @@ export default function dom( this._fragment.${block.hasIntroMethod ? 'intro' : 'mount'}( options.target, null ); } - ${(generator.hasComponents || generator.hasComplexBindings) && `@callAll(this._beforecreate);`} - ${(generator.hasComponents || templateProperties.oncreate) && `@callAll(this._oncreate);`} - ${(generator.hasComponents || generator.hasIntroTransitions) && `@callAll(this._aftercreate);`} + ${(generator.hasComponents || generator.hasComplexBindings || templateProperties.oncreate || generator.hasIntroTransitions) && deindent` + if ( !options._root ) { + ${generator.hasComponents && `this._block = true;`} + ${(generator.hasComponents || generator.hasComplexBindings) && `@callAll(this._beforecreate);`} + ${(generator.hasComponents || templateProperties.oncreate) && `@callAll(this._oncreate);`} + ${(generator.hasComponents || generator.hasIntroTransitions) && `@callAll(this._aftercreate);`} + ${generator.hasComponents && `this._block = false;`} + } + `} } @assign( ${prototypeBase}, ${proto}); diff --git a/src/generators/dom/visitors/shared/binding/getSetter.ts b/src/generators/dom/visitors/shared/binding/getSetter.ts index 784e1d7302e3..6c25d67a724a 100644 --- a/src/generators/dom/visitors/shared/binding/getSetter.ts +++ b/src/generators/dom/visitors/shared/binding/getSetter.ts @@ -27,10 +27,10 @@ export default function getSetter({ list[index]${tail} = ${value}; ${computed - ? `#component._set({ ${dependencies + ? `#component.set({ ${dependencies .map((prop: string) => `${prop}: state.${prop}`) .join(', ')} });` - : `#component._set({ ${dependencies + : `#component.set({ ${dependencies .map((prop: string) => `${prop}: #component.get( '${prop}' )`) .join(', ')} });`} `; @@ -40,13 +40,13 @@ export default function getSetter({ return deindent` var state = #component.get(); ${snippet} = ${value}; - #component._set({ ${dependencies + #component.set({ ${dependencies .map((prop: string) => `${prop}: state.${prop}`) .join(', ')} }); `; } - return `#component._set({ ${name}: ${value} });`; + return `#component.set({ ${name}: ${value} });`; } function isComputed(node: Node) { diff --git a/src/shared/index.js b/src/shared/index.js index 35d5fe8c9658..0a671d2320a2 100644 --- a/src/shared/index.js +++ b/src/shared/index.js @@ -106,9 +106,12 @@ export function onDev(eventName, handler) { export function set(newState) { this._set(assign({}, newState)); + if (this._root._block) return; + this._root._block = true; callAll(this._root._beforecreate); callAll(this._root._oncreate); callAll(this._root._aftercreate); + this._root._block = false; } export function callAll(fns) { From 3f73f252ace641f811291befc106e0ffdd51d291 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Mon, 24 Jul 2017 14:58:32 -0400 Subject: [PATCH 09/11] update tests --- .../expected-bundle.js | 3 +++ .../computed-collapsed-if/expected-bundle.js | 3 +++ .../each-block-changed-check/expected-bundle.js | 3 +++ .../event-handlers-custom/expected-bundle.js | 3 +++ .../samples/if-block-no-update/expected-bundle.js | 3 +++ test/js/samples/if-block-simple/expected-bundle.js | 3 +++ .../non-imported-component/expected-bundle.js | 13 ++++++++++--- test/js/samples/non-imported-component/expected.js | 10 +++++++--- .../expected-bundle.js | 8 +++++++- .../onrender-onteardown-rewritten/expected.js | 5 ++++- .../use-elements-as-anchors/expected-bundle.js | 3 +++ test/runtime/index.js | 13 ++++++++----- 12 files changed, 57 insertions(+), 13 deletions(-) diff --git a/test/js/samples/collapses-text-around-comments/expected-bundle.js b/test/js/samples/collapses-text-around-comments/expected-bundle.js index c6c772388303..59faec43c046 100644 --- a/test/js/samples/collapses-text-around-comments/expected-bundle.js +++ b/test/js/samples/collapses-text-around-comments/expected-bundle.js @@ -115,9 +115,12 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); + if (this._root._block) return; + this._root._block = true; callAll(this._root._beforecreate); callAll(this._root._oncreate); callAll(this._root._aftercreate); + this._root._block = false; } function callAll(fns) { diff --git a/test/js/samples/computed-collapsed-if/expected-bundle.js b/test/js/samples/computed-collapsed-if/expected-bundle.js index 35b70e410015..6e24c4c1638a 100644 --- a/test/js/samples/computed-collapsed-if/expected-bundle.js +++ b/test/js/samples/computed-collapsed-if/expected-bundle.js @@ -91,9 +91,12 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); + if (this._root._block) return; + this._root._block = true; callAll(this._root._beforecreate); callAll(this._root._oncreate); callAll(this._root._aftercreate); + this._root._block = false; } function callAll(fns) { diff --git a/test/js/samples/each-block-changed-check/expected-bundle.js b/test/js/samples/each-block-changed-check/expected-bundle.js index b5a15f5630ea..8aeafdeb122f 100644 --- a/test/js/samples/each-block-changed-check/expected-bundle.js +++ b/test/js/samples/each-block-changed-check/expected-bundle.js @@ -124,9 +124,12 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); + if (this._root._block) return; + this._root._block = true; callAll(this._root._beforecreate); callAll(this._root._oncreate); callAll(this._root._aftercreate); + this._root._block = false; } function callAll(fns) { diff --git a/test/js/samples/event-handlers-custom/expected-bundle.js b/test/js/samples/event-handlers-custom/expected-bundle.js index 6019667c5173..de7623327543 100644 --- a/test/js/samples/event-handlers-custom/expected-bundle.js +++ b/test/js/samples/event-handlers-custom/expected-bundle.js @@ -109,9 +109,12 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); + if (this._root._block) return; + this._root._block = true; callAll(this._root._beforecreate); callAll(this._root._oncreate); callAll(this._root._aftercreate); + this._root._block = false; } function callAll(fns) { diff --git a/test/js/samples/if-block-no-update/expected-bundle.js b/test/js/samples/if-block-no-update/expected-bundle.js index 53cca6fa20ba..5c46a788ad7e 100644 --- a/test/js/samples/if-block-no-update/expected-bundle.js +++ b/test/js/samples/if-block-no-update/expected-bundle.js @@ -115,9 +115,12 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); + if (this._root._block) return; + this._root._block = true; callAll(this._root._beforecreate); callAll(this._root._oncreate); callAll(this._root._aftercreate); + this._root._block = false; } function callAll(fns) { diff --git a/test/js/samples/if-block-simple/expected-bundle.js b/test/js/samples/if-block-simple/expected-bundle.js index 9636f3d99ab1..723df41e9935 100644 --- a/test/js/samples/if-block-simple/expected-bundle.js +++ b/test/js/samples/if-block-simple/expected-bundle.js @@ -115,9 +115,12 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); + if (this._root._block) return; + this._root._block = true; callAll(this._root._beforecreate); callAll(this._root._oncreate); callAll(this._root._aftercreate); + this._root._block = false; } function callAll(fns) { diff --git a/test/js/samples/non-imported-component/expected-bundle.js b/test/js/samples/non-imported-component/expected-bundle.js index 04bd9f8588bb..1b29740949cf 100644 --- a/test/js/samples/non-imported-component/expected-bundle.js +++ b/test/js/samples/non-imported-component/expected-bundle.js @@ -103,9 +103,12 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); + if (this._root._block) return; + this._root._block = true; callAll(this._root._beforecreate); callAll(this._root._oncreate); callAll(this._root._aftercreate); + this._root._block = false; } function callAll(fns) { @@ -194,9 +197,13 @@ function SvelteComponent ( options ) { this._fragment.mount( options.target, null ); } - callAll(this._beforecreate); - callAll(this._oncreate); - callAll(this._aftercreate); + if ( !options._root ) { + this._block = true; + callAll(this._beforecreate); + callAll(this._oncreate); + callAll(this._aftercreate); + this._block = false; + } } assign( SvelteComponent.prototype, proto ); diff --git a/test/js/samples/non-imported-component/expected.js b/test/js/samples/non-imported-component/expected.js index 61c2cceee186..065ebc0a72cd 100644 --- a/test/js/samples/non-imported-component/expected.js +++ b/test/js/samples/non-imported-component/expected.js @@ -76,9 +76,13 @@ function SvelteComponent ( options ) { this._fragment.mount( options.target, null ); } - callAll(this._beforecreate); - callAll(this._oncreate); - callAll(this._aftercreate); + if ( !options._root ) { + this._block = true; + callAll(this._beforecreate); + callAll(this._oncreate); + callAll(this._aftercreate); + this._block = false; + } } assign( SvelteComponent.prototype, proto ); diff --git a/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js b/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js index 02ccad5144bd..61de8b261e82 100644 --- a/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js +++ b/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js @@ -91,9 +91,12 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); + if (this._root._block) return; + this._root._block = true; callAll(this._root._beforecreate); callAll(this._root._oncreate); callAll(this._root._aftercreate); + this._root._block = false; } function callAll(fns) { @@ -159,7 +162,10 @@ function SvelteComponent ( options ) { this._fragment.create(); this._fragment.mount( options.target, null ); } - callAll(this._oncreate); + + if ( !options._root ) { + callAll(this._oncreate); + } } assign( SvelteComponent.prototype, proto ); diff --git a/test/js/samples/onrender-onteardown-rewritten/expected.js b/test/js/samples/onrender-onteardown-rewritten/expected.js index ff00f9392859..1a1c10f7d613 100644 --- a/test/js/samples/onrender-onteardown-rewritten/expected.js +++ b/test/js/samples/onrender-onteardown-rewritten/expected.js @@ -51,7 +51,10 @@ function SvelteComponent ( options ) { this._fragment.create(); this._fragment.mount( options.target, null ); } - callAll(this._oncreate); + + if ( !options._root ) { + callAll(this._oncreate); + } } assign( SvelteComponent.prototype, proto ); diff --git a/test/js/samples/use-elements-as-anchors/expected-bundle.js b/test/js/samples/use-elements-as-anchors/expected-bundle.js index ec2ceaf4af5a..8a42c00e2a90 100644 --- a/test/js/samples/use-elements-as-anchors/expected-bundle.js +++ b/test/js/samples/use-elements-as-anchors/expected-bundle.js @@ -115,9 +115,12 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); + if (this._root._block) return; + this._root._block = true; callAll(this._root._beforecreate); callAll(this._root._oncreate); callAll(this._root._aftercreate); + this._root._block = false; } function callAll(fns) { diff --git a/test/runtime/index.js b/test/runtime/index.js index 16d5820f0b18..dea60082a3ad 100644 --- a/test/runtime/index.js +++ b/test/runtime/index.js @@ -137,10 +137,9 @@ describe("runtime", () => { throw err; } + let usedObjectAssign = false; Object.assign = () => { - throw new Error( - "cannot use Object.assign in generated code, as it is not supported everywhere" - ); + usedObjectAssign = true; }; global.window = window; @@ -182,14 +181,18 @@ describe("runtime", () => { assert.htmlEqual(target.innerHTML, config.html); } - Object.assign = Object_assign; - if (config.test) { config.test(assert, component, target, window, raf); } else { component.destroy(); assert.equal(target.innerHTML, ""); } + + if (usedObjectAssign) { + throw new Error( + "cannot use Object.assign in generated code, as it is not supported everywhere" + ); + } }) .catch(err => { Object.assign = Object_assign; From 197c7e70d0190daac52a3320e6f07455c8cee84a Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 25 Jul 2017 08:56:51 -0400 Subject: [PATCH 10/11] rename _block to _lock --- src/generators/dom/index.ts | 4 ++-- src/shared/index.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/generators/dom/index.ts b/src/generators/dom/index.ts index c29be14bcc68..bb2313252e1e 100644 --- a/src/generators/dom/index.ts +++ b/src/generators/dom/index.ts @@ -237,11 +237,11 @@ export default function dom( ${(generator.hasComponents || generator.hasComplexBindings || templateProperties.oncreate || generator.hasIntroTransitions) && deindent` if ( !options._root ) { - ${generator.hasComponents && `this._block = true;`} + ${generator.hasComponents && `this._lock = true;`} ${(generator.hasComponents || generator.hasComplexBindings) && `@callAll(this._beforecreate);`} ${(generator.hasComponents || templateProperties.oncreate) && `@callAll(this._oncreate);`} ${(generator.hasComponents || generator.hasIntroTransitions) && `@callAll(this._aftercreate);`} - ${generator.hasComponents && `this._block = false;`} + ${generator.hasComponents && `this._lock = false;`} } `} } diff --git a/src/shared/index.js b/src/shared/index.js index 0a671d2320a2..119f50452b52 100644 --- a/src/shared/index.js +++ b/src/shared/index.js @@ -106,12 +106,12 @@ export function onDev(eventName, handler) { export function set(newState) { this._set(assign({}, newState)); - if (this._root._block) return; - this._root._block = true; + if (this._root._lock) return; + this._root._lock = true; callAll(this._root._beforecreate); callAll(this._root._oncreate); callAll(this._root._aftercreate); - this._root._block = false; + this._root._lock = false; } export function callAll(fns) { From 9085c0a22a05a2f4f5c5ea1eab82b64717f3d2cc Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 25 Jul 2017 11:07:52 -0400 Subject: [PATCH 11/11] update tests --- .../collapses-text-around-comments/expected-bundle.js | 6 +++--- .../samples/computed-collapsed-if/expected-bundle.js | 6 +++--- .../each-block-changed-check/expected-bundle.js | 6 +++--- .../samples/event-handlers-custom/expected-bundle.js | 6 +++--- test/js/samples/if-block-no-update/expected-bundle.js | 6 +++--- test/js/samples/if-block-simple/expected-bundle.js | 6 +++--- .../samples/non-imported-component/expected-bundle.js | 10 +++++----- test/js/samples/non-imported-component/expected.js | 4 ++-- .../onrender-onteardown-rewritten/expected-bundle.js | 6 +++--- .../samples/use-elements-as-anchors/expected-bundle.js | 6 +++--- 10 files changed, 31 insertions(+), 31 deletions(-) diff --git a/test/js/samples/collapses-text-around-comments/expected-bundle.js b/test/js/samples/collapses-text-around-comments/expected-bundle.js index 59faec43c046..535273b636a3 100644 --- a/test/js/samples/collapses-text-around-comments/expected-bundle.js +++ b/test/js/samples/collapses-text-around-comments/expected-bundle.js @@ -115,12 +115,12 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); - if (this._root._block) return; - this._root._block = true; + if (this._root._lock) return; + this._root._lock = true; callAll(this._root._beforecreate); callAll(this._root._oncreate); callAll(this._root._aftercreate); - this._root._block = false; + this._root._lock = false; } function callAll(fns) { diff --git a/test/js/samples/computed-collapsed-if/expected-bundle.js b/test/js/samples/computed-collapsed-if/expected-bundle.js index 6e24c4c1638a..547cb5e958f2 100644 --- a/test/js/samples/computed-collapsed-if/expected-bundle.js +++ b/test/js/samples/computed-collapsed-if/expected-bundle.js @@ -91,12 +91,12 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); - if (this._root._block) return; - this._root._block = true; + if (this._root._lock) return; + this._root._lock = true; callAll(this._root._beforecreate); callAll(this._root._oncreate); callAll(this._root._aftercreate); - this._root._block = false; + this._root._lock = false; } function callAll(fns) { diff --git a/test/js/samples/each-block-changed-check/expected-bundle.js b/test/js/samples/each-block-changed-check/expected-bundle.js index 8aeafdeb122f..47d43b2aeaca 100644 --- a/test/js/samples/each-block-changed-check/expected-bundle.js +++ b/test/js/samples/each-block-changed-check/expected-bundle.js @@ -124,12 +124,12 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); - if (this._root._block) return; - this._root._block = true; + if (this._root._lock) return; + this._root._lock = true; callAll(this._root._beforecreate); callAll(this._root._oncreate); callAll(this._root._aftercreate); - this._root._block = false; + this._root._lock = false; } function callAll(fns) { diff --git a/test/js/samples/event-handlers-custom/expected-bundle.js b/test/js/samples/event-handlers-custom/expected-bundle.js index de7623327543..c916b100782c 100644 --- a/test/js/samples/event-handlers-custom/expected-bundle.js +++ b/test/js/samples/event-handlers-custom/expected-bundle.js @@ -109,12 +109,12 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); - if (this._root._block) return; - this._root._block = true; + if (this._root._lock) return; + this._root._lock = true; callAll(this._root._beforecreate); callAll(this._root._oncreate); callAll(this._root._aftercreate); - this._root._block = false; + this._root._lock = false; } function callAll(fns) { diff --git a/test/js/samples/if-block-no-update/expected-bundle.js b/test/js/samples/if-block-no-update/expected-bundle.js index 5c46a788ad7e..39ea6622f50e 100644 --- a/test/js/samples/if-block-no-update/expected-bundle.js +++ b/test/js/samples/if-block-no-update/expected-bundle.js @@ -115,12 +115,12 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); - if (this._root._block) return; - this._root._block = true; + if (this._root._lock) return; + this._root._lock = true; callAll(this._root._beforecreate); callAll(this._root._oncreate); callAll(this._root._aftercreate); - this._root._block = false; + this._root._lock = false; } function callAll(fns) { diff --git a/test/js/samples/if-block-simple/expected-bundle.js b/test/js/samples/if-block-simple/expected-bundle.js index 723df41e9935..382c2fd8d35c 100644 --- a/test/js/samples/if-block-simple/expected-bundle.js +++ b/test/js/samples/if-block-simple/expected-bundle.js @@ -115,12 +115,12 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); - if (this._root._block) return; - this._root._block = true; + if (this._root._lock) return; + this._root._lock = true; callAll(this._root._beforecreate); callAll(this._root._oncreate); callAll(this._root._aftercreate); - this._root._block = false; + this._root._lock = false; } function callAll(fns) { diff --git a/test/js/samples/non-imported-component/expected-bundle.js b/test/js/samples/non-imported-component/expected-bundle.js index 1b29740949cf..91a8b8c29215 100644 --- a/test/js/samples/non-imported-component/expected-bundle.js +++ b/test/js/samples/non-imported-component/expected-bundle.js @@ -103,12 +103,12 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); - if (this._root._block) return; - this._root._block = true; + if (this._root._lock) return; + this._root._lock = true; callAll(this._root._beforecreate); callAll(this._root._oncreate); callAll(this._root._aftercreate); - this._root._block = false; + this._root._lock = false; } function callAll(fns) { @@ -198,11 +198,11 @@ function SvelteComponent ( options ) { } if ( !options._root ) { - this._block = true; + this._lock = true; callAll(this._beforecreate); callAll(this._oncreate); callAll(this._aftercreate); - this._block = false; + this._lock = false; } } diff --git a/test/js/samples/non-imported-component/expected.js b/test/js/samples/non-imported-component/expected.js index 065ebc0a72cd..787e62c54b8a 100644 --- a/test/js/samples/non-imported-component/expected.js +++ b/test/js/samples/non-imported-component/expected.js @@ -77,11 +77,11 @@ function SvelteComponent ( options ) { } if ( !options._root ) { - this._block = true; + this._lock = true; callAll(this._beforecreate); callAll(this._oncreate); callAll(this._aftercreate); - this._block = false; + this._lock = false; } } diff --git a/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js b/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js index 61de8b261e82..25fae9ba8c4b 100644 --- a/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js +++ b/test/js/samples/onrender-onteardown-rewritten/expected-bundle.js @@ -91,12 +91,12 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); - if (this._root._block) return; - this._root._block = true; + if (this._root._lock) return; + this._root._lock = true; callAll(this._root._beforecreate); callAll(this._root._oncreate); callAll(this._root._aftercreate); - this._root._block = false; + this._root._lock = false; } function callAll(fns) { diff --git a/test/js/samples/use-elements-as-anchors/expected-bundle.js b/test/js/samples/use-elements-as-anchors/expected-bundle.js index 8a42c00e2a90..32cd0203c230 100644 --- a/test/js/samples/use-elements-as-anchors/expected-bundle.js +++ b/test/js/samples/use-elements-as-anchors/expected-bundle.js @@ -115,12 +115,12 @@ function on(eventName, handler) { function set(newState) { this._set(assign({}, newState)); - if (this._root._block) return; - this._root._block = true; + if (this._root._lock) return; + this._root._lock = true; callAll(this._root._beforecreate); callAll(this._root._oncreate); callAll(this._root._aftercreate); - this._root._block = false; + this._root._lock = false; } function callAll(fns) {