Skip to content

Commit

Permalink
fix(platform-server): correctly implement get href in parse5 adapter (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenPandaz authored and chuckjaz committed Mar 14, 2017
1 parent 778f7d6 commit 80649ea
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/platform-server/src/parse5_adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 14 additions & 1 deletion packages/platform-server/test/integration_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -170,6 +170,19 @@ export function main() {
});
}));

it('should get base href from document', async(() => {
const platform = platformDynamicServer([{
provide: INITIAL_CONFIG,
useValue:
{document: '<html><head><base href="/"></head><body><app></app></body></html>'}
}]);
platform.bootstrapModule(ExampleModule).then((moduleRef) => {
const location = moduleRef.injector.get(PlatformLocation);
expect(location.getBaseHrefFromDOM()).toEqual('/');
platform.destroy();
});
}));

it('adds styles with ng-transition attribute', async(() => {
const platform = platformDynamicServer([{
provide: INITIAL_CONFIG,
Expand Down

0 comments on commit 80649ea

Please sign in to comment.