Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Directive ngValue sometimes do not update value attribute #15603

Closed
dmytro-krekota opened this issue Jan 12, 2017 · 2 comments
Closed

Directive ngValue sometimes do not update value attribute #15603

dmytro-krekota opened this issue Jan 12, 2017 · 2 comments

Comments

@dmytro-krekota
Copy link

@gkalpak
Copy link
Member

gkalpak commented Jan 12, 2017

This happens because of e6afca0.

Theoretically, when the value changes to undefined (either via delete $rootScope.someText or $rootScope.someText = undefined), the value attribute should be removed and the value property should be set to undefined (which essentially sets it to '' for <input> elements.

The problem is that element.prop('value', undefined) does not work as expected, because jqLite treats it in the same way as element.prop('value') (the getter). For example, $rootScope.someText = null works as expected.

I wonder how jQuery handles that...

@gkalpak
Copy link
Member

gkalpak commented Jan 12, 2017

jQuery handles it in th same way (.prop('value', undefined) is the same as .prop('value')). It seems we need special logic inside ngValue to convert undefined values to null (or something).

gkalpak pushed a commit that referenced this issue Jan 19, 2017
…ndefined

Previously, when the expression evaluated to `undefined` the `value` property
was not updated. This happened because jqLite/jQuery's `prop(_, undefined)` is
treated as a getter, thus not apdating the property.

This commit fixes it by setting the property to `null` instead.
(On IE9 we use `''` - see inline comments for more info.)

Fixes #15603

Closes #15605
ellimist pushed a commit to ellimist/angular.js that referenced this issue Mar 15, 2017
…ndefined

Previously, when the expression evaluated to `undefined` the `value` property
was not updated. This happened because jqLite/jQuery's `prop(_, undefined)` is
treated as a getter, thus not apdating the property.

This commit fixes it by setting the property to `null` instead.
(On IE9 we use `''` - see inline comments for more info.)

Fixes angular#15603

Closes angular#15605
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants