fix(core): check for undefined on normalizeDebugBindingValue (#15503)
DebugServices is parsing false atributes values incorrectly. Parse5 expects a string value for attributes, but currently boolean is being sent. Closes #15494
This commit is contained in:
parent
6269d28bb0
commit
aa16ccda79
|
@ -275,7 +275,7 @@ function camelCaseToDashCase(input: string): string {
|
||||||
function normalizeDebugBindingValue(value: any): string {
|
function normalizeDebugBindingValue(value: any): string {
|
||||||
try {
|
try {
|
||||||
// Limit the size of the value as otherwise the DOM just gets polluted.
|
// Limit the size of the value as otherwise the DOM just gets polluted.
|
||||||
return value ? value.toString().slice(0, 30) : value;
|
return value != null ? value.toString().slice(0, 30) : value;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return '[ERROR] Exception while trying to serialize the value';
|
return '[ERROR] Exception while trying to serialize the value';
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
import {animate, style, transition, trigger} from '@angular/animations';
|
import {animate, style, transition, trigger} from '@angular/animations';
|
||||||
import {APP_BASE_HREF, PlatformLocation, isPlatformServer} from '@angular/common';
|
import {APP_BASE_HREF, PlatformLocation, isPlatformServer} from '@angular/common';
|
||||||
import {ApplicationRef, CompilerFactory, Component, HostListener, NgModule, NgModuleRef, NgZone, PLATFORM_ID, PlatformRef, ViewEncapsulation, destroyPlatform, getPlatform} from '@angular/core';
|
import {ApplicationRef, CompilerFactory, Component, HostListener, Input, NgModule, NgModuleRef, NgZone, PLATFORM_ID, PlatformRef, ViewEncapsulation, destroyPlatform, getPlatform} from '@angular/core';
|
||||||
import {TestBed, async, inject} from '@angular/core/testing';
|
import {TestBed, async, inject} from '@angular/core/testing';
|
||||||
import {Http, HttpModule, Response, ResponseOptions, XHRBackend} from '@angular/http';
|
import {Http, HttpModule, Response, ResponseOptions, XHRBackend} from '@angular/http';
|
||||||
import {MockBackend, MockConnection} from '@angular/http/testing';
|
import {MockBackend, MockConnection} from '@angular/http/testing';
|
||||||
|
@ -166,6 +166,23 @@ class NativeEncapsulationApp {
|
||||||
class NativeExampleModule {
|
class NativeExampleModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Component({selector: 'my-child', template: 'Works!'})
|
||||||
|
class MyChildComponent {
|
||||||
|
@Input() public attr: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Component({selector: 'app', template: '<my-child [attr]="false"></my-child>'})
|
||||||
|
class MyHostComponent {
|
||||||
|
}
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
declarations: [MyHostComponent, MyChildComponent],
|
||||||
|
bootstrap: [MyHostComponent],
|
||||||
|
imports: [ServerModule, BrowserModule.withServerTransition({appId: 'false-attributes'})]
|
||||||
|
})
|
||||||
|
class FalseAttributesModule {
|
||||||
|
}
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
if (getDOM().supportsDOMEvents()) return; // NODE only
|
if (getDOM().supportsDOMEvents()) return; // NODE only
|
||||||
|
|
||||||
|
@ -406,6 +423,15 @@ export function main() {
|
||||||
called = true;
|
called = true;
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
it('should handle false values on attributes', async(() => {
|
||||||
|
renderModule(FalseAttributesModule, {document: doc}).then((output) => {
|
||||||
|
expect(output).toBe(
|
||||||
|
'<html><head></head><body><app ng-version="0.0.0-PLACEHOLDER">' +
|
||||||
|
'<my-child ng-reflect-attr="false">Works!</my-child></app></body></html>');
|
||||||
|
called = true;
|
||||||
|
});
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('http', () => {
|
describe('http', () => {
|
||||||
|
|
Loading…
Reference in New Issue