Skip to content
This repository has been archived by the owner on Aug 2, 2018. It is now read-only.

Commit

Permalink
Do not redirect if no url given
Browse files Browse the repository at this point in the history
  • Loading branch information
tomalec committed Oct 1, 2014
1 parent 6b8d4fc commit 8824578
Showing 1 changed file with 19 additions and 22 deletions.
41 changes: 19 additions & 22 deletions src/juicy-redirect.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,29 @@
break;
}
};
JuicyRedirectElementPrototype.redirect = function(newVal){
var url;
if(newVal == "current") {
JuicyRedirectElementPrototype.redirect = function(url){
if(!url){
return false;
}
if(url == "current") {
url = window.location.href;
}
else {
url = newVal;
if(this.hasAttribute("history")) {
history.pushState(null, null, url);
this.dispatchEvent(
new CustomEvent(
"juicy-redirect-pushstate",
{
"detail":{"url":url},
"bubbles": true
}
)
);
}
if(url != "") {
if(this.hasAttribute("history")) {
history.pushState(null, null, url);
this.dispatchEvent(
new CustomEvent(
"juicy-redirect-pushstate",
{
"detail":{"url":url},
"bubbles": true
}
)
);
}
else {
window.location = url;
}
this.setAttribute("url", "");
else {
window.location = url;
}
this.setAttribute("url", "");
return url;
}

Expand Down

0 comments on commit 8824578

Please sign in to comment.