melanke / Watch.JS

watch the changes of any object or attribute
Other
2.14k stars 219 forks source link

Watched array pushes to parent object still a bug #56

Open nickimproove opened 11 years ago

nickimproove commented 11 years ago

This issue is still a bug link: https://github.com/melanke/Watch.JS/issues/19

var apple = 
{
    manufacturer:"macintosh",
    color: "red",
    types: 
    {
        machines: 
        [
            'mac pro',
            'imac'
        ]
    }
}

watch(apple, "types", function()
{
    console.log(this);
});

apple.types.machines.push('ipad');

console.log(this) outputs result you see bellow:

{
    mac pro,imac,ipad:undefined,
    machines: 
    [
        "mac pro",  
        "imac",
        "ipad"
    ]
}
melanke commented 11 years ago

Sorry, I dont get your issue. I think this is working: http://jsfiddle.net/WDgye/

nickimproove commented 11 years ago

Hello,

Se my screendump bellow if you push to machines array there will also be a object pushed to it´s parent "types".

Thats must be a bug right?

Im using firefox for this test were you using webkit (chrome) browser for your test ?

firefox