feat(query): adds support for descendants and more list apis.
Additional clean up of query code. Closes: #1935 BREAKING CHANGE: By default Query only queries direct children.
This commit is contained in:
@@ -46,4 +46,8 @@ class BaseQueryList<T> extends Object with IterableMixin<T> {
|
||||
removeCallback(callback) {
|
||||
this._callbacks.remove(callback);
|
||||
}
|
||||
|
||||
get length => this._results.length;
|
||||
get first => this._results.first;
|
||||
get last => this._results.last;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {List, MapWrapper, ListWrapper} from 'angular2/src/facade/collection';
|
||||
import {List, ListWrapper, MapWrapper} from 'angular2/src/facade/collection';
|
||||
|
||||
/**
|
||||
* Injectable Objects that contains a live list of child directives in the light Dom of a directive.
|
||||
@@ -10,9 +10,9 @@ import {List, MapWrapper, ListWrapper} from 'angular2/src/facade/collection';
|
||||
* @exportedAs angular2/view
|
||||
*/
|
||||
export class BaseQueryList<T> {
|
||||
_results: List<T>;
|
||||
_callbacks;
|
||||
_dirty;
|
||||
protected _results: List<T>;
|
||||
protected _callbacks;
|
||||
protected _dirty;
|
||||
|
||||
constructor() {
|
||||
this._results = [];
|
||||
@@ -43,4 +43,10 @@ export class BaseQueryList<T> {
|
||||
onChange(callback) { ListWrapper.push(this._callbacks, callback); }
|
||||
|
||||
removeCallback(callback) { ListWrapper.remove(this._callbacks, callback); }
|
||||
|
||||
get length() { return this._results.length; }
|
||||
|
||||
get first() { return ListWrapper.first(this._results); }
|
||||
|
||||
get last() { return ListWrapper.last(this._results); }
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -35,9 +35,9 @@ import {BaseQueryList} from './base_query_list';
|
||||
* with `<tabs>`
|
||||
* component's on `hydrate` and deregister on `dehydrate` event. While a reasonable approach, this
|
||||
* would only work
|
||||
* partialy since `*ng-for` could rearange the list of `<pane>` components which would not be
|
||||
* partialy since `*ng-for` could rearrange the list of `<pane>` components which would not be
|
||||
* reported to `<tabs>`
|
||||
* component and thus the list of `<pane>` componets would be out of sync with respect to the list
|
||||
* component and thus the list of `<pane>` components would be out of sync with respect to the list
|
||||
* of `<pane>` elements.
|
||||
*
|
||||
* A preferred solution is to inject a `QueryList` which is a live list of directives in the
|
||||
|
||||
Reference in New Issue
Block a user