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

limitTo: Ignore limit when undefined #10484

Closed
gkalpak opened this issue Dec 16, 2014 · 4 comments
Closed

limitTo: Ignore limit when undefined #10484

gkalpak opened this issue Dec 16, 2014 · 4 comments

Comments

@gkalpak
Copy link
Member

gkalpak commented Dec 16, 2014

Currently, passing an undefined limit to the limitTo filter will return an empty array/string.
I would expect filtering to be skipped and the original input returned, when the limit argument is undefined.

E.g.:

Limit: <input type="number" ng-model="limit" />
Items: <ul><li ng-repeat="item in items | limitTo:limit">...</li></ul>

Before interacting with the input (i.e. explicitly specifying a limit), I would expect all items to be listed.
What happens instead, is that no item is listed, until a valid integer number is specified.

Although there are ways around this limitation (i.e. detecting undefined and set limit to Infinity), they are unnecessrily verbose (imo).

@pkozlowski-opensource
Copy link
Member

It kind of makes sense what you are saying and I think that the current behavior is bogus for non-string inputs. Having said this it would be a breaking change (see those tests:

it('should return an empty string when X cannot be parsed', function() {
expect(limitTo(str, 'bogus')).toEqual("");
expect(limitTo(str, 'null')).toEqual("");
expect(limitTo(str, 'undefined')).toEqual("");
expect(limitTo(str, null)).toEqual("");
expect(limitTo(str, undefined)).toEqual("");
});
) so we shouldn't be doing this before 1.4. But yeh, let's revisit this as part of 1.4.

@pkozlowski-opensource
Copy link
Member

Oh, actually it is fine for arrays. But yeh, we can revisit behavior for undefined in 1.4.x

@marcin-wosinek
Copy link
Contributor

I'm taking look at this. Should it return input unchanged only for undefined and 'undefined'; or for all bogus values?

marcin-wosinek pushed a commit to marcin-wosinek/angular.js that referenced this issue Dec 17, 2014
BREAKING CHANGE: limitTo changed behavoir when limit value is undefined.
Instead of returning empty object/array it returns non-changed input.

Closes angular#10484
marcin-wosinek added a commit to marcin-wosinek/angular.js that referenced this issue Dec 17, 2014
BREAKING CHANGE: limitTo changed behavoir when limit value is undefined.
Instead of returning empty object/array it returns non-changed input.

Closes angular#10484
marcin-wosinek added a commit to marcin-wosinek/angular.js that referenced this issue Dec 18, 2014
BREAKING CHANGE: limitTo changed behavoir when limit value is invalid.
Instead of returning empty object/array it returns unchanged input.

Closes angular#10484
marcin-wosinek added a commit to marcin-wosinek/angular.js that referenced this issue Dec 18, 2014
BREAKING CHANGE: limitTo changed behavoir when limit value is invalid.
Instead of returning empty object/array it returns unchanged input.

Closes angular#10484
marcin-wosinek added a commit to marcin-wosinek/angular.js that referenced this issue Dec 18, 2014
BREAKING CHANGE: limitTo changed behavoir when limit value is invalid.
Instead of returning empty object/array it returns unchanged input.

Closes angular#10484
marcin-wosinek added a commit to marcin-wosinek/angular.js that referenced this issue Dec 18, 2014
BREAKING CHANGE: limitTo changed behavoir when limit value is invalid.
Instead of returning empty object/array it returns unchanged input.

Closes angular#10484
marcin-wosinek added a commit to marcin-wosinek/angular.js that referenced this issue Dec 18, 2014
BREAKING CHANGE: limitTo changed behavior when limit value is invalid.
Instead of returning empty object/array it returns unchanged input.

Closes angular#10484
marcin-wosinek added a commit to marcin-wosinek/angular.js that referenced this issue Dec 18, 2014
BREAKING CHANGE: limitTo changed behavior when limit value is invalid.
Instead of returning empty object/array it returns unchanged input.

Closes angular#10484
marcin-wosinek added a commit to marcin-wosinek/angular.js that referenced this issue Dec 19, 2014
BREAKING CHANGE: limitTo changed behavior when limit value is invalid.
Instead of returning empty object/array it returns unchanged input.

Closes angular#10484
@marcin-wosinek
Copy link
Contributor

@petebacondarwin I believe this can be closed too due to #10510.

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

Successfully merging a pull request may close this issue.

4 participants