Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

ng-repeat Convert to new change-detection correct unnecessary moves. #728

Closed
mhevery opened this issue Mar 13, 2014 · 2 comments
Closed

Comments

@mhevery
Copy link
Contributor

mhevery commented Mar 13, 2014

 // iit test  
    iit(r'should not move blocks when elements only added or removed',
        inject((Injector injector) {
      var throwOnMove = new MockAnimate();
      var child = injector.createChild([new Module()
          ..value(NgAnimate, throwOnMove) // THIS LINE WILL CAUSE THE TEST TO FAIL
          ]);

      child.invoke((Injector injector, Scope $rootScope, Compiler compiler, DirectiveMap _directives) {
        $exceptionHandler = injector.get(ExceptionHandler);
        scope = $rootScope;
        $compile = (html) {
          element = $(html);
          var viewFactory = compiler(element, _directives);
          var view = viewFactory(injector, element);
          return element;
        };
        directives = _directives;
      });

      element = $compile(
        '<ul>' +
            '<li ng-repeat="item in items">{{item}}</li>' +
        '</ul>');

      // INIT
      scope.context['items'] = ['a', 'b', 'c'];
      scope.apply();

      // GROW
      scope.context['items'].add('d');
      scope.apply();

      // SHRINK
      scope.context['items'].removeLast();
      scope.apply();
      scope.context['items'].removeAt(0);
      scope.apply();
      expect(element.text()).toEqual('bc');
    }));

// Mock animate instance that throws on move
class MockAnimate extends NgAnimate {
  Animation move(Iterable<Node> nodes, Node parent,
            { Node insertBefore }) {
    throw "Move should not be called";
  }
}
@vicb
Copy link
Contributor

vicb commented Mar 14, 2014

relates to #645

@vicb
Copy link
Contributor

vicb commented Mar 17, 2014

I do take this one

vicb added a commit to vicb/angular.dart that referenced this issue Mar 18, 2014
closes dart-archive#728

The algorithm used to prevent moves is not very efficient and will not always minimize the amount of mobed nodes.
vicb added a commit to vicb/angular.dart that referenced this issue Mar 20, 2014
closes dart-archive#728

The algorithm used to prevent moves is not very efficient and will not
always minimize the amount of mobed nodes.
vicb added a commit to vicb/angular.dart that referenced this issue Mar 20, 2014
vicb added a commit to vicb/angular.dart that referenced this issue Mar 21, 2014
vicb added a commit to vicb/angular.dart that referenced this issue Mar 21, 2014
@vicb vicb closed this as completed in 09871cb Mar 25, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants