Files
pjax/lib/proto/parse-element.js

23 lines
534 B
JavaScript
Raw Normal View History

var attrState = "data-pjax-state"
module.exports = function(el) {
switch (el.tagName.toLowerCase()) {
2018-01-09 00:44:20 -05:00
case "a":
// only attach link if el does not already have link attached
if (!el.hasAttribute(attrState)) {
2018-01-09 00:44:20 -05:00
this.attachLink(el)
}
break
case "form":
// only attach link if el does not already have link attached
if (!el.hasAttribute(attrState)) {
this.attachForm(el)
}
2018-01-09 00:44:20 -05:00
break
2018-01-09 00:44:20 -05:00
default:
throw "Pjax can only be applied on <a> or <form> submit"
}
}