single-spa
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -20,2 +20,3 @@ 'use strict'; | ||
exports.triggerAppChange = triggerAppChange; | ||
exports.navigateToUrl = navigateToUrl; | ||
@@ -186,2 +187,27 @@ var _singleSpaChildAppError = require('./single-spa-child-app-error.js'); | ||
function navigateToUrl(obj) { | ||
var url = void 0; | ||
if (typeof obj === 'string') { | ||
url = obj; | ||
} else if (this && this.href) { | ||
url = this.href; | ||
} else if (obj && obj.currentTarget && obj.currentTarget.href && obj.preventDefault) { | ||
url = obj.currentTarget.href; | ||
obj.preventDefault(); | ||
} else { | ||
throw new Error('singleSpaNavigate must be either called with a string url, with an <a> tag as its context, or with an event whose currentTarget is an <a> tag'); | ||
} | ||
var anchorElement = document.createElement('a'); | ||
anchorElement.setAttribute('href', url); | ||
if (window.location.origin + window.location.pathname === anchorElement.origin + anchorElement.pathname) { | ||
window.location.hash = anchorElement.hash; | ||
} else { | ||
window.history.pushState(null, null, url); | ||
} | ||
} | ||
window.singleSpaNavigate = navigateToUrl; | ||
function urlReroute() { | ||
@@ -188,0 +214,0 @@ performAppChanges([], arguments); |
{ | ||
"name": "single-spa", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "Multiple applications, one page", | ||
@@ -12,3 +12,3 @@ "main": "lib/single-spa.js", | ||
"test": "jasmine", | ||
"build:canopy": "npm run build && rm -rf ../../workplace/customer-spa/jspm_packages/npm/single-spa@2.0.0 && rsync -av . ../../workplace/customer-spa/jspm_packages/npm/single-spa@2.0.0 --exclude node_modules --exclude .git --exclude --spec --exclude examples" | ||
"build:canopy": "npm run build && rm -rf ../../workplace/customer-spa/jspm_packages/npm/single-spa@2.0.2 && rsync -av . ../../workplace/customer-spa/jspm_packages/npm/single-spa@2.0.2 --exclude node_modules --exclude .git --exclude --spec --exclude examples" | ||
}, | ||
@@ -15,0 +15,0 @@ "repository": "https://github.com/CanopyTax/single-spa", |
@@ -150,2 +150,27 @@ import { handleChildAppError } from './single-spa-child-app-error.js'; | ||
export function navigateToUrl(obj) { | ||
let url; | ||
if (typeof obj === 'string') { | ||
url = obj ; | ||
} else if (this && this.href) { | ||
url = this.href; | ||
} else if (obj && obj.currentTarget && obj.currentTarget.href && obj.preventDefault) { | ||
url = obj.currentTarget.href; | ||
obj.preventDefault(); | ||
} else { | ||
throw new Error(`singleSpaNavigate must be either called with a string url, with an <a> tag as its context, or with an event whose currentTarget is an <a> tag`); | ||
} | ||
const anchorElement= document.createElement('a'); | ||
anchorElement.setAttribute('href', url); | ||
if (window.location.origin + window.location.pathname === anchorElement.origin + anchorElement.pathname) { | ||
window.location.hash = anchorElement.hash; | ||
} else { | ||
window.history.pushState(null, null, url); | ||
} | ||
} | ||
window.singleSpaNavigate = navigateToUrl; | ||
function urlReroute() { | ||
@@ -152,0 +177,0 @@ performAppChanges([], arguments) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
46154
1022