fix(platform-server): reflect properties to attributes for known elements, for serialization

This commit is contained in:
Alex Rickabaugh
2017-02-13 15:17:40 -08:00
committed by Igor Minar
parent 9559d3e949
commit 047cda5b3c
3 changed files with 48 additions and 3 deletions

View File

@ -90,6 +90,14 @@ export class HttpBeforeExampleModule {
export class HttpAfterExampleModule {
}
@Component({selector: 'app', template: `<img [src]="'link'">`})
class ImageApp {
}
@NgModule({declarations: [ImageApp], imports: [ServerModule], bootstrap: [ImageApp]})
class ImageExampleModule {
}
export function main() {
if (getDOM().supportsDOMEvents()) return; // NODE only
@ -143,6 +151,18 @@ export function main() {
});
}));
it('copies known properties to attributes', async(() => {
const platform = platformDynamicServer(
[{provide: INITIAL_CONFIG, useValue: {document: '<app></app>'}}]);
platform.bootstrapModule(ImageExampleModule).then(ref => {
const appRef: ApplicationRef = ref.injector.get(ApplicationRef);
const app = appRef.components[0].location.nativeElement;
const img = getDOM().getElementsByTagName(app, 'img')[0] as any;
expect(img.attribs['src']).toEqual('link');
});
}));
describe('PlatformLocation', () => {
it('is injectable', async(() => {
const platform = platformDynamicServer(