-
Notifications
You must be signed in to change notification settings - Fork 27.3k
fix($parse): create undefined arrays in assigements #9850
fix($parse): create undefined arrays in assigements #9850
Conversation
@@ -1164,6 +1164,23 @@ describe('parser', function() { | |||
fn.assign(scope, 123); | |||
expect(scope.a.b.c).toEqual(123); | |||
})); | |||
|
|||
it('should create undefined objects in assignment expressions', inject(function($parse) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't we already have a test for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
surpassingly I can see only very limited number of tests for the assign
:
angular.js/test/ng/parseSpec.js
Line 1143 in 2a0254e
describe('assignable', function() { |
But maybe I'm not looking at the right place...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't check, I'd just be surprised if we didn't. More tests are always good though
I'm not sure how I feel about this --- I guess it's okay maybe, but I dunno. the patch looks fine though |
Yeh, honestly I also don't know what to think about this one :-) I guess it can be useful in some cases but I'm just afraid that we are introducing some corner cases I can't see atm. |
I am torn about this, the reason being that if you have <input ng-model="model[0]"/>
<input ng-model="model.foo"/> then depending on the order the user fills the fields, we end up with an array or an object. With this in mind, I lean towards not merging this, but not strong enought to oppose it getting merge |
Ah, I see that @pkozlowski-opensource already posted the same issue in the original report. Sorry for the noise |
@lgalfaso yeh, this was exactly my first worry as well. Anyway, I don't feel strongly about this one either way. Let's either merge this or close as "won't fix" - there is no point spending too much time on this one. |
I kinda feel like we should shy away from assignment in expressions and get people to initialize their data --- is that too unrealistic? :( |
Please look at my comment in #9820 |
This issue was discussed and the agreement was to make this PR a wont fix |
angular. does not (and will not angular/angular.js#9850) properly handle arrays in keys unless they have already been created in the model. This fix/feature adds a separate parser for these circumstances and a formlyConfig.extras flag to control its use. The flag is in place to minimize impact on current functionality of the setter. This is in support of formly-js#706
angular. does not (and will not angular/angular.js#9850) properly handle arrays in keys unless they have already been created in the model. This fix/feature adds a separate parser for these circumstances and a formlyConfig.extras flag to control its use. The flag is in place to minimize impact on current functionality of the setter. This is in support of #706
Fixes #9820