diff --git a/src/mouse.js b/src/mouse.js index e42e399e..950a4d9b 100644 --- a/src/mouse.js +++ b/src/mouse.js @@ -46,9 +46,9 @@ steal('./synthetic.js', function (Syn) { } //submit a form - if (!(Syn.support.clickSubmits) && (nodeName === "input" && - type === "submit") || - nodeName === 'button') { + if (!(Syn.support.clickSubmits) && ((nodeName === "input" || + nodeName === "button") && + type === "submit")) { var form = Syn.closest(element, "form"); if (form) { diff --git a/test/qunit/mouse_test.js b/test/qunit/mouse_test.js index e9109527..094579bf 100644 --- a/test/qunit/mouse_test.js +++ b/test/qunit/mouse_test.js @@ -15,6 +15,7 @@ steal("src/synthetic.js", function (Syn) { "" + "click me" + "click me" + + "" + ""; }, @@ -113,6 +114,20 @@ steal("src/synthetic.js", function (Syn) { Syn.trigger("click", {}, st.g("checkbox")); }); + + test("Click a button that is type=button should not trigger form submit", function(){ + var timeout = setTimeout(function(){ + ok(true, "Form was not submitted"); + start(); + }); + st.binder("outer", "submit", function(ev){ + clearTimeout(timeout); + ev.preventDefault(); + }); + + Syn.trigger("click", {}, st.g("button")); + stop(); + }); test("Select is changed on click", function () {