X Tutup
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ export class ChangeDetectorJITGenerator {
for (var i = 0; i < r.args.length; ++i) {
res += JSON.stringify(r.fixedArgs[i]);
res += " + ";
res += this._localNames[r.args[i]];
res += `${UTIL}.s(${this._localNames[r.args[i]]})`;
res += " + ";
}
res += JSON.stringify(r.fixedArgs[r.args.length]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,6 @@ export class ChangeDetectionUtil {
}

static isValueBlank(value: any): boolean { return isBlank(value); }

static s(value: any): string { return isPresent(value) ? `${value}` : ''; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,15 @@ export function main() {
expect(val.dispatcher.log).toEqual(['propName=BvalueA']);
});

it('should output empty strings for null values in interpolation', () => {
var val = _createChangeDetector('interpolation', new TestData('value'));
val.changeDetector.hydrate(new TestData(null), null, null, null);

val.changeDetector.detectChanges();

expect(val.dispatcher.log).toEqual(['propName=BA']);
});

it('should escape values in literals that indicate interpolation',
() => { expect(_bindSimpleValue('"$"')).toEqual(['propName=$']); });

Expand Down
15 changes: 13 additions & 2 deletions modules/angular2/test/core/compiler/integration_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ import {
PipeFactory,
Pipes,
defaultPipes,
ChangeDetection,
DynamicChangeDetection,
Pipe,
ChangeDetectorRef,
ON_PUSH
Expand Down Expand Up @@ -96,6 +94,19 @@ export function main() {
});
}));

it('should update text node with a blank string when interpolation evaluates to null',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({template: '<div>{{null}}{{ctxProp}}</div>'}))
.createAsync(MyComp)
.then((rootTC) => {
rootTC.componentInstance.ctxProp = null;

rootTC.detectChanges();
expect(rootTC.nativeElement).toHaveText('');
async.done();
});
}));

it('should consume element binding changes',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
tcb.overrideView(MyComp, new viewAnn.View({template: '<div [id]="ctxProp"></div>'}))
Expand Down
X Tutup