melanke / Watch.JS

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

Added check if b or a is undefined #102

Closed yackermann closed 7 years ago

yackermann commented 7 years ago

If there is situation where you tracking an item that has not been defined yet, a or b will be undefined, statements:

                    if (a.hasOwnProperty(i)) {
...
                    if (b.hasOwnProperty(j)) {

will lead to trying to read a property of an undefined.

Lines: https://github.com/melanke/Watch.JS/blob/master/src/watch.js#L76 https://github.com/melanke/Watch.JS/blob/master/src/watch.js#L90