refactor(forEach): change to for-of with iterable
rename: foreach -> for rename: array -> iterable update: DartParseTreeWriter update: naive_infinite_scroll update: todo fix: tests in foreach_spec Closes #919
This commit is contained in:
@ -6,7 +6,7 @@ import {bootstrap, Component, Viewport, Template, ViewContainer, Compiler}
|
||||
import {PromiseWrapper} from 'angular2/src/facade/async';
|
||||
import {ListWrapper} from 'angular2/src/facade/collection';
|
||||
import {ScrollAreaComponent} from './scroll_area';
|
||||
import {If, Foreach} from 'angular2/directives';
|
||||
import {If, For} from 'angular2/directives';
|
||||
import {DOM} from 'angular2/src/dom/dom_adapter';
|
||||
import {document} from 'angular2/src/facade/browser';
|
||||
|
||||
@ -85,7 +85,7 @@ export function setupReflectorForApp() {
|
||||
'annotations': [
|
||||
new Component({selector: 'scroll-app'}),
|
||||
new Template({
|
||||
directives: [ScrollAreaComponent, If, Foreach],
|
||||
directives: [ScrollAreaComponent, If, For],
|
||||
inline: `
|
||||
<div>
|
||||
<div style="display: flex">
|
||||
@ -93,7 +93,7 @@ export function setupReflectorForApp() {
|
||||
</div>
|
||||
<div template="if scrollAreas.length > 0">
|
||||
<p>Following tables are only here to add weight to the UI:</p>
|
||||
<scroll-area template="foreach #scrollArea in scrollAreas"></scroll-area>
|
||||
<scroll-area template="for #scrollArea of scrollAreas"></scroll-area>
|
||||
</div>
|
||||
</div>`
|
||||
})]
|
||||
|
@ -7,7 +7,7 @@ import {PromiseWrapper} from 'angular2/src/facade/async';
|
||||
import {ListWrapper, MapWrapper} from 'angular2/src/facade/collection';
|
||||
import {Company, Opportunity, Offering, Account, CustomDate, STATUS_LIST}
|
||||
from './common';
|
||||
import {Foreach} from 'angular2/directives';
|
||||
import {For} from 'angular2/directives';
|
||||
|
||||
export class HasStyle {
|
||||
style:Map;
|
||||
@ -163,10 +163,10 @@ export function setupReflectorForCells() {
|
||||
}
|
||||
}),
|
||||
new Template({
|
||||
directives: [Foreach],
|
||||
directives: [For],
|
||||
inline: `
|
||||
<div [style]="style">
|
||||
<button template="foreach #stage in stages"
|
||||
<button template="for #stage of stages"
|
||||
[disabled]="stage.isDisabled"
|
||||
[style]="stage.style"
|
||||
on-click="setStage(stage)">
|
||||
|
@ -25,7 +25,7 @@ import {ComponentUrlMapper} from 'angular2/src/core/compiler/component_url_mappe
|
||||
import {StyleInliner} from 'angular2/src/core/compiler/style_inliner';
|
||||
import {CssProcessor} from 'angular2/src/core/compiler/css_processor';
|
||||
|
||||
import {If, Foreach} from 'angular2/directives';
|
||||
import {If, For} from 'angular2/directives';
|
||||
import {App, setupReflectorForApp} from './app';
|
||||
import {ScrollAreaComponent, setupReflectorForScrollArea} from './scroll_area';
|
||||
import {ScrollItemComponent, setupReflectorForScrollItem} from './scroll_item';
|
||||
@ -170,13 +170,13 @@ export function setupReflectorForAngular() {
|
||||
})]
|
||||
});
|
||||
|
||||
reflector.registerType(Foreach, {
|
||||
'factory': (vp) => new Foreach(vp),
|
||||
reflector.registerType(For, {
|
||||
'factory': (vp) => new For(vp),
|
||||
'parameters': [[ViewContainer]],
|
||||
'annotations' : [new Viewport({
|
||||
selector: '[foreach]',
|
||||
selector: '[for]',
|
||||
bind: {
|
||||
'iterableChanges': 'in | iterableDiff'
|
||||
'iterableChanges': 'of | iterableDiff'
|
||||
}
|
||||
})]
|
||||
});
|
||||
|
@ -12,7 +12,7 @@ import {Offering, ITEMS, ITEM_HEIGHT, VISIBLE_ITEMS, VIEW_PORT_HEIGHT,
|
||||
ROW_WIDTH, HEIGHT} from './common';
|
||||
import {generateOfferings} from './random_data';
|
||||
import {ScrollItemComponent} from './scroll_item';
|
||||
import {Foreach} from 'angular2/directives';
|
||||
import {For} from 'angular2/directives';
|
||||
|
||||
export class ScrollAreaComponent {
|
||||
_fullList:List<Offering>;
|
||||
@ -69,7 +69,7 @@ export function setupReflectorForScrollArea() {
|
||||
selector: 'scroll-area',
|
||||
}),
|
||||
new Template({
|
||||
directives: [ScrollItemComponent, Foreach],
|
||||
directives: [ScrollItemComponent, For],
|
||||
inline: `
|
||||
<div>
|
||||
<div id="scrollDiv"
|
||||
@ -78,7 +78,7 @@ export function setupReflectorForScrollArea() {
|
||||
<div id="padding"></div>
|
||||
<div id="inner">
|
||||
<scroll-item
|
||||
template="foreach #item in visibleItems"
|
||||
template="for #item of visibleItems"
|
||||
[offering]="item">
|
||||
</scroll-item>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user