Code cleanup
This commit is contained in:
@@ -1,15 +1,17 @@
|
|||||||
|
var attrState = "data-pjax-state"
|
||||||
|
|
||||||
module.exports = function(el) {
|
module.exports = function(el) {
|
||||||
switch (el.tagName.toLowerCase()) {
|
switch (el.tagName.toLowerCase()) {
|
||||||
case "a":
|
case "a":
|
||||||
// only attach link if el does not already have link attached
|
// only attach link if el does not already have link attached
|
||||||
if (!el.hasAttribute("data-pjax-state")) {
|
if (!el.hasAttribute(attrState)) {
|
||||||
this.attachLink(el)
|
this.attachLink(el)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
|
||||||
case "form":
|
case "form":
|
||||||
// only attach link if el does not already have link attached
|
// only attach link if el does not already have link attached
|
||||||
if (!el.hasAttribute("data-pjax-state")) {
|
if (!el.hasAttribute(attrState)) {
|
||||||
this.attachForm(el)
|
this.attachForm(el)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ tape("test attach form preventDefaulted events", function(t) {
|
|||||||
var loadUrlCalled = false
|
var loadUrlCalled = false
|
||||||
var form = document.createElement("form")
|
var form = document.createElement("form")
|
||||||
|
|
||||||
// This needs to be before the call to attachFormk()
|
// This needs to be before the call to attachForm()
|
||||||
on(form, "submit", function(event) { event.preventDefault() })
|
on(form, "submit", function(event) { event.preventDefault() })
|
||||||
|
|
||||||
attachForm.call({
|
attachForm.call({
|
||||||
|
|||||||
Reference in New Issue
Block a user