Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

model binded to "null" is always converted to empty object #283

Closed
yd290276 opened this issue Jan 10, 2016 · 1 comment
Closed

model binded to "null" is always converted to empty object #283

yd290276 opened this issue Jan 10, 2016 · 1 comment

Comments

@yd290276
Copy link

When a model bind to a null value, aurelia.binding always convert null (or undefined) to an empty object.
This has for effect to change the binded value in aurelia core and then trigger again (twice) the change handler for the property in the VM.

Code exemple in a view with a select element :

<select
                            ref="select_area"
                            class="form-control"
                            id="select_template_zone"
                            value.bind="imagecropperVM.currentArea"
                            disabled.bind="!templateSelected">
                        <option model.bind="null" selected>Select a zone...</option>
                        <option repeat.for="[id,zone] of templatezones.zones" model.bind="id" value="${id}">${zone.name}</option>
                    </select>

In this example, when first select option is selected, then a first call to change handler is done with a new value of "null", then automatically a second call is done with the new value sets to "Object" because in aurelia-bindings.js, line 1426, the code checks if "instance" is wether null or undefined and if so, it changes the value to an empty object "{}".

I think this behavior/feature is not what developpers/users expect, so aurelia should handle correctly null or undefined value for bindings instead changing the value.

@jdanyow
Copy link
Contributor

jdanyow commented Jan 10, 2016

agree, duplicate of #205

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

No branches or pull requests

2 participants