-
Notifications
You must be signed in to change notification settings - Fork 27.4k
feat(ngList): support whitespace control through ngTrim #8216
Conversation
Thanks for the PR! Please check the items below to help us merge this faster. See the contributing docs for more information.
If you need to make changes to your pull request, you can update the commit with Thanks again for your help! |
@IgorMinar, @purcell, @tedjp, @hnordt - can you take a look at this |
okay, having read this, I think we're saying that ngTrim now affects the way ngList separators work, by making whitespace before/after the separator optional (or not)? The feature seems okay, but reading the markup in the tests, it's not totally communicating the intent of this behaviour to me. Either way, I guess that makes sense. |
Yes that's the idea. I'm not sure how to make the tests clearer. @caitp any ideas? |
@petebacondarwin Looks sound to me. |
@petebacondarwin I don't think the tests are the problem, to me I just think that using the feature declaratively is not really self-documenting. It's not clear that |
this looks good to me. @caitp from the user perspective ngTrim is applied onto the individual parts in the list and not on the separator, so ng-trim-separator doesn't make things any better. |
@IgorMinar not if you read the tests, that's not actually what's happening. I mean, in practice, it is what's happening, but it's not how you'd describe the end result --- so the end result doesn't seem to make sense based on the input. I think a new attribute would make more sense, but I don't think we want to add a new attribute, so it looks good to me. (It's just, confusing, I think this will result in code which is actually more confusing than it should be --- but maybe that's better than adding yet another API to make it clearer) |
Yes, I was trying to minimize changes to the API. One of the goals of this PR was to fix up Much of this has been discussed before in #2561 and #4008. The standard meaning of
To accomplish this I have deputized the
Does this seem reasonable too? I think @caitp is not 100% happy but is being pragmatic and thinks it is a fair compromise. |
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
Landed as 8d18d20 |
This PR sits on top of #4344 to make
ngList
consistent with standard use ofngTrim
and useful in scenarios where you want to split on whitespace strings.