canjs / can-reflect

Operate on unknown data types
https://canjs.com/doc/can-reflect.html
MIT License
4 stars 4 forks source link

Dependencies on `length` are displayed strangely #145

Open phillipskevin opened 6 years ago

phillipskevin commented 6 years ago

I'm not positive this issue is caused by can-reflect, but canReflect.getKeyDependencies is the lowest level place I've narrowed it down to.

When a property depends on the length of another property it is displayed strangely. This code:

ViewModel: {
    numbers: {
        default() {
            return [1, 2, 3, 4, 5, 6];
        }
    },

    get oddNumbers() {
        return this.numbers.reduce((odds, num) => {
            if (num % 2 === 1) {
                odds.push(num);
            }
            return odds;
        }, []);
    }
}

...returns this graph: image

This should somehow be tied to numbers.length.