diff --git a/packages/platform-server/src/domino_adapter.ts b/packages/platform-server/src/domino_adapter.ts index 8ea4035c80..17bf3c4fc9 100644 --- a/packages/platform-server/src/domino_adapter.ts +++ b/packages/platform-server/src/domino_adapter.ts @@ -13,6 +13,12 @@ function _notImplemented(methodName: string) { return new Error('This method is not implemented in DominoAdapter: ' + methodName); } +function setDomTypes() { + // Make all Domino types available as types in the global env. + Object.assign(global, domino.impl); + (global as any)['KeyboardEvent'] = domino.impl.Event; +} + /** * Parses a document string to a Document object. */ @@ -33,7 +39,10 @@ export function serializeDocument(doc: Document): string { * DOM Adapter for the server platform based on https://github.com/fgnass/domino. */ export class DominoAdapter extends BrowserDomAdapter { - static makeCurrent() { setRootDomAdapter(new DominoAdapter()); } + static makeCurrent() { + setDomTypes(); + setRootDomAdapter(new DominoAdapter()); + } private static defaultDoc: Document; diff --git a/packages/platform-server/test/integration_spec.ts b/packages/platform-server/test/integration_spec.ts index 092e135153..bc27c9d856 100644 --- a/packages/platform-server/test/integration_spec.ts +++ b/packages/platform-server/test/integration_spec.ts @@ -10,7 +10,7 @@ import {AnimationBuilder, animate, style, transition, trigger} from '@angular/an import {APP_BASE_HREF, PlatformLocation, isPlatformServer} from '@angular/common'; import {HttpClient, HttpClientModule} from '@angular/common/http'; import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing'; -import {ApplicationRef, CompilerFactory, Component, HostListener, Input, NgModule, NgModuleRef, NgZone, PLATFORM_ID, PlatformRef, ViewEncapsulation, destroyPlatform, getPlatform} from '@angular/core'; +import {ApplicationRef, CompilerFactory, Component, HostListener, Inject, Input, NgModule, NgModuleRef, NgZone, PLATFORM_ID, PlatformRef, ViewEncapsulation, destroyPlatform, getPlatform} from '@angular/core'; import {TestBed, async, inject} from '@angular/core/testing'; import {Http, HttpModule, Response, ResponseOptions, XHRBackend} from '@angular/http'; import {MockBackend, MockConnection} from '@angular/http/testing'; @@ -254,6 +254,20 @@ class MyInputComponent { class NameModule { } +@Component({selector: 'app', template: '
'}) +class HTMLTypesApp { + html = 'foo bar'; + constructor(@Inject(DOCUMENT) doc: Document) {} +} + +@NgModule({ + declarations: [HTMLTypesApp], + imports: [BrowserModule.withServerTransition({appId: 'inner-html'}), ServerModule], + bootstrap: [HTMLTypesApp] +}) +class HTMLTypesModule { +} + const TEST_KEY = makeStateKey