Include Activated Submit Buttons as Successful Controls. #40

Merged
merged 1 commit into from Jun 28, 2011

Projects

None yet

2 participants

@mhemesath
Contributor

When forms are submitted by clicking on a submit input, the name/value of the submit input should be submitted along with the form. This is line with specification from the W3C: http://www.w3.org/TR/html401/interact/forms.html#h-17.13.2 as well as how jQueries own $("form input[type=subit]").click() would behave.

This pull request does cause another test to fail. I'm not sure its a bad thing, just an object difference caused by the differences in serializing the the forms specifically:

uncaught: AssertionError: expected { query: 'foo bar', '=': '' } to equal { query: 'foo bar' }
@tj
Member
tj commented Jun 28, 2011

true that! I'll pull it down and have a look

@tj tj merged commit 551c9b2 into LearnBoost:master Jun 28, 2011
@tj
Member
tj commented Jun 28, 2011

that = definitely shouldn't be there, but I'll patch that

@tj tj commented on the diff Jun 28, 2011
lib/jquery/index.js
@@ -98,10 +98,11 @@ module.exports = function(browser, $){
form.defaultSelectOptions();
method = form.attr('method') || 'get';
url = form.attr('action') || parse($.browser.path).pathname;
+ var body = $.param(form.serializeArray().concat([{"name" : this[0].name, "value" : this[0].value }]));
@tj
tj Jun 28, 2011 Member

I'm patching but just for reference you can use concat() without providing an array to it, and no need to quote those keys

@mhemesath
mhemesath Jun 28, 2011 Contributor

Ah, didn't know, thanks for the info! I'll tell yah, Im learning a lot digging through your projects!

@tj
tj Jun 28, 2011 Member

$.param() doesnt seem to be doing much, vs serialize i just get:

query=foo+bar&=
query=foo+bar

i've never used that jquery fn before

@mhemesath
mhemesath Jun 28, 2011 Contributor

hm, maybe that isn't needed then? I thought that was needed to convert the serializedArray back into a serialized string.

@tj
tj Jun 28, 2011 Member

yeah it seems fine, i just dont use jquery much. i think that = is because of jquery trying to join when "name" is not present

@tj
tj Jun 28, 2011 Member

I just think your stuff didn't account for when the input doesn't have a name

@mhemesath
mhemesath Jun 28, 2011 Contributor

sorry bout that. Thanks for taking a look and merging! Onward with testing!!!!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment