@@ -1494,9 +1494,10 @@ exports.Obj = class Obj extends Base
1494
1494
# `foo = ({a, rest..., b}) ->` -> `foo = {a, b, rest...}) ->`
1495
1495
reorderProperties : ->
1496
1496
props = @properties
1497
- splatProps = (prop for prop in props when prop instanceof Splat)
1498
- objProps = (prop for prop in props when prop not instanceof Splat)
1499
- @objects = @properties = [].concat objProps, splatProps
1497
+ splatProps = (x for prop, x in props when prop instanceof Splat)
1498
+ props[splatProps[1 ]].error " multiple spread elements are disallowed" if splatProps ? .length > 1
1499
+ splatProp = props .splice splatProps[0 ], 1
1500
+ @objects = @properties = [].concat props, splatProp
1500
1501
1501
1502
compileNode : (o ) ->
1502
1503
@ reorderProperties () if @ hasSplat () and @lhs
@@ -1511,10 +1512,6 @@ exports.Obj = class Obj extends Base
1511
1512
# CSX attributes <div id="val" attr={aaa} {props...} />
1512
1513
return @ compileCSXAttributes o if @csx
1513
1514
1514
- if @ hasSplat () and @lhs
1515
- splatProps = (ix for prop, ix in props when prop instanceof Splat)
1516
- props[splatProps[1 ]].error " multiple spread elements are disallowed" if splatProps ? .length > 1
1517
-
1518
1515
# If this object is the left-hand side of an assignment, all its children
1519
1516
# are too.
1520
1517
if @lhs
@@ -2200,9 +2197,7 @@ exports.Assign = class Assign extends Base
2200
2197
# know that, so that those nodes know that they’re assignable as
2201
2198
# destructured variables.
2202
2199
@variable .base .lhs = yes
2203
- # Check if @variable contains Obj with splats.
2204
- hasSplat = @variable .contains (node) -> node instanceof Obj and node .hasSplat ()
2205
- return @ compileDestructuring o if not @variable .isAssignable () or @variable .isArray () and hasSplat
2200
+ return @ compileDestructuring o if not @variable .isAssignable ()
2206
2201
2207
2202
return @ compileSplice o if @variable .isSplice ()
2208
2203
return @ compileConditional o if @context in [' ||=' , ' &&=' , ' ?=' ]
0 commit comments