fix(browser_adapter.ts): baseElement.getAttribute
currently throwing an error ```error Error during instantiation of LocationStrategy! (RouterLink -> Router -> Location -> LocationStrategy). ORIGINAL ERROR: TypeError: baseElement.attr is not a function ``` Closes #3214
This commit is contained in:
@@ -423,7 +423,11 @@ class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
||||
return null;
|
||||
}
|
||||
var baseUri = Uri.parse(href);
|
||||
return baseUri.path;
|
||||
return baseUri.path[0] == '/' ? baseUri.path : ('/' + baseUri.path);
|
||||
}
|
||||
|
||||
resetBaseElement() {
|
||||
baseElement = null;
|
||||
}
|
||||
|
||||
String getUserAgent() {
|
||||
|
||||
@@ -297,6 +297,7 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
||||
}
|
||||
return relativePath(href);
|
||||
}
|
||||
resetBaseElement(): void { baseElement = null; }
|
||||
getUserAgent(): string { return window.navigator.userAgent; }
|
||||
setData(element, name: string, value: string) { element.dataset[name] = value; }
|
||||
getData(element, name: string): string { return element.dataset[name]; }
|
||||
@@ -313,7 +314,7 @@ function getBaseElementHref(): string {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return baseElement.attr('href');
|
||||
return baseElement.getAttribute('href');
|
||||
}
|
||||
|
||||
// based on urlUtils.js in AngularJS 1
|
||||
|
||||
@@ -127,6 +127,7 @@ export class DomAdapter {
|
||||
getHistory(): History { throw _abstract(); }
|
||||
getLocation(): Location { throw _abstract(); }
|
||||
getBaseHref(): string { throw _abstract(); }
|
||||
resetBaseElement(): void { throw _abstract(); }
|
||||
getUserAgent(): string { throw _abstract(); }
|
||||
setData(element, name: string, value: string) { throw _abstract(); }
|
||||
getData(element, name: string): string { throw _abstract(); }
|
||||
|
||||
@@ -400,6 +400,10 @@ class Html5LibDomAdapter implements DomAdapter {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
resetBaseElement() {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
String getUserAgent() {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
@@ -532,6 +532,8 @@ export class Parse5DomAdapter extends DomAdapter {
|
||||
return this.defaultDoc().body;
|
||||
}
|
||||
}
|
||||
getBaseHref(): string { throw 'not implemented'; }
|
||||
resetBaseElement(): void { throw 'not implemented'; }
|
||||
getHistory(): History { throw 'not implemented'; }
|
||||
getLocation(): Location { throw 'not implemented'; }
|
||||
getUserAgent(): string { return "Fake user agent"; }
|
||||
|
||||
Reference in New Issue
Block a user