Skip to content

Commit

Permalink
feat(block): Chain ElementProbe parents; add to shadowRoot
Browse files Browse the repository at this point in the history
This allows one to retrieve ElementProbe from any element including
a shadowRoot. The ElementProbe contains element, injector, and scope. 
The added benefit is that by waling the ElementProbe parent one can 
get the parent element of a shadow DOM.

Closes dart-archive#625
Closes dart-archive#630
  • Loading branch information
pavelgj authored and mhevery committed Feb 26, 2014
1 parent b307c82 commit b77534e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/directive/ng_repeat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ class NgRepeatDirective extends AbstractNgRepeatDirective {
BoundBlockFactory boundBlockFactory,
Scope scope,
Parser parser,
AstParser astParser)
: super(blockHole, boundBlockFactory, scope, parser, astParser);
AstParser astParser,
FilterMap filters)
: super(blockHole, boundBlockFactory, scope, parser, astParser, filters);
}

/**
Expand Down Expand Up @@ -118,8 +119,9 @@ class NgShallowRepeatDirective extends AbstractNgRepeatDirective {
BoundBlockFactory boundBlockFactory,
Scope scope,
Parser parser,
AstParser astParser)
: super(blockHole, boundBlockFactory, scope, parser, astParser)
AstParser astParser,
FilterMap filters)
: super(blockHole, boundBlockFactory, scope, parser, astParser, filters)
{
print('DEPRECATED: [ng-shallow-repeat] use [ng-repeat]');
}
Expand All @@ -134,6 +136,7 @@ abstract class AbstractNgRepeatDirective {
final Scope _scope;
final Parser _parser;
final AstParser _astParser;
final FilterMap filters;

String _expression;
String _valueIdentifier;
Expand All @@ -145,7 +148,8 @@ abstract class AbstractNgRepeatDirective {
Iterable _lastCollection;

AbstractNgRepeatDirective(this._blockHole, this._boundBlockFactory,
this._scope, this._parser, this._astParser);
this._scope, this._parser, this._astParser,
this.filters);

set expression(value) {
_expression = value;
Expand Down Expand Up @@ -181,7 +185,7 @@ abstract class AbstractNgRepeatDirective {
_keyIdentifier = match.group(2);

_watch = _scope.watch(
_astParser(_listExpr, collection: true),
_astParser(_listExpr, collection: true, filters: filters),
(CollectionChangeRecord collection, _) {
//TODO(misko): we should take advantage of the CollectionChangeRecord!
_onCollectionChange(collection == null ? [] : collection.iterable);
Expand Down
10 changes: 10 additions & 0 deletions test/directive/ng_repeat_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ main() {
});


it('should support filters', () {
element = $compile(
'<div><span ng-repeat="item in items | filter:myFilter">{{item}}</span></div>');
scope.context['items'] = ['foo', 'bar', 'baz'];
scope.context['myFilter'] = (String item) => item.startsWith('b');
scope.apply();
expect(element.find('span').length).toEqual(2);
});


describe('track by', () {
it(r'should track using expression function', () {
element = $compile(
Expand Down

0 comments on commit b77534e

Please sign in to comment.