ember-animation / liquid-fire

Animations & transitions for ambitious Ember applications.
Other
1.15k stars 199 forks source link

toModel function doesn't reference right model #141

Open wongpeiyi opened 9 years ago

wongpeiyi commented 9 years ago

http://jsbin.com/dohizofico/1/edit (have to download and reference liquid-fire properly)

I modified the prebuilt-example to include DS models in the routes, and use a toModel function in the transition. However, this == window in the toModel function and toModel == undefined in the fromModel function.

ef4 commented 9 years ago

Yes, this is a Javascript quirk. this in toModel always contains the new model, but if there is none, it is undefined, but vanilla Javascript doesn't let this be undefined, and so replaces it with window.

This is a poor part of the API that I would like to improve, it was a mistake to use this here, for just this reason.

wongpeiyi commented 9 years ago

Thanks. Is there a reason why there is no model though? I modified the example so both routes contain a model.

wongpeiyi commented 9 years ago

https://github.com/ef4/liquid-fire/blame/c9f93689a2bb3dafab6a600db9eb229553dc8e9a/addon/transitions.js#L117

@ef4 I'm not sure but should this not be liquidContext? For liquid-outlets, it appears that _liquidChildFor is called after _viewProperties hence get('liquidContext') returns undefined instead of the new view's context