-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix(input): make ngList honor custom separators #4344
Conversation
Thanks for the PR!
If you need to make changes to your pull request, you can update the commit with Thanks again for your help! |
I have previously signed a CLA, for #4207, but since that has apparently not been reviewed, I'll go ahead and sign another CLA. (Name: Stephen Purcell / Steve Purcell) The mary-poppins bot doesn't seem to detect the valid commit message format, but I have the pre-commit hook installed locally and passing. |
Remove support for regexp separators, and correctly use custom separator when formatting values into the control. See angular#4008 and angular#2561.
LGTM, but since this requires a breaking change, I'm going to triage it for 1.3.x. It should be one of the first PRs to make it in. thanks for all the work! |
Is there a way for this to split on newline for |
+1 |
@tedjp - that is a good point. We should somehow support that without it becoming too complex |
@tedjp - perhaps we could use |
OK, so to break on newlines we need to be able to get the whitespace from the ngList attribute. Then we have the other question of whether to trim whitespace from the the list items. At the moment we always trim but if we are not going to trim the whitespace from the separator string then we might have a problem. For instance, how should |
How about this? If
If
|
The separator string used to split the view value into a list for the model value is now used to join the list items back together again for the view value. BREAKING CHANGE: The `ngList` directive no longer supports splitting the view value via a regular expression. We need to be able to re-join list items back together and doing this when you can split with regular expressions can lead to inconsistent behaviour and would be much more complex to support. If your application relies upon ngList splitting with a regular expression then you should either try to convert the separator to a simple string or you can implement your own version of this directive for you application. Closes angular#4008 Closes angular#2561 Closes angular#4344
With the removal of regular expression support `ngList` no longer supported splitting on newlines (and other pure whitespace splitters). This change allows the application developer to specify whether whitespace should be respected or trimmed by using the `ngTrim` attribute. This also makes `ngList` consistent with the standard use of `ngTrim` in input directives in general. Related To: angular#4344
With the removal of regular expression support `ngList` no longer supported splitting on newlines (and other pure whitespace splitters). This change allows the application developer to specify whether whitespace should be respected or trimmed by using the `ngTrim` attribute. This also makes `ngList` consistent with the standard use of `ngTrim` in input directives in general. Related To: angular#4344
The separator string used to split the view value into a list for the model value is now used to join the list items back together again for the view value. BREAKING CHANGE: The `ngList` directive no longer supports splitting the view value via a regular expression. We need to be able to re-join list items back together and doing this when you can split with regular expressions can lead to inconsistent behaviour and would be much more complex to support. If your application relies upon ngList splitting with a regular expression then you should either try to convert the separator to a simple string or you can implement your own version of this directive for you application. Closes angular#4008 Closes angular#2561 Closes angular#4344
With the removal of regular expression support `ngList` no longer supported splitting on newlines (and other pure whitespace splitters). This change allows the application developer to specify whether whitespace should be respected or trimmed by using the `ngTrim` attribute. This also makes `ngList` consistent with the standard use of `ngTrim` in input directives in general. Related To: angular#4344
With the removal of regular expression support `ngList` no longer supported splitting on newlines (and other pure whitespace splitters). This change allows the application developer to specify whether whitespace should be respected or trimmed by using the `ngTrim` attribute. This also makes `ngList` consistent with the standard use of `ngTrim` in input directives in general. Related To: #4344
Remove support for regexp separators, and correctly use custom separator when formatting values into the control.
Follows @IgorMinar's suggestions from #2561, as suggested by @petebacondarwin in #4008.
The existing "should allow custom separator" test was incomplete, since it did not check that the custom separator was used to format the values in the control.
Notes:
" | "
, the spaces should be rendered into the control. Even with my changes, this is not the case, because theattr.ngList
value has already been trimmed prior to being passed to the directive. I have omitted the failing test for this case. How would we handle this?ng-trim
where present: I'd suggest that when it is present, the values between the separators should not be trimmed.