Clone options in attach-link to prevent requestOptions changes from persisting
This commit is contained in:
@@ -6,10 +6,11 @@ var clone = require("../clone")
|
||||
var attrClick = "data-pjax-click-state"
|
||||
|
||||
var formAction = function(el, event) {
|
||||
// Since we'll be modifying request options, clone the existing options
|
||||
// so these changes don't persist
|
||||
// Since loadUrl modifies options and we may add our own modifications below,
|
||||
// clone it so the changes don't persist
|
||||
var options = clone(this.options);
|
||||
|
||||
// Initialize requestOptions
|
||||
options.requestOptions = {
|
||||
requestUrl: el.getAttribute("action") || window.location.href,
|
||||
requestMethod: el.getAttribute("method") || "GET",
|
||||
|
||||
@@ -7,6 +7,13 @@ var attrClick = "data-pjax-click-state"
|
||||
var attrKey = "data-pjax-keyup-state"
|
||||
|
||||
var linkAction = function(el, event) {
|
||||
// Since loadUrl modifies options and we may add our own modifications below,
|
||||
// clone it so the changes don't persist
|
||||
var options = clone(this.options);
|
||||
|
||||
// Initialize requestOptions since loadUrl expects it to be an object
|
||||
options.requestOptions = {};
|
||||
|
||||
// Don’t break browser special behavior on links (like page in new window)
|
||||
if (event.which > 1 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {
|
||||
el.setAttribute(attrClick, "modifier")
|
||||
@@ -51,10 +58,9 @@ var linkAction = function(el, event) {
|
||||
this.reload()
|
||||
return
|
||||
}
|
||||
this.options.requestOptions = this.options.requestOptions || {};
|
||||
|
||||
el.setAttribute(attrClick, "load")
|
||||
|
||||
var options = clone(this.options)
|
||||
options.triggerElement = el
|
||||
this.loadUrl(el.href, options)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user