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

23 lines
541 B
JavaScript
Raw Permalink Normal View History

2019-03-03 01:37:45 -05:00
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)) {
2019-03-03 01:37:45 -05:00
this.attachLink(el);
2018-01-09 00:44:20 -05:00
}
2019-03-03 01:37:45 -05:00
break;
case "form":
// only attach link if el does not already have link attached
if (!el.hasAttribute(attrState)) {
2019-03-03 01:37:45 -05:00
this.attachForm(el);
}
2019-03-03 01:37:45 -05:00
break;
2018-01-09 00:44:20 -05:00
default:
2019-03-03 01:37:45 -05:00
throw "Pjax can only be applied on <a> or <form> submit";
}
2019-03-03 01:37:45 -05:00
};