Skip to content

default Pipes not on by default  #3173

Closed

Description

@jhades

In alpha 31, the default pipes are not on by default. In an application bootstrapped without any extra configuration, the following code:

{{'Hello World!' | uppercase}}

gets rendered as Hello World! instead of HELLO WORLD!. This is in a typescript setup, the problem can be reproduced like this:

  • clone the angular2-seed
  • npm install / gulp serve.dev
  • add the code above on home.html - the string does not get uppercased

Apparently the default pipes should be (as indicated here):

export const defaultPipes: Pipes = CONST_EXPR(new Pipes({
  "iterableDiff": iterableDiff,
  "keyValDiff": keyValDiff,
  "async": async,
  "uppercase": uppercase,
  "lowercase": lowercase,
  "json": json,
  "limitTo": limitTo,
  "number": decimal,
  "percent": percent,
  "currency": currency,
  "date": date
}));

Activity

  1. jessegood commented on Jul 21, 2015

    @jessegood

    @jhades: I noticed that the uppercase and lowercase pipes work by adding
    changeDetection:ON_PUSH in your @Component.
    However, it should still work with the default I believe.

  2. added a commit that references this issue on Jul 22, 2015
    e1af45c
  3. PatrickJS commented on Jul 22, 2015

    @PatrickJS
    Contributor

    @jhades @jessegood this was my fault sorry about that. I pushed up a PR with the correct fix #3189. The problem was that I was doing more work than I should by only transforming on reference change. This is why changeDetection: ON_PUSH would allow it to work since you're providing a new reference to the bindings which would correctly transform the value

  4. gkalpak commented on Aug 3, 2015

    @gkalpak
    Member

    FWIW, I don't think the issue was checking against the last input value, but the fact that in case of a match you would return the input value (not the transformed output).
    Since these transforms are very cheap anyway, it's not worth having such an optimization in place anyway.

  5. PatrickJS commented on Aug 3, 2015

    @PatrickJS
    Contributor

    The problem was that I used ObservablePipe as code reference since it was the only real pipe at the time (and of course we have no real docs at the time). Then there was also an API changed to remove having to return NO_CHANGE reference when the transformation didn't need to happen (now changed to use WrappedValue). I was also doing smoke tests for these pipes in an app that optimized the change detection for reference checks (changeDetection: ON_PUSH) and the old pipe API.

    change_detection/pipes/observable_pipe.ts
    ObservablePipe has to maintain reference of the Observable and has essentially 4 states in which the transform does something different that causes side effects: Observable without a subscription, Observable with a subscription, current value/returned value are the same, and current value/returned value are different. I only know this because I had to create an ObservablePipe that prevented a cycle from happening when a change returns a new Observable reference. So there's actually a potential bug where the first state should return the returned value and the returned value should be dereferenced during the onDestroy Pipe lifecycle rather than the Observable reference lifecycle. With all that said I should have went back to refactor the pipes so that's my bad

  6. gkalpak commented on Aug 3, 2015

    @gkalpak
    Member

    Looking at the commit that closed this issue (4dc6d74), I thought it was the fact that the untransformed value was returned after the initial invokation.

    But I don't know much about pipes, so I probably misread that 😞
    Sorry for the noise 😈

  7. angular-automatic-lock-bot commented on Sep 6, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  8. locked and limited conversation to collaborators on Sep 6, 2019
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

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions