diff --git a/modules/@angular/compiler-cli/integrationtest/src/module.ts b/modules/@angular/compiler-cli/integrationtest/src/module.ts index 9a39e82b2f..9abec97280 100644 --- a/modules/@angular/compiler-cli/integrationtest/src/module.ts +++ b/modules/@angular/compiler-cli/integrationtest/src/module.ts @@ -8,7 +8,7 @@ import {ApplicationRef, NgModule} from '@angular/core'; import {FormsModule} from '@angular/forms'; -import {BrowserModule} from '@angular/platform-browser'; +import {ServerModule} from '@angular/platform-server'; import {MdButtonModule} from '@angular2-material/button'; import {ThirdpartyModule} from '../third_party_src/module'; @@ -48,7 +48,7 @@ import {CompForChildQuery, CompWithChildQuery, CompWithDirectiveChild, Directive ComponentUsingThirdParty, ], imports: [ - BrowserModule, + ServerModule, FormsModule, MdButtonModule, ModuleUsingCustomElements, diff --git a/modules/@angular/compiler-cli/integrationtest/src/module_fixtures.ts b/modules/@angular/compiler-cli/integrationtest/src/module_fixtures.ts index a1891e157e..bebdf7a725 100644 --- a/modules/@angular/compiler-cli/integrationtest/src/module_fixtures.ts +++ b/modules/@angular/compiler-cli/integrationtest/src/module_fixtures.ts @@ -8,7 +8,6 @@ import {LowerCasePipe, NgIf} from '@angular/common'; import {ANALYZE_FOR_ENTRY_COMPONENTS, Component, ComponentFactoryResolver, Directive, Inject, Injectable, Input, ModuleWithProviders, NgModule, OpaqueToken, Pipe} from '@angular/core'; -import {BrowserModule} from '@angular/platform-browser'; @Injectable() export class SomeService { diff --git a/modules/@angular/compiler/src/view_compiler/view_builder.ts b/modules/@angular/compiler/src/view_compiler/view_builder.ts index c290b924f3..204b125639 100644 --- a/modules/@angular/compiler/src/view_compiler/view_builder.ts +++ b/modules/@angular/compiler/src/view_compiler/view_builder.ts @@ -528,7 +528,8 @@ function generateCreateMethod(view: CompileView): o.Statement[] { resultExpr = o.NULL_EXPR; } let allNodesExpr: o.Expression = - ViewProperties.renderer.prop('directRenderer') + ViewProperties.renderer.cast(o.DYNAMIC_TYPE) + .prop('directRenderer') .conditional(o.NULL_EXPR, o.literalArr(view.nodes.map(node => node.renderNode))); return parentRenderNodeStmts.concat(view.createMethod.finish(), [ diff --git a/modules/@angular/core/test/linker/direct_rendering_integration_spec.ts b/modules/@angular/core/test/linker/direct_rendering_integration_spec.ts index a77e5f8edf..73d68ae6a3 100644 --- a/modules/@angular/core/test/linker/direct_rendering_integration_spec.ts +++ b/modules/@angular/core/test/linker/direct_rendering_integration_spec.ts @@ -100,7 +100,7 @@ export function main() { const fixture = TestBed.createComponent(MyComp); fixture.detectChanges(); - destroyViewLogs.splice(0, destroyViewLogs.length); + destroyViewLogs.length = 0; fixture.componentInstance.shown = false; fixture.detectChanges(); diff --git a/modules/@angular/platform-browser/src/dom/dom_renderer.ts b/modules/@angular/platform-browser/src/dom/dom_renderer.ts index 792eed3600..bb96fbb7e1 100644 --- a/modules/@angular/platform-browser/src/dom/dom_renderer.ts +++ b/modules/@angular/platform-browser/src/dom/dom_renderer.ts @@ -55,11 +55,15 @@ export class DomRootRenderer_ extends DomRootRenderer { } export const DIRECT_DOM_RENDERER: DirectRenderer = { - remove(node: Text | Comment | Element) { node.remove();}, + remove(node: Text | Comment | Element) { + if (node.parentNode) { + node.parentNode.removeChild(node); + } + }, appendChild(node: Node, parent: Element) { parent.appendChild(node);}, - insertBefore(node: Node, refNode: Node) { refNode.parentElement.insertBefore(node, refNode);}, + insertBefore(node: Node, refNode: Node) { refNode.parentNode.insertBefore(node, refNode);}, nextSibling(node: Node) { return node.nextSibling;}, - parentElement(node: Node): Element{return node.parentElement;} + parentElement(node: Node): Element{return node.parentNode as Element;} }; export class DomRenderer implements Renderer { @@ -165,7 +169,10 @@ export class DomRenderer implements Renderer { detachView(viewRootNodes: (Element|Text|Comment)[]) { for (let i = 0; i < viewRootNodes.length; i++) { - viewRootNodes[i].remove(); + const node = viewRootNodes[i]; + if (node.parentNode) { + node.parentNode.removeChild(node); + } } } @@ -260,7 +267,7 @@ export class DomRenderer implements Renderer { } function moveNodesAfterSibling(sibling: Node, nodes: Node[]) { - const parent = sibling.parentElement; + const parent = sibling.parentNode; if (nodes.length > 0 && parent) { const nextSibling = sibling.nextSibling; if (nextSibling) { diff --git a/modules/@angular/platform-server/src/private_export.ts b/modules/@angular/platform-server/src/private_export.ts index 497ea8d270..939e44a0dd 100644 --- a/modules/@angular/platform-server/src/private_export.ts +++ b/modules/@angular/platform-server/src/private_export.ts @@ -7,9 +7,12 @@ */ -import {INTERNAL_SERVER_PLATFORM_PROVIDERS} from './server'; +import {INTERNAL_SERVER_PLATFORM_PROVIDERS, SERVER_RENDER_PROVIDERS} from './server'; -export var __platform_server_private__: - {INTERNAL_SERVER_PLATFORM_PROVIDERS: typeof INTERNAL_SERVER_PLATFORM_PROVIDERS} = { - INTERNAL_SERVER_PLATFORM_PROVIDERS: INTERNAL_SERVER_PLATFORM_PROVIDERS - }; +export var __platform_server_private__: { + INTERNAL_SERVER_PLATFORM_PROVIDERS: typeof INTERNAL_SERVER_PLATFORM_PROVIDERS, + SERVER_RENDER_PROVIDERS: typeof SERVER_RENDER_PROVIDERS, +} = { + INTERNAL_SERVER_PLATFORM_PROVIDERS: INTERNAL_SERVER_PLATFORM_PROVIDERS, + SERVER_RENDER_PROVIDERS: SERVER_RENDER_PROVIDERS, +}; diff --git a/modules/@angular/platform-server/src/private_import_platform-browser.ts b/modules/@angular/platform-server/src/private_import_platform-browser.ts index be5eac1a17..baeda1c481 100644 --- a/modules/@angular/platform-server/src/private_import_platform-browser.ts +++ b/modules/@angular/platform-server/src/private_import_platform-browser.ts @@ -13,7 +13,7 @@ export var DomAdapter: typeof _.DomAdapter = _.DomAdapter; export var setRootDomAdapter: typeof _.setRootDomAdapter = _.setRootDomAdapter; export var getDOM: typeof _.getDOM = _.getDOM; export var SharedStylesHost: typeof _.SharedStylesHost = _.SharedStylesHost; -export type SharedStylesHost = typeof _.SharedStylesHost; +export type SharedStylesHost = typeof _._SharedStylesHost; export var NAMESPACE_URIS: typeof _.NAMESPACE_URIS = _.NAMESPACE_URIS; export var shimContentAttribute: typeof _.shimContentAttribute = _.shimContentAttribute; export var shimHostAttribute: typeof _.shimHostAttribute = _.shimHostAttribute; diff --git a/modules/@angular/platform-server/src/server.ts b/modules/@angular/platform-server/src/server.ts index 85a669c4a9..72db3a2512 100644 --- a/modules/@angular/platform-server/src/server.ts +++ b/modules/@angular/platform-server/src/server.ts @@ -8,7 +8,7 @@ import {PlatformLocation} from '@angular/common'; import {platformCoreDynamic} from '@angular/compiler'; -import {NgModule, PLATFORM_INITIALIZER, PlatformRef, Provider, RootRenderer, createPlatformFactory, isDevMode, platformCore} from '@angular/core'; +import {Injectable, NgModule, PLATFORM_INITIALIZER, PlatformRef, Provider, RootRenderer, createPlatformFactory, isDevMode, platformCore} from '@angular/core'; import {BrowserModule} from '@angular/platform-browser'; import {Parse5DomAdapter} from './parse5_adapter'; @@ -53,7 +53,8 @@ export function _createConditionalRootRenderer(rootRenderer: any) { export const SERVER_RENDER_PROVIDERS: Provider[] = [ ServerRootRenderer, {provide: RootRenderer, useFactory: _createConditionalRootRenderer, deps: [ServerRootRenderer]}, - {provide: SharedStylesHost, useClass: SharedStylesHost}, + // use plain SharedStylesHost, not the DomSharedStylesHost + SharedStylesHost ]; /** @@ -61,7 +62,7 @@ export const SERVER_RENDER_PROVIDERS: Provider[] = [ * * @experimental */ -@NgModule({imports: [BrowserModule], providers: SERVER_RENDER_PROVIDERS}) +@NgModule({exports: [BrowserModule], providers: SERVER_RENDER_PROVIDERS}) export class ServerModule { } diff --git a/modules/@angular/platform-server/src/server_renderer.ts b/modules/@angular/platform-server/src/server_renderer.ts index 5635a2867a..480d629665 100644 --- a/modules/@angular/platform-server/src/server_renderer.ts +++ b/modules/@angular/platform-server/src/server_renderer.ts @@ -128,6 +128,8 @@ export class ServerRenderer implements Renderer { destroyView(hostElement: any, viewAllNodes: any[]) {} listen(renderElement: any, name: string, callback: Function): Function { + // Note: We are not using the EventsPlugin here as this is not needed + // to run our tests. var outsideHandler = (event: any) => this._zone.runGuarded(() => callback(event)); return this._zone.runOutsideAngular( () => getDOM().onAndCancel(renderElement, name, outsideHandler)); diff --git a/modules/@angular/platform-server/testing/private_import_platform_server.ts b/modules/@angular/platform-server/testing/private_import_platform_server.ts index d12fb63d72..ea2ac5b55b 100644 --- a/modules/@angular/platform-server/testing/private_import_platform_server.ts +++ b/modules/@angular/platform-server/testing/private_import_platform_server.ts @@ -10,3 +10,4 @@ import {__platform_server_private__ as _} from '@angular/platform-server'; export var INTERNAL_SERVER_PLATFORM_PROVIDERS: typeof _.INTERNAL_SERVER_PLATFORM_PROVIDERS = _.INTERNAL_SERVER_PLATFORM_PROVIDERS; +export var SERVER_RENDER_PROVIDERS: typeof _.SERVER_RENDER_PROVIDERS = _.SERVER_RENDER_PROVIDERS; diff --git a/modules/@angular/platform-server/testing/server.ts b/modules/@angular/platform-server/testing/server.ts index 52c41beb20..1379ccdeb2 100644 --- a/modules/@angular/platform-server/testing/server.ts +++ b/modules/@angular/platform-server/testing/server.ts @@ -10,9 +10,7 @@ import {platformCoreDynamicTesting} from '@angular/compiler/testing'; import {NgModule, PlatformRef, Provider, createPlatformFactory} from '@angular/core'; import {BrowserDynamicTestingModule} from '@angular/platform-browser-dynamic/testing'; -import {SERVER_RENDER_PROVIDERS} from '../src/server'; - -import {INTERNAL_SERVER_PLATFORM_PROVIDERS} from './private_import_platform_server'; +import {INTERNAL_SERVER_PLATFORM_PROVIDERS, SERVER_RENDER_PROVIDERS} from './private_import_platform_server'; /**