can-route-pushstate
Advanced tools
Comparing version 3.4.1 to 3.4.3
@@ -908,2 +908,78 @@ /* jshint asi:true,scripturl:true */ | ||
test("javascript: void(0) links get pushstated", function(){ | ||
stop(); | ||
makeTestingIframe(function (info, done) { | ||
info.route(":type", { type: "yay" }); | ||
info.route.ready(); | ||
var window = info.window; | ||
var link = window.document.createElement("a"); | ||
link.href = "javascript: void(0)"; | ||
link.innerHTML = "Click Me"; | ||
window.document.body.appendChild(link); | ||
try { | ||
domDispatch.call(link, "click"); | ||
ok(true, "Clicking javascript: void(0) anchor did not cause a security exception"); | ||
} catch(err) { | ||
ok(false, "Clicking javascript: void(0) anchor caused a security exception"); | ||
} | ||
start(); | ||
done(); | ||
}); | ||
}); | ||
test("links with target=_blank do not get pushstated", function(){ | ||
stop(); | ||
makeTestingIframe(function (info, done) { | ||
info.route(":type", { type: "yay" }); | ||
info.route.ready(); | ||
var window = info.window; | ||
var link = window.document.createElement("a"); | ||
link.href = "/yay"; | ||
link.target = "_blank"; | ||
link.innerHTML = "Click Me"; | ||
window.document.body.appendChild(link); | ||
try { | ||
domDispatch.call(link, "click"); | ||
ok(true, "Clicking anchor with blank target did not cause a security exception"); | ||
} catch(err) { | ||
ok(false, "Clicking anchor with blank target caused a security exception"); | ||
} | ||
start(); | ||
done(); | ||
}); | ||
}); | ||
test("clicking on links while holding meta key do not get pushstated", function(){ | ||
stop(); | ||
makeTestingIframe(function (info, done) { | ||
info.route(":type", { type: "yay" }); | ||
info.route.ready(); | ||
var window = info.window; | ||
var link = window.document.createElement("a"); | ||
link.href = "/heyo"; | ||
link.innerHTML = "Click Me"; | ||
window.document.body.appendChild(link); | ||
try { | ||
domDispatch.call(link, {type: 'click', metaKey: true}); | ||
ok(true, "Clicking anchor with blank target did not cause a security exception"); | ||
} catch(err) { | ||
ok(false, "Clicking anchor with blank target caused a security exception"); | ||
} | ||
start(); | ||
done(); | ||
}); | ||
}); | ||
} // end steal-only | ||
@@ -910,0 +986,0 @@ |
@@ -180,2 +180,12 @@ // # can/route/pushstate/pushstate.js | ||
// Do not pushstate if target is for blank window. | ||
if (node.target === "_blank") { | ||
return; | ||
} | ||
// Do not pushstate if meta key was pressed, mimicking standard browser behavior. | ||
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) { | ||
return; | ||
} | ||
// If link is within the same domain and descendant of `root` | ||
@@ -182,0 +192,0 @@ if (window.location.host === linksHost) { |
@@ -1,2 +0,2 @@ | ||
/*can-route-pushstate@3.4.0#can-route-pushstate*/ | ||
/*can-route-pushstate@3.4.2#can-route-pushstate*/ | ||
define([ | ||
@@ -105,2 +105,8 @@ 'require', | ||
} | ||
if (node.target === '_blank') { | ||
return; | ||
} | ||
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) { | ||
return; | ||
} | ||
if (window.location.host === linksHost) { | ||
@@ -107,0 +113,0 @@ var root = cleanRoot(); |
{ | ||
"name": "can-route-pushstate", | ||
"version": "3.4.1", | ||
"version": "3.4.3", | ||
"description": "Pushstate for can-route", | ||
@@ -5,0 +5,0 @@ "homepage": "https://canjs.com", |
Sorry, the diff of this file is too big to display
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
285438
7229