Skip to content

Commit d8364f6

Browse files
committed
remove unnecessary if statement
1 parent fa80261 commit d8364f6

File tree

6 files changed

+10
-11
lines changed

6 files changed

+10
-11
lines changed

src/generators/dom/index.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ export default function dom ( parsed, source, options ) {
8383
` );
8484
}
8585

86-
// TODO is the `if ( this._fragment )` condition necessary?
8786
builders._set.addBlock( deindent`
8887
${options.dev && deindent`
8988
if ( typeof newState !== 'object' ) {
@@ -99,7 +98,7 @@ export default function dom ( parsed, source, options ) {
9998
this._state = ${generator.helper( 'assign' )}( {}, oldState, newState );
10099
${computations.length && `${generator.alias( 'recompute' )}( this._state, newState, oldState, false )`}
101100
${generator.helper( 'dispatchObservers' )}( this, this._observers.pre, newState, oldState );
102-
${block.hasUpdateMethod && `if ( this._fragment ) this._fragment.update( newState, this._state );`}
101+
${block.hasUpdateMethod && `this._fragment.update( newState, this._state );`}
103102
${generator.helper( 'dispatchObservers' )}( this, this._observers.post, newState, oldState );
104103
${generator.hasComplexBindings && `while ( this._bindings.length ) this._bindings.pop()();`}
105104
${( generator.hasComponents || generator.hasIntroTransitions ) && `this._flush();`}

test/js/samples/collapses-text-around-comments/expected.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ SvelteComponent.prototype._set = function _set ( newState ) {
6969
var oldState = this._state;
7070
this._state = assign( {}, oldState, newState );
7171
dispatchObservers( this, this._observers.pre, newState, oldState );
72-
if ( this._fragment ) this._fragment.update( newState, this._state );
72+
this._fragment.update( newState, this._state );
7373
dispatchObservers( this, this._observers.post, newState, oldState );
7474
};
7575

@@ -83,4 +83,4 @@ SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = functio
8383
this._torndown = true;
8484
};
8585

86-
export default SvelteComponent;
86+
export default SvelteComponent;

test/js/samples/each-block-changed-check/expected.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ SvelteComponent.prototype._set = function _set ( newState ) {
145145
var oldState = this._state;
146146
this._state = assign( {}, oldState, newState );
147147
dispatchObservers( this, this._observers.pre, newState, oldState );
148-
if ( this._fragment ) this._fragment.update( newState, this._state );
148+
this._fragment.update( newState, this._state );
149149
dispatchObservers( this, this._observers.post, newState, oldState );
150150
};
151151

@@ -159,4 +159,4 @@ SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = functio
159159
this._torndown = true;
160160
};
161161

162-
export default SvelteComponent;
162+
export default SvelteComponent;

test/js/samples/if-block-no-update/expected.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ SvelteComponent.prototype._set = function _set ( newState ) {
9595
var oldState = this._state;
9696
this._state = assign( {}, oldState, newState );
9797
dispatchObservers( this, this._observers.pre, newState, oldState );
98-
if ( this._fragment ) this._fragment.update( newState, this._state );
98+
this._fragment.update( newState, this._state );
9999
dispatchObservers( this, this._observers.post, newState, oldState );
100100
};
101101

test/js/samples/if-block-simple/expected.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ SvelteComponent.prototype._set = function _set ( newState ) {
7676
var oldState = this._state;
7777
this._state = assign( {}, oldState, newState );
7878
dispatchObservers( this, this._observers.pre, newState, oldState );
79-
if ( this._fragment ) this._fragment.update( newState, this._state );
79+
this._fragment.update( newState, this._state );
8080
dispatchObservers( this, this._observers.post, newState, oldState );
8181
};
8282

@@ -90,4 +90,4 @@ SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = functio
9090
this._torndown = true;
9191
};
9292

93-
export default SvelteComponent;
93+
export default SvelteComponent;

test/js/samples/use-elements-as-anchors/expected.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ SvelteComponent.prototype._set = function _set ( newState ) {
226226
var oldState = this._state;
227227
this._state = assign( {}, oldState, newState );
228228
dispatchObservers( this, this._observers.pre, newState, oldState );
229-
if ( this._fragment ) this._fragment.update( newState, this._state );
229+
this._fragment.update( newState, this._state );
230230
dispatchObservers( this, this._observers.post, newState, oldState );
231231
};
232232

@@ -240,4 +240,4 @@ SvelteComponent.prototype.teardown = SvelteComponent.prototype.destroy = functio
240240
this._torndown = true;
241241
};
242242

243-
export default SvelteComponent;
243+
export default SvelteComponent;

0 commit comments

Comments
 (0)