Code cleanup

This commit is contained in:
Behind The Math
2018-04-09 17:39:20 -04:00
parent 4c0b6d6251
commit a42ae57448
2 changed files with 5 additions and 3 deletions

View File

@@ -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

View File

@@ -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({