diff --git a/packages/platform-server/src/parse5_adapter.ts b/packages/platform-server/src/parse5_adapter.ts index 9d909bff22..27fb309fbb 100644 --- a/packages/platform-server/src/parse5_adapter.ts +++ b/packages/platform-server/src/parse5_adapter.ts @@ -505,7 +505,7 @@ export class Parse5DomAdapter extends DomAdapter { isShadowRoot(node: any): boolean { return this.getShadowRoot(node) == node; } importIntoDoc(node: any): any { return this.clone(node); } adoptNode(node: any): any { return node; } - getHref(el: any): string { return el.href; } + getHref(el: any): string { return this.getAttribute(el, 'href'); } resolveAndSetHref(el: any, baseUrl: string, href: string) { if (href == null) { el.href = baseUrl; diff --git a/packages/platform-server/test/integration_spec.ts b/packages/platform-server/test/integration_spec.ts index 07a16e72d5..d74a6d3497 100644 --- a/packages/platform-server/test/integration_spec.ts +++ b/packages/platform-server/test/integration_spec.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {PlatformLocation, isPlatformServer} from '@angular/common'; +import {APP_BASE_HREF, PlatformLocation, isPlatformServer} from '@angular/common'; import {ApplicationRef, CompilerFactory, Component, NgModule, NgModuleRef, NgZone, PLATFORM_ID, PlatformRef, destroyPlatform, getPlatform} from '@angular/core'; import {TestBed, async, inject} from '@angular/core/testing'; import {Http, HttpModule, Response, ResponseOptions, XHRBackend} from '@angular/http'; @@ -170,6 +170,19 @@ export function main() { }); })); + it('should get base href from document', async(() => { + const platform = platformDynamicServer([{ + provide: INITIAL_CONFIG, + useValue: + {document: '