@@ -270,7 +270,7 @@ export default class Expression {
270
270
} ) ;
271
271
} else {
272
272
dependencies . add ( name ) ;
273
- component . add_reference ( name ) ;
273
+ component . add_reference ( name ) ; // TODO is this redundant/misplaced?
274
274
}
275
275
} else if ( ! is_synthetic && is_contextual ( component , template_scope , name ) ) {
276
276
code . prependRight ( node . start , key === 'key' && parent . shorthand
@@ -288,41 +288,7 @@ export default class Expression {
288
288
this . skip ( ) ;
289
289
}
290
290
291
- if ( function_expression ) {
292
- if ( node . type === 'AssignmentExpression' ) {
293
- const names = node . left . type === 'MemberExpression'
294
- ? [ get_object ( node . left ) . name ]
295
- : extract_names ( node . left ) ;
296
-
297
- if ( node . operator === '=' && nodes_match ( node . left , node . right ) ) {
298
- const dirty = names . filter ( name => {
299
- return ! scope . declarations . has ( name ) ;
300
- } ) ;
301
-
302
- if ( dirty . length ) component . has_reactive_assignments = true ;
303
-
304
- code . overwrite ( node . start , node . end , dirty . map ( n => component . invalidate ( n ) ) . join ( '; ' ) ) ;
305
- } else {
306
- names . forEach ( name => {
307
- if ( scope . declarations . has ( name ) ) return ;
308
-
309
- const variable = component . var_lookup . get ( name ) ;
310
- if ( variable && variable . hoistable ) return ;
311
-
312
- pending_assignments . add ( name ) ;
313
- } ) ;
314
- }
315
- } else if ( node . type === 'UpdateExpression' ) {
316
- const { name } = get_object ( node . argument ) ;
317
-
318
- if ( scope . declarations . has ( name ) ) return ;
319
-
320
- const variable = component . var_lookup . get ( name ) ;
321
- if ( variable && variable . hoistable ) return ;
322
-
323
- pending_assignments . add ( name ) ;
324
- }
325
- } else {
291
+ if ( ! function_expression ) {
326
292
if ( node . type === 'AssignmentExpression' ) {
327
293
// TODO should this be a warning/error? `<p>{foo = 1}</p>`
328
294
}
@@ -451,6 +417,40 @@ export default class Expression {
451
417
contextual_dependencies = null ;
452
418
}
453
419
420
+ if ( node . type === 'AssignmentExpression' ) {
421
+ const names = node . left . type === 'MemberExpression'
422
+ ? [ get_object ( node . left ) . name ]
423
+ : extract_names ( node . left ) ;
424
+
425
+ if ( node . operator === '=' && nodes_match ( node . left , node . right ) ) {
426
+ const dirty = names . filter ( name => {
427
+ return ! scope . declarations . has ( name ) ;
428
+ } ) ;
429
+
430
+ if ( dirty . length ) component . has_reactive_assignments = true ;
431
+
432
+ code . overwrite ( node . start , node . end , dirty . map ( n => component . invalidate ( n ) ) . join ( '; ' ) ) ;
433
+ } else {
434
+ names . forEach ( name => {
435
+ if ( scope . declarations . has ( name ) ) return ;
436
+
437
+ const variable = component . var_lookup . get ( name ) ;
438
+ if ( variable && variable . hoistable ) return ;
439
+
440
+ pending_assignments . add ( name ) ;
441
+ } ) ;
442
+ }
443
+ } else if ( node . type === 'UpdateExpression' ) {
444
+ const { name } = get_object ( node . argument ) ;
445
+
446
+ if ( scope . declarations . has ( name ) ) return ;
447
+
448
+ const variable = component . var_lookup . get ( name ) ;
449
+ if ( variable && variable . hoistable ) return ;
450
+
451
+ pending_assignments . add ( name ) ;
452
+ }
453
+
454
454
if ( / S t a t e m e n t / . test ( node . type ) ) {
455
455
if ( pending_assignments . size > 0 ) {
456
456
const has_semi = code . original [ node . end - 1 ] === ';' ;
@@ -463,7 +463,7 @@ export default class Expression {
463
463
if ( / ^ ( B r e a k | C o n t i n u e | R e t u r n ) S t a t e m e n t / . test ( node . type ) ) {
464
464
if ( node . argument ) {
465
465
code . overwrite ( node . start , node . argument . start , `var $$result = ` ) ;
466
- code . appendLeft ( node . argument . end , `${ insert } ; return $$result` ) ;
466
+ code . appendLeft ( node . end , `${ insert } ; return $$result` ) ;
467
467
} else {
468
468
code . prependRight ( node . start , `${ insert } ; ` ) ;
469
469
}
0 commit comments