Skip to content

Commit 2e7a429

Browse files
committed
get rid of tmp variable, we dont need it
1 parent 950f2ce commit 2e7a429

File tree

5 files changed

+9
-19
lines changed

5 files changed

+9
-19
lines changed

src/generators/dom/Block.js

-5
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,4 @@ export default class Block {
154154
}
155155
`;
156156
}
157-
158-
tmp () {
159-
if ( !this._tmp ) this._tmp = this.getUniqueName( 'tmp' );
160-
return this._tmp;
161-
}
162157
}

src/generators/dom/visitors/Element/Attribute.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ export default function visitAttribute ( generator, block, state, node, attribut
8181

8282
block.builders.create.addLine( updater );
8383
block.builders.update.addBlock( deindent`
84-
if ( ( ${block.tmp()} = ${value} ) !== ${last} ) {
85-
${last} = ${block.tmp()};
84+
if ( ${last} !== ( ${last} = ${value} ) ) {
8685
${updater}
8786
}
8887
` );

src/generators/dom/visitors/MustacheTag.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ export default function visitMustacheTag ( generator, block, state, node ) {
99
block.addElement( name, `${generator.helper( 'createText' )}( last_${name} )`, state.parentNode, true );
1010

1111
block.builders.update.addBlock( deindent`
12-
if ( ( ${block.tmp()} = ${snippet} ) !== last_${name} ) {
13-
${name}.data = last_${name} = ${block.tmp()};
12+
if ( last_${name} !== ( last_${name} = ${snippet} ) ) {
13+
${name}.data = last_${name};
1414
}
1515
` );
1616
}

src/generators/dom/visitors/RawMustacheTag.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ export default function visitRawMustacheTag ( generator, block, state, node ) {
2626
}
2727

2828
block.builders.update.addBlock( deindent`
29-
if ( ( ${block.tmp()} = ${snippet} ) !== last_${name} ) {
30-
last_${name} = ${block.tmp()};
29+
if ( last_${name} !== ( last_${name} = ${snippet} ) ) {
3130
${detachStatement}
3231
${mountStatement}
3332
}

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

+5-8
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,15 @@ function create_each_block ( root, each_block_value, comment, comment_index, com
7575
},
7676

7777
update: function ( changed, root, each_block_value, comment, comment_index ) {
78-
var tmp;
79-
80-
if ( ( tmp = comment.author ) !== last_text ) {
81-
text.data = last_text = tmp;
78+
if ( last_text !== ( last_text = comment.author ) ) {
79+
text.data = last_text;
8280
}
8381

84-
if ( ( tmp = root.elapsed(comment.time, root.time) ) !== last_text_2 ) {
85-
text_2.data = last_text_2 = tmp;
82+
if ( last_text_2 !== ( last_text_2 = root.elapsed(comment.time, root.time) ) ) {
83+
text_2.data = last_text_2;
8684
}
8785

88-
if ( ( tmp = comment.html ) !== last_raw ) {
89-
last_raw = tmp;
86+
if ( last_raw !== ( last_raw = comment.html ) ) {
9087
detachBetween( raw_before, raw_after );
9188
raw_before.insertAdjacentHTML( 'afterend', last_raw );
9289
}

0 commit comments

Comments
 (0)