-
Notifications
You must be signed in to change notification settings - Fork 27.4k
ngModel parse errors always use named parser #10076
ngModel parse errors always use named parser #10076
Comments
Is this not a bug for 1.3? |
I think we must break the API to fix it properly, so that's why I moved And I really don't like that we cannot return undefined from a parser Am 11.12.2014 um 21:26 schrieb Pete Bacon Darwin:
|
I just ran into this bug when writing a directive for an It seems that a single instance of I don't see a fix for this. Does anyone have a workaround? Here's my use case: While I was writing that out, I figured out a solution -- return So, hopefully this information might help someone else. |
This commit changes how input elements use the private $$parserName property on the ngModelController to name parse errors. Until now, the input types (number, date etc.) would set $$parserName when the inputs were initialized, which meant that any other parsers on the ngModelController would also be named after that type. The effect of that was that the `$error` property and the `ng-invalid-...` class would always be that of the built-in parser, even if the custom parser had nothing to do with it. The new behavior is that the $$parserName is only set if the actual parser is invalid, i.e. returns `undefined`. Also, $$parserName has been removed from input[email] and input[url], as these types do not have a built-in parser anymore. BREAKING CHANGE: Custom parsers that fail to parse on input types email, url, date, month, time, datetime-local, week, do no longer set $error[inputType], and no longer set the class `ng-invalid-[inputType]`. Instead, they set $error.parse and `ng-invalid-parse`. Closes angular#14292 Closes angular#10076
This commit changes how input elements use the private $$parserName property on the ngModelController to name parse errors. Until now, the input types (number, date etc.) would set $$parserName when the inputs were initialized, which meant that any other parsers on the ngModelController would also be named after that type. The effect of that was that the `$error` property and the `ng-invalid-...` class would always be that of the built-in parser, even if the custom parser had nothing to do with it. The new behavior is that the $$parserName is only set if the built-in parser is invalid i.e. returns `undefined`. Also, $$parserName has been removed from input[email] and input[url], as these types do not have a built-in parser anymore. BREAKING CHANGE: *Custom* parsers that fail to parse on input types "email", "url", "number", "date", "month", "time", "datetime-local", "week", do no longer set `ngModelController.$error[inputType]`, and the `ng-invalid-[inputType]` class. Also, custom parsers on input type "range" do no longer set `ngModelController.$error.number` and the `ng-invalid-number` class. Instead, any custom parsers on these inputs set `ngModelController.$error.parse` and `ng-invalid-parse`. Closes angular#14292 Closes angular#10076
This commit changes how input elements use the private $$parserName property on the ngModelController to name parse errors. Until now, the input types (number, date etc.) would set $$parserName when the inputs were initialized, which meant that any other parsers on the ngModelController would also be named after that type. The effect of that was that the `$error` property and the `ng-invalid-...` class would always be that of the built-in parser, even if the custom parser had nothing to do with it. The new behavior is that the $$parserName is only set if the built-in parser is invalid i.e. returns `undefined`. Also, $$parserName has been removed from input[email] and input[url], as these types do not have a built-in parser anymore. Closes #14292 Closes #10076 Closes #16347 BREAKING CHANGE: *Custom* parsers that fail to parse on input types "email", "url", "number", "date", "month", "time", "datetime-local", "week", do no longer set `ngModelController.$error[inputType]`, and the `ng-invalid-[inputType]` class. Also, custom parsers on input type "range" do no longer set `ngModelController.$error.number` and the `ng-invalid-number` class. Instead, any custom parsers on these inputs set `ngModelController.$error.parse` and `ng-invalid-parse`. This change was made to make distinguishing errors from built-in parsers and custom parsers easier.
For our core parsers, we use a private / undocumented property called
$$parserName
, so that the $error is named, e.g.$error.date
. Other parsers will always set$error.parse
. When you have something like this:where myParser adds:
the
$error
will nevertheless bedate
, because the$$parserName
is set in the link function, and $$runValidators will always use the$$parserName
if it is set.The text was updated successfully, but these errors were encountered: