From a42ae57448d4fedfad05ada8b69ae1413fb118ee Mon Sep 17 00:00:00 2001 From: Behind The Math Date: Mon, 9 Apr 2018 17:39:20 -0400 Subject: [PATCH] Code cleanup --- lib/proto/parse-element.js | 6 ++++-- tests/lib/proto/attach-form.js | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/proto/parse-element.js b/lib/proto/parse-element.js index 02659d9..8214a67 100644 --- a/lib/proto/parse-element.js +++ b/lib/proto/parse-element.js @@ -1,15 +1,17 @@ +var attrState = "data-pjax-state" + 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")) { + if (!el.hasAttribute(attrState)) { this.attachLink(el) } break case "form": // only attach link if el does not already have link attached - if (!el.hasAttribute("data-pjax-state")) { + if (!el.hasAttribute(attrState)) { this.attachForm(el) } break diff --git a/tests/lib/proto/attach-form.js b/tests/lib/proto/attach-form.js index 249afc8..865e993 100644 --- a/tests/lib/proto/attach-form.js +++ b/tests/lib/proto/attach-form.js @@ -65,7 +65,7 @@ tape("test attach form preventDefaulted events", function(t) { var loadUrlCalled = false 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() }) attachForm.call({