parse-element.js checks if the element was already parsed by
checking for the `data-pjax-click-state` attribute. However, this
attribute was not added until the link is clicked.
Originally, there was a separate attribute, `data-pjax-enabled`,
which tracked if the element was parsed already, but that was
changed in 9a86044.
This commit merges the attributes for mouse clicks and key presses
into one and adds that attribute when the element is initially
parsed.
21 lines
515 B
JavaScript
21 lines
515 B
JavaScript
module.exports = function(el) {
|
|
switch (el.tagName.toLowerCase()) {
|
|
case "a":
|
|
// only attach link if el does not already have link attached
|
|
if (!el.hasAttribute("data-pjax-state")) {
|
|
this.attachLink(el)
|
|
}
|
|
break
|
|
|
|
case "form":
|
|
// only attach link if el does not already have link attached
|
|
if (!el.hasAttribute("data-pjax-state")) {
|
|
this.attachForm(el)
|
|
}
|
|
break
|
|
|
|
default:
|
|
throw "Pjax can only be applied on <a> or <form> submit"
|
|
}
|
|
}
|