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

limitTo: Ignore limit when undefined #10484

Closed

Description

@gkalpak

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).

Activity

  1. pkozlowski-opensource commented on Dec 16, 2014

    @pkozlowski-opensource
    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.

  2. added this to the 1.4.x milestone on Dec 16, 2014
  3. pkozlowski-opensource commented on Dec 16, 2014

    @pkozlowski-opensource
    Member

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

  4. marcin-wosinek commented on Dec 17, 2014

    @marcin-wosinek
    Contributor

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

  5. added 9 commits that reference this issue on Dec 17, 2014
    cc70067
    c09dea9
    3c0d8e4
    7d48430
    f1a6390
    d2e50bd
    b66a1fe
    a9ba807
    ea5085c
  6. marcin-wosinek commented on Dec 21, 2014

    @marcin-wosinek
    Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions