forked from prototypejs/prototype
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make sure BUTTON elements are included in form serialization
- Loading branch information
Juriy Zaytsev
committed
May 30, 2009
1 parent
6c35231
commit 2c1923c
Showing
5 changed files
with
54 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2c1923c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity. How do you handle the IE6 discrepancies between
innerHTML
andvalue
. I recall that was the issue which prevented us from fixing this.2c1923c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It actually passes all form tests in IE6. Wouldn't it makes sense to simply document IE6 inability to set button's value from "value" attribute set in HTML? Programatically set values are all serialized properly, afaik.
2c1923c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure about that?
2c1923c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About programatically set values being serialized? Yep. That's what test does
form['tf_button'].value = "foo bar";
and thenvar expected = { /*... */ tf_button: 'foo bar', tf_checkbox:'on', tf_radio:'on' }
2c1923c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked and it seems that, as Tobie pointed out, assigning value with
form['tf_button'].value = "foo bar";
actually changes button'sinnerHTML
, and readingvalue
"consistently" returns itsinnerHTML
.A simple workaround is to add a function named
button
that handles buttons cases:However, this line in
testFormSerialize
has to be rewritten to callForm.Element.setValue
instead of assigning withvalue =
.I'll test this against all supported browsers and submit a patch if it's working as expected
2c1923c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What exactly are we working around here? If a user sets button's value, he would expect that value to be visually changed as well, right? Wouldn't the change you're talking about only affect property of a
value
attribute, leaving button displayed with an old value?2c1923c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, actually
<button>
tags appearance should be determined by theirinnerHTML
and not by theirvalue
attribute.2c1923c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The workaround worked well on all browsers, I attached a patch on Lighthouse.