From d8364f6e0a89002594e0f2523a1901c56ea35348 Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Wed, 3 May 2017 21:35:15 -0400 Subject: [PATCH] remove unnecessary if statement --- src/generators/dom/index.js | 3 +-- test/js/samples/collapses-text-around-comments/expected.js | 4 ++-- test/js/samples/each-block-changed-check/expected.js | 4 ++-- test/js/samples/if-block-no-update/expected.js | 2 +- test/js/samples/if-block-simple/expected.js | 4 ++-- test/js/samples/use-elements-as-anchors/expected.js | 4 ++-- 6 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/generators/dom/index.js b/src/generators/dom/index.js index 04c50b42e0..60aee7b5ad 100644 --- a/src/generators/dom/index.js +++ b/src/generators/dom/index.js @@ -83,7 +83,6 @@ export default function dom ( parsed, source, options ) { ` ); } - // TODO is the `if ( this._fragment )` condition necessary? builders._set.addBlock( deindent` ${options.dev && deindent` if ( typeof newState !== 'object' ) { @@ -99,7 +98,7 @@ export default function dom ( parsed, source, options ) { this._state = ${generator.helper( 'assign' )}( {}, oldState, newState ); ${computations.length && `${generator.alias( 'recompute' )}( this._state, newState, oldState, false )`} ${generator.helper( 'dispatchObservers' )}( this, this._observers.pre, newState, oldState ); - ${block.hasUpdateMethod && `if ( this._fragment ) this._fragment.update( newState, this._state );`} + ${block.hasUpdateMethod && `this._fragment.update( newState, this._state );`} ${generator.helper( 'dispatchObservers' )}( this, this._observers.post, newState, oldState ); ${generator.hasComplexBindings && `while ( this._bindings.length ) this._bindings.pop()();`} ${( generator.hasComponents || generator.hasIntroTransitions ) && `this._flush();`} diff --git a/test/js/samples/collapses-text-around-comments/expected.js b/test/js/samples/collapses-text-around-comments/expected.js index faa7e9d36a..8145330e3e 100644 --- a/test/js/samples/collapses-text-around-comments/expected.js +++ b/test/js/samples/collapses-text-around-comments/expected.js @@ -69,7 +69,7 @@ SvelteComponent.prototype._set = function _set ( newState ) { var oldState = this._state; this._state = assign( {}, oldState, newState ); dispatchObservers( this, this._observers.pre, newState, oldState ); - if ( this._fragment ) this._fragment.update( newState, this._state ); + this._fragment.update( newState, this._state ); dispatchObservers( this, this._observers.post, newState, oldState ); }; @@ -83,4 +83,4 @@ SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = functio this._torndown = true; }; -export default SvelteComponent; +export default SvelteComponent; \ No newline at end of file diff --git a/test/js/samples/each-block-changed-check/expected.js b/test/js/samples/each-block-changed-check/expected.js index c0a8092727..b31be6e9fa 100644 --- a/test/js/samples/each-block-changed-check/expected.js +++ b/test/js/samples/each-block-changed-check/expected.js @@ -145,7 +145,7 @@ SvelteComponent.prototype._set = function _set ( newState ) { var oldState = this._state; this._state = assign( {}, oldState, newState ); dispatchObservers( this, this._observers.pre, newState, oldState ); - if ( this._fragment ) this._fragment.update( newState, this._state ); + this._fragment.update( newState, this._state ); dispatchObservers( this, this._observers.post, newState, oldState ); }; @@ -159,4 +159,4 @@ SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = functio this._torndown = true; }; -export default SvelteComponent; +export default SvelteComponent; \ No newline at end of file diff --git a/test/js/samples/if-block-no-update/expected.js b/test/js/samples/if-block-no-update/expected.js index 2d7d9662e5..e86244e8e5 100644 --- a/test/js/samples/if-block-no-update/expected.js +++ b/test/js/samples/if-block-no-update/expected.js @@ -95,7 +95,7 @@ SvelteComponent.prototype._set = function _set ( newState ) { var oldState = this._state; this._state = assign( {}, oldState, newState ); dispatchObservers( this, this._observers.pre, newState, oldState ); - if ( this._fragment ) this._fragment.update( newState, this._state ); + this._fragment.update( newState, this._state ); dispatchObservers( this, this._observers.post, newState, oldState ); }; diff --git a/test/js/samples/if-block-simple/expected.js b/test/js/samples/if-block-simple/expected.js index 6ed64aa06b..ea623351fd 100644 --- a/test/js/samples/if-block-simple/expected.js +++ b/test/js/samples/if-block-simple/expected.js @@ -76,7 +76,7 @@ SvelteComponent.prototype._set = function _set ( newState ) { var oldState = this._state; this._state = assign( {}, oldState, newState ); dispatchObservers( this, this._observers.pre, newState, oldState ); - if ( this._fragment ) this._fragment.update( newState, this._state ); + this._fragment.update( newState, this._state ); dispatchObservers( this, this._observers.post, newState, oldState ); }; @@ -90,4 +90,4 @@ SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = functio this._torndown = true; }; -export default SvelteComponent; +export default SvelteComponent; \ No newline at end of file diff --git a/test/js/samples/use-elements-as-anchors/expected.js b/test/js/samples/use-elements-as-anchors/expected.js index 6d4f9b68aa..3ddbc2ed1d 100644 --- a/test/js/samples/use-elements-as-anchors/expected.js +++ b/test/js/samples/use-elements-as-anchors/expected.js @@ -226,7 +226,7 @@ SvelteComponent.prototype._set = function _set ( newState ) { var oldState = this._state; this._state = assign( {}, oldState, newState ); dispatchObservers( this, this._observers.pre, newState, oldState ); - if ( this._fragment ) this._fragment.update( newState, this._state ); + this._fragment.update( newState, this._state ); dispatchObservers( this, this._observers.post, newState, oldState ); }; @@ -240,4 +240,4 @@ SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = functio this._torndown = true; }; -export default SvelteComponent; +export default SvelteComponent; \ No newline at end of file