can.view.render update is sometimes `undefined` #360

Closed
amcdnl opened this Issue Apr 18, 2013 · 5 comments

Comments

Projects
None yet
4 participants
@amcdnl
Contributor

amcdnl commented Apr 18, 2013

The can.view.render class sometimes throws an Uncaught TypeError: undefined is not a function error because the update function is undefined at the call time.

See : https://github.com/bitovi/canjs/blob/master/view/render.js#L227

I propose we add change it to be update && update(newVal, oldVal)

See: http://screencast.com/t/jauYywxJSV

@ccummings

This comment has been minimized.

Show comment
Hide comment
@ccummings

ccummings Apr 18, 2013

Contributor

The binder is called is called right away and if something updates the value before hookups are run, update will be undefined. This typically happens when a value used in live binding is updated inside of a can.view call, which is a bad thing to do.

A nicer fix is to assign a function to update at https://github.com/bitovi/canjs/blob/master/view/render.js#L261 that updates binding.value to newValue and console.warns that the developer might be shooting themselves in the foot.

This should make things work most of the time.

Contributor

ccummings commented Apr 18, 2013

The binder is called is called right away and if something updates the value before hookups are run, update will be undefined. This typically happens when a value used in live binding is updated inside of a can.view call, which is a bad thing to do.

A nicer fix is to assign a function to update at https://github.com/bitovi/canjs/blob/master/view/render.js#L261 that updates binding.value to newValue and console.warns that the developer might be shooting themselves in the foot.

This should make things work most of the time.

@daffl

This comment has been minimized.

Show comment
Hide comment
@daffl

daffl Apr 18, 2013

Contributor

That sounds good. This issue keeps coming (e.g. #218) up so fixing it would be very helpful.

Contributor

daffl commented Apr 18, 2013

That sounds good. This issue keeps coming (e.g. #218) up so fixing it would be very helpful.

@ghost ghost assigned ccummings Apr 18, 2013

@amcdnl

This comment has been minimized.

Show comment
Hide comment
@amcdnl

amcdnl Apr 18, 2013

Contributor

I like that ...

Contributor

amcdnl commented Apr 18, 2013

I like that ...

@whitecolor

This comment has been minimized.

Show comment
Hide comment
@whitecolor

whitecolor Apr 21, 2013

Contributor

That is an old problem that happens sometimes "unexpectedly" is not resolved, and I always have to patch render.js each time I update.

Contributor

whitecolor commented Apr 21, 2013

That is an old problem that happens sometimes "unexpectedly" is not resolved, and I always have to patch render.js each time I update.

@ccummings

This comment has been minimized.

Show comment
Hide comment
@ccummings

ccummings Apr 23, 2013

Contributor

Looks like the incremental live lists update in #362 has fixed this issue.

Contributor

ccummings commented Apr 23, 2013

Looks like the incremental live lists update in #362 has fixed this issue.

@ccummings ccummings closed this Apr 23, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment