This is very odd. This basic functionality does not work for some reason.

App controller:

    add : function(component, event, helper) {
        var items = component.get('v.obj')
        var subItem = {name:'three'}
        items.subItems.push( subItem )
        component.set( 'v.obj', items )
    doInit: function(component, event, helper) {
         component.set( 'v.obj', {subItems:[{name:'one'}, {name:'two'}]}  )


<aura:application >
    <aura:attribute name="obj" type="Object"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>  
    <ui:button press="{!c.add}" label="add" />

With locker enabled, console always prints 2. Without, it increments by one with each press.

Edit: I found that workaround. Turns out you need to get and set the subItem itself.

add : function(component, event, helper) {
        var items = component.get('v.obj.subItems')
        var subItem = {name:'three'}
        items.push( subItem )
        component.set( 'v.obj.subItems', items )

This is fine enough for adding new items, but no idea how I could remove items in deeper nesting. Setting to undefined or {} does not help much.

  • I can reproduce the issue locally as well. This feels very similar to bugs we've encountered in the past, but appears to be slightly different. If you open a case with support you can reference bug ID W-3457602, which I just filed to track internally. – TrevorBliss Nov 8 '16 at 1:32

I'm not sure when exactly but this is fixed now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.