From 16e3574bfb8a7ab358ee82c592641b6c097658b9 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 1 Mar 2017 11:36:54 -0500 Subject: [PATCH 1/4] warn on onrender/onteardown, replace with oncreate/ondestroy (#40) --- src/generators/Generator.js | 8 +++---- src/generators/dom/index.js | 23 +++++++++++++++---- src/generators/server-side-rendering/index.js | 2 +- src/validate/index.js | 2 -- src/validate/js/index.js | 17 +++++++++++--- src/validate/js/propValidators/index.js | 4 ++++ src/validate/js/propValidators/oncreate.js | 9 ++++++++ src/validate/js/propValidators/ondestroy.js | 9 ++++++++ src/validate/js/propValidators/onrender.js | 9 +++----- src/validate/js/propValidators/onteardown.js | 9 +++----- 10 files changed, 65 insertions(+), 27 deletions(-) create mode 100644 src/validate/js/propValidators/oncreate.js create mode 100644 src/validate/js/propValidators/ondestroy.js diff --git a/src/generators/Generator.js b/src/generators/Generator.js index 20618ee60e..6c27163ecf 100644 --- a/src/generators/Generator.js +++ b/src/generators/Generator.js @@ -243,7 +243,7 @@ export default class Generator { } defaultExport.declaration.properties.forEach( prop => { - templateProperties[ prop.key.name ] = prop.value; + templateProperties[ prop.key.name ] = prop; }); this.code.prependRight( js.content.start, 'var template = (function () {' ); @@ -255,7 +255,7 @@ export default class Generator { [ 'helpers', 'events', 'components' ].forEach( key => { if ( templateProperties[ key ] ) { - templateProperties[ key ].properties.forEach( prop => { + templateProperties[ key ].value.properties.forEach( prop => { this[ key ][ prop.key.name ] = prop.value; }); } @@ -264,7 +264,7 @@ export default class Generator { if ( templateProperties.computed ) { const dependencies = new Map(); - templateProperties.computed.properties.forEach( prop => { + templateProperties.computed.value.properties.forEach( prop => { const key = prop.key.name; const value = prop.value; @@ -286,7 +286,7 @@ export default class Generator { computations.push({ key, deps }); } - templateProperties.computed.properties.forEach( prop => visit( prop.key.name ) ); + templateProperties.computed.value.properties.forEach( prop => visit( prop.key.name ) ); } } diff --git a/src/generators/dom/index.js b/src/generators/dom/index.js index 815d053cb3..b208b1e122 100644 --- a/src/generators/dom/index.js +++ b/src/generators/dom/index.js @@ -156,6 +156,19 @@ export default function dom ( parsed, source, options, names ) { const { computations, templateProperties } = generator.parseJs(); + // Remove these after version 2 + if ( templateProperties.onrender ) { + const { key } = templateProperties.onrender; + generator.code.overwrite( key.start, key.end, 'oncreate', true ); + templateProperties.oncreate = templateProperties.onrender; + } + + if ( templateProperties.onteardown ) { + const { key } = templateProperties.onteardown; + generator.code.overwrite( key.start, key.end, 'ondestroy', true ); + templateProperties.ondestroy = templateProperties.onteardown; + } + generator.imports.forEach( node => { node.specifiers.forEach( specifier => { generator.importedNames[ specifier.local.name ] = true; @@ -164,7 +177,7 @@ export default function dom ( parsed, source, options, names ) { let namespace = null; if ( templateProperties.namespace ) { - const ns = templateProperties.namespace.value; + const ns = templateProperties.namespace.value.value; namespace = namespaces[ ns ] || ns; // TODO remove the namespace property from the generated code, it's unused past this point @@ -281,12 +294,12 @@ export default function dom ( parsed, source, options, names ) { builders._set.addBlock( statement ); } - if ( templateProperties.onrender ) { + if ( templateProperties.oncreate ) { builders.init.addBlock( deindent` if ( options._root ) { - options._root._renderHooks.push({ fn: template.onrender, context: this }); + options._root._renderHooks.push({ fn: template.oncreate, context: this }); } else { - template.onrender.call( this ); + template.oncreate.call( this ); } ` ); } @@ -348,7 +361,7 @@ export default function dom ( parsed, source, options, names ) { }; ${name}.prototype.teardown = function teardown ( detach ) { - this.fire( 'teardown' );${templateProperties.onteardown ? `\ntemplate.onteardown.call( this );` : ``} + this.fire( 'teardown' );${templateProperties.ondestroy ? `\ntemplate.ondestroy.call( this );` : ``} this._fragment.teardown( detach !== false ); this._fragment = null; diff --git a/src/generators/server-side-rendering/index.js b/src/generators/server-side-rendering/index.js index a12366cc2d..0e42b49dfa 100644 --- a/src/generators/server-side-rendering/index.js +++ b/src/generators/server-side-rendering/index.js @@ -114,7 +114,7 @@ export default function ssr ( parsed, source, options, names ) { } ` ); - templateProperties.components.properties.forEach( prop => { + templateProperties.components.value.properties.forEach( prop => { builders.renderCss.addLine( `addComponent( template.components.${prop.key.name} );` ); }); } diff --git a/src/validate/index.js b/src/validate/index.js index 6e34a50f88..d16c83708a 100644 --- a/src/validate/index.js +++ b/src/validate/index.js @@ -36,8 +36,6 @@ export default function validate ( parsed, source, { onerror, onwarn, name, file }); }, - templateProperties: {}, - names: [], namespace: null diff --git a/src/validate/js/index.js b/src/validate/js/index.js index bc3ab784f1..0e6d0488f1 100644 --- a/src/validate/js/index.js +++ b/src/validate/js/index.js @@ -23,10 +23,21 @@ export default function validateJs ( validator, js ) { checkForComputedKeys( validator, node.declaration.properties ); checkForDupes( validator, node.declaration.properties ); + const templateProperties = {}; + node.declaration.properties.forEach( prop => { - validator.templateProperties[ prop.key.name ] = prop; + templateProperties[ prop.key.name ] = prop; }); + // Remove these checks in version 2 + if ( templateProperties.oncreate && templateProperties.onrender ) { + validator.error( 'Cannot have both oncreate and onrender', templateProperties.onrender.start ); + } + + if ( templateProperties.ondestroy && templateProperties.onteardown ) { + validator.error( 'Cannot have both ondestroy and onteardown', templateProperties.onteardown.start ); + } + // ensure all exported props are valid node.declaration.properties.forEach( prop => { const propValidator = propValidators[ prop.key.name ]; @@ -45,8 +56,8 @@ export default function validateJs ( validator, js ) { } }); - if ( validator.templateProperties.namespace ) { - const ns = validator.templateProperties.namespace.value.value; + if ( templateProperties.namespace ) { + const ns = templateProperties.namespace.value.value; validator.namespace = namespaces[ ns ] || ns; } diff --git a/src/validate/js/propValidators/index.js b/src/validate/js/propValidators/index.js index 655df8d3cc..0d5f6d8ffc 100644 --- a/src/validate/js/propValidators/index.js +++ b/src/validate/js/propValidators/index.js @@ -1,5 +1,7 @@ import data from './data.js'; import computed from './computed.js'; +import oncreate from './oncreate.js'; +import ondestroy from './ondestroy.js'; import onrender from './onrender.js'; import onteardown from './onteardown.js'; import helpers from './helpers.js'; @@ -11,6 +13,8 @@ import namespace from './namespace.js'; export default { data, computed, + oncreate, + ondestroy, onrender, onteardown, helpers, diff --git a/src/validate/js/propValidators/oncreate.js b/src/validate/js/propValidators/oncreate.js new file mode 100644 index 0000000000..3d863ec726 --- /dev/null +++ b/src/validate/js/propValidators/oncreate.js @@ -0,0 +1,9 @@ +import usesThisOrArguments from '../utils/usesThisOrArguments.js'; + +export default function oncreate ( validator, prop ) { + if ( prop.value.type === 'ArrowFunctionExpression' ) { + if ( usesThisOrArguments( prop.value.body ) ) { + validator.error( `'oncreate' should be a function expression, not an arrow function expression`, prop.start ); + } + } +} diff --git a/src/validate/js/propValidators/ondestroy.js b/src/validate/js/propValidators/ondestroy.js new file mode 100644 index 0000000000..7ce61e223d --- /dev/null +++ b/src/validate/js/propValidators/ondestroy.js @@ -0,0 +1,9 @@ +import usesThisOrArguments from '../utils/usesThisOrArguments.js'; + +export default function onteardown ( validator, prop ) { + if ( prop.value.type === 'ArrowFunctionExpression' ) { + if ( usesThisOrArguments( prop.value.body ) ) { + validator.error( `'onteardown' should be a function expression, not an arrow function expression`, prop.start ); + } + } +} diff --git a/src/validate/js/propValidators/onrender.js b/src/validate/js/propValidators/onrender.js index 33693be8f1..4f0cad4fbb 100644 --- a/src/validate/js/propValidators/onrender.js +++ b/src/validate/js/propValidators/onrender.js @@ -1,9 +1,6 @@ -import usesThisOrArguments from '../utils/usesThisOrArguments.js'; +import oncreate from './oncreate.js'; export default function onrender ( validator, prop ) { - if ( prop.value.type === 'ArrowFunctionExpression' ) { - if ( usesThisOrArguments( prop.value.body ) ) { - validator.error( `'onrender' should be a function expression, not an arrow function expression`, prop.start ); - } - } + validator.warn( `'onrender' has been deprecated in favour of 'oncreate', and will cause an error in Svelte 2.x`, prop.start ); + oncreate( validator, prop ); } diff --git a/src/validate/js/propValidators/onteardown.js b/src/validate/js/propValidators/onteardown.js index 7ce61e223d..c1038d4365 100644 --- a/src/validate/js/propValidators/onteardown.js +++ b/src/validate/js/propValidators/onteardown.js @@ -1,9 +1,6 @@ -import usesThisOrArguments from '../utils/usesThisOrArguments.js'; +import ondestroy from './ondestroy.js'; export default function onteardown ( validator, prop ) { - if ( prop.value.type === 'ArrowFunctionExpression' ) { - if ( usesThisOrArguments( prop.value.body ) ) { - validator.error( `'onteardown' should be a function expression, not an arrow function expression`, prop.start ); - } - } + validator.warn( `'onteardown' has been deprecated in favour of 'ondestroy', and will cause an error in Svelte 2.x`, prop.start ); + ondestroy( validator, prop ); } From 543ee2f87064741de7ebb5911e6bc119162051ed Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 1 Mar 2017 11:45:55 -0500 Subject: [PATCH 2/4] update tests --- src/validate/js/propValidators/ondestroy.js | 4 ++-- test/generator/component-ref/Widget.html | 2 +- test/generator/lifecycle-events/main.html | 4 ++-- test/generator/onrender-chain/Item.html | 2 +- .../onrender-fires-when-ready-nested/Widget.html | 2 +- .../generator/onrender-fires-when-ready-nested/_config.js | 2 +- test/generator/onrender-fires-when-ready/Widget.html | 2 +- test/generator/onrender-fires-when-ready/_config.js | 2 +- test/generator/set-in-observe-dedupes-renders/Widget.html | 2 +- test/generator/set-in-observe-dedupes-renders/main.html | 2 +- test/generator/set-in-observe/_config.js | 2 +- test/generator/set-in-observe/main.html | 2 +- test/generator/set-in-onrender/_config.js | 2 +- test/generator/set-in-onrender/main.html | 2 +- test/sourcemaps/script/input.html | 2 +- .../errors.json | 0 test/validator/oncreate-arrow-no-this/input.html | 5 +++++ .../errors.json | 2 +- .../input.html | 2 +- .../errors.json | 0 test/validator/ondestroy-arrow-no-this/input.html | 5 +++++ test/validator/ondestroy-arrow-this/errors.json | 8 ++++++++ .../input.html | 2 +- test/validator/onrender-arrow-no-this/input.html | 5 ----- test/validator/onteardown-arrow-no-this/input.html | 5 ----- test/validator/onteardown-arrow-this/errors.json | 8 -------- 26 files changed, 38 insertions(+), 38 deletions(-) rename test/validator/{onrender-arrow-no-this => oncreate-arrow-no-this}/errors.json (100%) create mode 100644 test/validator/oncreate-arrow-no-this/input.html rename test/validator/{onrender-arrow-this => oncreate-arrow-this}/errors.json (57%) rename test/validator/{onrender-arrow-this => oncreate-arrow-this}/input.html (77%) rename test/validator/{onteardown-arrow-no-this => ondestroy-arrow-no-this}/errors.json (100%) create mode 100644 test/validator/ondestroy-arrow-no-this/input.html create mode 100644 test/validator/ondestroy-arrow-this/errors.json rename test/validator/{onteardown-arrow-this => ondestroy-arrow-this}/input.html (75%) delete mode 100644 test/validator/onrender-arrow-no-this/input.html delete mode 100644 test/validator/onteardown-arrow-no-this/input.html delete mode 100644 test/validator/onteardown-arrow-this/errors.json diff --git a/src/validate/js/propValidators/ondestroy.js b/src/validate/js/propValidators/ondestroy.js index 7ce61e223d..3471034178 100644 --- a/src/validate/js/propValidators/ondestroy.js +++ b/src/validate/js/propValidators/ondestroy.js @@ -1,9 +1,9 @@ import usesThisOrArguments from '../utils/usesThisOrArguments.js'; -export default function onteardown ( validator, prop ) { +export default function ondestroy ( validator, prop ) { if ( prop.value.type === 'ArrowFunctionExpression' ) { if ( usesThisOrArguments( prop.value.body ) ) { - validator.error( `'onteardown' should be a function expression, not an arrow function expression`, prop.start ); + validator.error( `'ondestroy' should be a function expression, not an arrow function expression`, prop.start ); } } } diff --git a/test/generator/component-ref/Widget.html b/test/generator/component-ref/Widget.html index c5a462601a..c8cf786cc8 100644 --- a/test/generator/component-ref/Widget.html +++ b/test/generator/component-ref/Widget.html @@ -2,7 +2,7 @@ diff --git a/test/validator/onrender-arrow-this/errors.json b/test/validator/oncreate-arrow-this/errors.json similarity index 57% rename from test/validator/onrender-arrow-this/errors.json rename to test/validator/oncreate-arrow-this/errors.json index 5cc9b2c78d..06d020a4f8 100644 --- a/test/validator/onrender-arrow-this/errors.json +++ b/test/validator/oncreate-arrow-this/errors.json @@ -1,5 +1,5 @@ [{ - "message": "'onrender' should be a function expression, not an arrow function expression", + "message": "'oncreate' should be a function expression, not an arrow function expression", "pos": 29, "loc": { "line": 3, diff --git a/test/validator/onrender-arrow-this/input.html b/test/validator/oncreate-arrow-this/input.html similarity index 77% rename from test/validator/onrender-arrow-this/input.html rename to test/validator/oncreate-arrow-this/input.html index e4283e60ba..36d36b698d 100644 --- a/test/validator/onrender-arrow-this/input.html +++ b/test/validator/oncreate-arrow-this/input.html @@ -1,6 +1,6 @@ diff --git a/test/validator/ondestroy-arrow-this/errors.json b/test/validator/ondestroy-arrow-this/errors.json new file mode 100644 index 0000000000..98e176f58f --- /dev/null +++ b/test/validator/ondestroy-arrow-this/errors.json @@ -0,0 +1,8 @@ +[{ + "message": "'ondestroy' should be a function expression, not an arrow function expression", + "pos": 29, + "loc": { + "line": 3, + "column": 2 + } +}] diff --git a/test/validator/onteardown-arrow-this/input.html b/test/validator/ondestroy-arrow-this/input.html similarity index 75% rename from test/validator/onteardown-arrow-this/input.html rename to test/validator/ondestroy-arrow-this/input.html index ac2f1d7e8b..2f5df93962 100644 --- a/test/validator/onteardown-arrow-this/input.html +++ b/test/validator/ondestroy-arrow-this/input.html @@ -1,6 +1,6 @@ diff --git a/test/validator/onteardown-arrow-no-this/input.html b/test/validator/onteardown-arrow-no-this/input.html deleted file mode 100644 index a742898edb..0000000000 --- a/test/validator/onteardown-arrow-no-this/input.html +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/test/validator/onteardown-arrow-this/errors.json b/test/validator/onteardown-arrow-this/errors.json deleted file mode 100644 index 0596578b95..0000000000 --- a/test/validator/onteardown-arrow-this/errors.json +++ /dev/null @@ -1,8 +0,0 @@ -[{ - "message": "'onteardown' should be a function expression, not an arrow function expression", - "pos": 29, - "loc": { - "line": 3, - "column": 2 - } -}] From 1736498bde986bbb4a9a430913934f60d85c529b Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 1 Mar 2017 11:55:59 -0500 Subject: [PATCH 3/4] add component.destroy() as alias of component.teardown(), to align with ondestroy --- src/generators/dom/index.js | 3 ++- src/generators/dom/visitors/Component.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/generators/dom/index.js b/src/generators/dom/index.js index b208b1e122..69105e8b2a 100644 --- a/src/generators/dom/index.js +++ b/src/generators/dom/index.js @@ -355,12 +355,13 @@ export default function dom ( parsed, source, options, names ) { ${name}.prototype._flush = ${shared._flush}; ` ); + // TODO deprecate component.teardown() builders.main.addBlock( deindent` ${name}.prototype._set = function _set ( newState ) { ${builders._set} }; - ${name}.prototype.teardown = function teardown ( detach ) { + ${name}.prototype.teardown = ${name}.prototype.destroy = function destroy ( detach ) { this.fire( 'teardown' );${templateProperties.ondestroy ? `\ntemplate.ondestroy.call( this );` : ``} this._fragment.teardown( detach !== false ); diff --git a/src/generators/dom/visitors/Component.js b/src/generators/dom/visitors/Component.js index a7d114cbe6..edd6a5209c 100644 --- a/src/generators/dom/visitors/Component.js +++ b/src/generators/dom/visitors/Component.js @@ -137,7 +137,7 @@ export default { ` ); } - generator.current.builders.teardown.addLine( `${name}.teardown( ${isToplevel ? 'detach' : 'false'} );` ); + generator.current.builders.teardown.addLine( `${name}.destroy( ${isToplevel ? 'detach' : 'false'} );` ); generator.current.builders.init.addBlock( local.init ); if ( !local.update.isEmpty() ) generator.current.builders.update.addBlock( local.update ); From d6962b3ff10857d2465ce1cde989e49927b068b7 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 1 Mar 2017 11:57:41 -0500 Subject: [PATCH 4/4] use component.destroy() in tests instead of component.teardown() --- test/formats.js | 6 +++--- test/generate.js | 2 +- test/generator/binding-select-initial-value/_config.js | 2 +- test/generator/component-binding-each-nested/_config.js | 2 +- test/generator/component-binding-each/_config.js | 2 +- test/generator/component-events-each/_config.js | 2 +- test/generator/component-yield-multiple-in-if/_config.js | 2 +- test/generator/computed-values-default/_config.js | 2 +- test/generator/computed-values/_config.js | 2 +- test/generator/deconflict-builtins/_config.js | 2 +- test/generator/destructuring/_config.js | 2 +- test/generator/each-block-keyed/_config.js | 2 +- test/generator/events-custom/_config.js | 2 +- test/generator/events-lifecycle/_config.js | 2 +- test/generator/hello-world/_config.js | 2 +- test/generator/if-block-elseif-text/_config.js | 2 +- test/generator/if-block-elseif/_config.js | 2 +- test/generator/lifecycle-events/_config.js | 2 +- test/generator/onrender-chain/_config.js | 2 +- test/generator/onrender-fires-when-ready/_config.js | 2 +- test/generator/raw-mustaches-preserved/_config.js | 2 +- test/generator/raw-mustaches/_config.js | 2 +- test/generator/select/_config.js | 2 +- test/generator/set-in-observe-dedupes-renders/_config.js | 2 +- test/generator/svg-attributes/_config.js | 2 +- test/generator/svg-class/_config.js | 2 +- test/generator/svg-each-block-namespace/_config.js | 2 +- test/generator/svg-xlink/_config.js | 2 +- 28 files changed, 30 insertions(+), 30 deletions(-) diff --git a/test/formats.js b/test/formats.js index a712c4b7a4..9b803cadcc 100644 --- a/test/formats.js +++ b/test/formats.js @@ -17,7 +17,7 @@ function testAmd ( code, expectedId, dependencies, html ) { assert.htmlEqual( main.innerHTML, html ); - component.teardown(); + component.destroy(); } define.amd = true; @@ -44,7 +44,7 @@ function testCjs ( code, dependencyById, html ) { assert.htmlEqual( main.innerHTML, html ); - component.teardown(); + component.destroy(); }); } @@ -59,7 +59,7 @@ function testIife ( code, name, globals, html ) { assert.htmlEqual( main.innerHTML, html ); - component.teardown(); + component.destroy(); }); } diff --git a/test/generate.js b/test/generate.js index 7adba3c61d..1f5bafcd01 100644 --- a/test/generate.js +++ b/test/generate.js @@ -98,7 +98,7 @@ describe( 'generate', () => { if ( config.test ) { config.test( assert, component, target, window ); } else { - component.teardown(); + component.destroy(); assert.equal( target.innerHTML, '' ); } }) diff --git a/test/generator/binding-select-initial-value/_config.js b/test/generator/binding-select-initial-value/_config.js index b49c1135af..f6b685fd7e 100644 --- a/test/generator/binding-select-initial-value/_config.js +++ b/test/generator/binding-select-initial-value/_config.js @@ -24,6 +24,6 @@ export default { assert.equal( select.value, 'b' ); assert.ok( options[1].selected ); - component.teardown(); + component.destroy(); } }; diff --git a/test/generator/component-binding-each-nested/_config.js b/test/generator/component-binding-each-nested/_config.js index ab5cbef585..536996e869 100644 --- a/test/generator/component-binding-each-nested/_config.js +++ b/test/generator/component-binding-each-nested/_config.js @@ -17,6 +17,6 @@ export default {

blah, bar, baz

` ); - component.teardown(); + component.destroy(); } }; diff --git a/test/generator/component-binding-each/_config.js b/test/generator/component-binding-each/_config.js index 3cb8d05bc9..d42460aff0 100644 --- a/test/generator/component-binding-each/_config.js +++ b/test/generator/component-binding-each/_config.js @@ -17,6 +17,6 @@ export default {

blah, bar, baz

` ); - component.teardown(); + component.destroy(); } }; diff --git a/test/generator/component-events-each/_config.js b/test/generator/component-events-each/_config.js index 25635556a0..e7efe6fbff 100644 --- a/test/generator/component-events-each/_config.js +++ b/test/generator/component-events-each/_config.js @@ -22,6 +22,6 @@ export default { buttons[2].dispatchEvent( event ); assert.deepEqual( clicks, [ 'a', 'c' ]); - component.teardown(); + component.destroy(); } }; diff --git a/test/generator/component-yield-multiple-in-if/_config.js b/test/generator/component-yield-multiple-in-if/_config.js index 58e0ecfabc..1460962e7a 100644 --- a/test/generator/component-yield-multiple-in-if/_config.js +++ b/test/generator/component-yield-multiple-in-if/_config.js @@ -7,6 +7,6 @@ export default { component.set({ arriving: false }); assert.htmlEqual( target.innerHTML, `

Goodbye

` ); - component.teardown(); + component.destroy(); } }; diff --git a/test/generator/computed-values-default/_config.js b/test/generator/computed-values-default/_config.js index 9d761d8915..63db59a8a3 100644 --- a/test/generator/computed-values-default/_config.js +++ b/test/generator/computed-values-default/_config.js @@ -4,6 +4,6 @@ export default { test ( assert, component, target ) { component.set({ a: 2 }); assert.equal( target.innerHTML, '

4

' ); - component.teardown(); + component.destroy(); } }; diff --git a/test/generator/computed-values/_config.js b/test/generator/computed-values/_config.js index b5f7112fa8..8425cba4ff 100644 --- a/test/generator/computed-values/_config.js +++ b/test/generator/computed-values/_config.js @@ -5,6 +5,6 @@ export default { assert.equal( component.get( 'c' ), 5 ); assert.equal( component.get( 'cSquared' ), 25 ); assert.equal( target.innerHTML, '

3 + 2 = 5

\n

5 * 5 = 25

' ); - component.teardown(); + component.destroy(); } }; diff --git a/test/generator/deconflict-builtins/_config.js b/test/generator/deconflict-builtins/_config.js index 14927e7ad3..5ad7a44210 100644 --- a/test/generator/deconflict-builtins/_config.js +++ b/test/generator/deconflict-builtins/_config.js @@ -3,6 +3,6 @@ export default { test ( assert, component ) { assert.equal( component.get( 'foo' ), 'got' ); - component.teardown(); + component.destroy(); } }; \ No newline at end of file diff --git a/test/generator/destructuring/_config.js b/test/generator/destructuring/_config.js index f8a46d1810..77308e36b1 100644 --- a/test/generator/destructuring/_config.js +++ b/test/generator/destructuring/_config.js @@ -22,6 +22,6 @@ export default { assert.equal( count, 1 ); assert.equal( number, 42 ); - component.teardown(); + component.destroy(); } }; \ No newline at end of file diff --git a/test/generator/each-block-keyed/_config.js b/test/generator/each-block-keyed/_config.js index 094c2f1066..35b47f5be8 100644 --- a/test/generator/each-block-keyed/_config.js +++ b/test/generator/each-block-keyed/_config.js @@ -23,6 +23,6 @@ export default { assert.ok( !target.contains( p1 ), 'first

element should be removed' ); assert.equal( p2, p3, 'second

element should be retained' ); - component.teardown(); + component.destroy(); } }; diff --git a/test/generator/events-custom/_config.js b/test/generator/events-custom/_config.js index ed86a9300d..9fe6bbb6c7 100644 --- a/test/generator/events-custom/_config.js +++ b/test/generator/events-custom/_config.js @@ -12,6 +12,6 @@ export default { component.fire( 'foo', expected ); assert.equal( count, 1 ); - component.teardown(); + component.destroy(); } }; diff --git a/test/generator/events-lifecycle/_config.js b/test/generator/events-lifecycle/_config.js index 3a9677fca1..3303728f51 100644 --- a/test/generator/events-lifecycle/_config.js +++ b/test/generator/events-lifecycle/_config.js @@ -7,7 +7,7 @@ export default { count += 1; }); - component.teardown(); + component.destroy(); assert.equal( count, 1 ); } }; diff --git a/test/generator/hello-world/_config.js b/test/generator/hello-world/_config.js index cc4f568358..49d6f03776 100644 --- a/test/generator/hello-world/_config.js +++ b/test/generator/hello-world/_config.js @@ -9,7 +9,7 @@ export default { component.set({ name: 'everybody' }); assert.htmlEqual( target.innerHTML, '

Hello everybody!

' ); - component.teardown(); + component.destroy(); assert.htmlEqual( target.innerHTML, '' ); } }; diff --git a/test/generator/if-block-elseif-text/_config.js b/test/generator/if-block-elseif-text/_config.js index 9ddec8563a..89c8b011a9 100644 --- a/test/generator/if-block-elseif-text/_config.js +++ b/test/generator/if-block-elseif-text/_config.js @@ -18,6 +18,6 @@ export default { before-else-after ` ); - component.teardown(); + component.destroy(); } }; diff --git a/test/generator/if-block-elseif/_config.js b/test/generator/if-block-elseif/_config.js index 50f6b7eac9..ec24f3dd94 100644 --- a/test/generator/if-block-elseif/_config.js +++ b/test/generator/if-block-elseif/_config.js @@ -18,6 +18,6 @@ export default {

x is between 5 and 10

` ); - component.teardown(); + component.destroy(); } }; diff --git a/test/generator/lifecycle-events/_config.js b/test/generator/lifecycle-events/_config.js index 457d888b06..3dcb0d5192 100644 --- a/test/generator/lifecycle-events/_config.js +++ b/test/generator/lifecycle-events/_config.js @@ -1,7 +1,7 @@ export default { test ( assert, component ) { assert.deepEqual( component.events, [ 'render' ]); - component.teardown(); + component.destroy(); assert.deepEqual( component.events, [ 'render', 'teardown' ]); } }; diff --git a/test/generator/onrender-chain/_config.js b/test/generator/onrender-chain/_config.js index cb3bab34a3..1bbf616117 100644 --- a/test/generator/onrender-chain/_config.js +++ b/test/generator/onrender-chain/_config.js @@ -12,6 +12,6 @@ export default { 12345 ` ); - component.teardown(); + component.destroy(); } }; diff --git a/test/generator/onrender-fires-when-ready/_config.js b/test/generator/onrender-fires-when-ready/_config.js index 5776e23915..d70d2c6e53 100644 --- a/test/generator/onrender-fires-when-ready/_config.js +++ b/test/generator/onrender-fires-when-ready/_config.js @@ -7,6 +7,6 @@ export default { component.set({ foo: true }); assert.htmlEqual( target.innerHTML, `

true

\n

true

` ); - component.teardown(); + component.destroy(); } }; diff --git a/test/generator/raw-mustaches-preserved/_config.js b/test/generator/raw-mustaches-preserved/_config.js index 698a58f911..4d3971d7e9 100644 --- a/test/generator/raw-mustaches-preserved/_config.js +++ b/test/generator/raw-mustaches-preserved/_config.js @@ -16,6 +16,6 @@ export default { assert.equal( target.innerHTML, `
${ns}

does not change

${ns}
` ); assert.strictEqual( target.querySelector( 'p' ), p ); - component.teardown(); + component.destroy(); } }; diff --git a/test/generator/raw-mustaches/_config.js b/test/generator/raw-mustaches/_config.js index 8b7767d6d1..22269ea975 100644 --- a/test/generator/raw-mustaches/_config.js +++ b/test/generator/raw-mustaches/_config.js @@ -14,7 +14,7 @@ export default { assert.equal( target.innerHTML, `before${ns}${ns}after` ); component.set({ raw: 'how about unclosed elements?' }); assert.equal( target.innerHTML, `before${ns}how about unclosed elements?${ns}after` ); - component.teardown(); + component.destroy(); assert.equal( target.innerHTML, '' ); } }; diff --git a/test/generator/select/_config.js b/test/generator/select/_config.js index e0023dea9e..8fffd0d25d 100644 --- a/test/generator/select/_config.js +++ b/test/generator/select/_config.js @@ -25,7 +25,7 @@ export default { assert.equal( target.querySelector( 'select' ).value, 'a' ); - component.teardown(); + component.destroy(); assert.htmlEqual( target.innerHTML, '' ); } }; diff --git a/test/generator/set-in-observe-dedupes-renders/_config.js b/test/generator/set-in-observe-dedupes-renders/_config.js index c86db923c0..776bfefc5d 100644 --- a/test/generator/set-in-observe-dedupes-renders/_config.js +++ b/test/generator/set-in-observe-dedupes-renders/_config.js @@ -3,6 +3,6 @@ export default { test ( assert, component ) { component.set({ foo: { x: 2 } }); - component.teardown(); + component.destroy(); } }; diff --git a/test/generator/svg-attributes/_config.js b/test/generator/svg-attributes/_config.js index 836f320a77..a14ad958ba 100644 --- a/test/generator/svg-attributes/_config.js +++ b/test/generator/svg-attributes/_config.js @@ -10,6 +10,6 @@ export default { test ( assert, component, target ) { const circle = target.querySelector( 'circle' ); assert.equal( circle.getAttribute( 'class' ), 'red' ); - component.teardown(); + component.destroy(); } }; diff --git a/test/generator/svg-class/_config.js b/test/generator/svg-class/_config.js index d801f4d602..74141d1679 100644 --- a/test/generator/svg-class/_config.js +++ b/test/generator/svg-class/_config.js @@ -9,6 +9,6 @@ export default { assert.equal( svg.namespaceURI, 'http://www.w3.org/2000/svg' ); assert.equal( svg.getAttribute( 'class' ), 'foo' ); - component.teardown(); + component.destroy(); } }; diff --git a/test/generator/svg-each-block-namespace/_config.js b/test/generator/svg-each-block-namespace/_config.js index eccd720c03..1bdab1a605 100644 --- a/test/generator/svg-each-block-namespace/_config.js +++ b/test/generator/svg-each-block-namespace/_config.js @@ -10,6 +10,6 @@ export default { assert.equal( circles[0].namespaceURI, 'http://www.w3.org/2000/svg' ); assert.equal( circles[1].namespaceURI, 'http://www.w3.org/2000/svg' ); assert.equal( circles[2].namespaceURI, 'http://www.w3.org/2000/svg' ); - component.teardown(); + component.destroy(); } }; diff --git a/test/generator/svg-xlink/_config.js b/test/generator/svg-xlink/_config.js index eb49f3a72a..55bb6440a7 100644 --- a/test/generator/svg-xlink/_config.js +++ b/test/generator/svg-xlink/_config.js @@ -14,6 +14,6 @@ export default { assert.equal( href.namespaceURI, 'http://www.w3.org/1999/xlink' ); - component.teardown(); + component.destroy(); } };