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

Commit b77534e

Browse files
pavelgjmhevery
authored andcommitted
feat(block): Chain ElementProbe parents; add to shadowRoot
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 #625 Closes #630
1 parent b307c82 commit b77534e

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

lib/directive/ng_repeat.dart

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@ class NgRepeatDirective extends AbstractNgRepeatDirective {
8585
BoundBlockFactory boundBlockFactory,
8686
Scope scope,
8787
Parser parser,
88-
AstParser astParser)
89-
: super(blockHole, boundBlockFactory, scope, parser, astParser);
88+
AstParser astParser,
89+
FilterMap filters)
90+
: super(blockHole, boundBlockFactory, scope, parser, astParser, filters);
9091
}
9192

9293
/**
@@ -118,8 +119,9 @@ class NgShallowRepeatDirective extends AbstractNgRepeatDirective {
118119
BoundBlockFactory boundBlockFactory,
119120
Scope scope,
120121
Parser parser,
121-
AstParser astParser)
122-
: super(blockHole, boundBlockFactory, scope, parser, astParser)
122+
AstParser astParser,
123+
FilterMap filters)
124+
: super(blockHole, boundBlockFactory, scope, parser, astParser, filters)
123125
{
124126
print('DEPRECATED: [ng-shallow-repeat] use [ng-repeat]');
125127
}
@@ -134,6 +136,7 @@ abstract class AbstractNgRepeatDirective {
134136
final Scope _scope;
135137
final Parser _parser;
136138
final AstParser _astParser;
139+
final FilterMap filters;
137140

138141
String _expression;
139142
String _valueIdentifier;
@@ -145,7 +148,8 @@ abstract class AbstractNgRepeatDirective {
145148
Iterable _lastCollection;
146149

147150
AbstractNgRepeatDirective(this._blockHole, this._boundBlockFactory,
148-
this._scope, this._parser, this._astParser);
151+
this._scope, this._parser, this._astParser,
152+
this.filters);
149153

150154
set expression(value) {
151155
_expression = value;
@@ -181,7 +185,7 @@ abstract class AbstractNgRepeatDirective {
181185
_keyIdentifier = match.group(2);
182186

183187
_watch = _scope.watch(
184-
_astParser(_listExpr, collection: true),
188+
_astParser(_listExpr, collection: true, filters: filters),
185189
(CollectionChangeRecord collection, _) {
186190
//TODO(misko): we should take advantage of the CollectionChangeRecord!
187191
_onCollectionChange(collection == null ? [] : collection.iterable);

test/directive/ng_repeat_spec.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,16 @@ main() {
7979
});
8080

8181

82+
it('should support filters', () {
83+
element = $compile(
84+
'<div><span ng-repeat="item in items | filter:myFilter">{{item}}</span></div>');
85+
scope.context['items'] = ['foo', 'bar', 'baz'];
86+
scope.context['myFilter'] = (String item) => item.startsWith('b');
87+
scope.apply();
88+
expect(element.find('span').length).toEqual(2);
89+
});
90+
91+
8292
describe('track by', () {
8393
it(r'should track using expression function', () {
8494
element = $compile(

0 commit comments

Comments
 (0)