Bug 13448 - REGRESSION: setting an input element's value to JavaScript null gives "null"
Summary: REGRESSION: setting an input element's value to JavaScript null gives "null"
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: 523.x (Safari 3)
Hardware: Mac OS X 10.4
: P1 Normal
Assignee: Sam Weinig
Keywords: InRadar
Depends on:
Reported: 2007-04-22 10:30 PDT by Darin Adler
Modified: 2007-04-24 09:32 PDT (History)
3 users (show)

See Also:

test case (ready for layout tests directory) (740 bytes, text/html)
2007-04-22 10:31 PDT, Darin Adler
no flags Details
patch (6.36 KB, patch)
2007-04-24 08:07 PDT, Sam Weinig
mitz: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Darin Adler 2007-04-22 10:30:38 PDT
While working on another bug, I noticed this regression. Setting an input element's value to JavaScript null now gives us "null" instead of "". I tested Gecko and it works like the old version of Safari -- gives "".
Comment 1 Darin Adler 2007-04-22 10:31:05 PDT
Created attachment 14137 [details]
test case (ready for layout tests directory)
Comment 2 Darin Adler 2007-04-22 10:31:59 PDT
Comment 3 Darin Adler 2007-04-22 12:19:52 PDT
This is actually a bug in the HTML DOM bindings. We have keywords that translate null values into strings with various rules, but I couldn't immediately find the appropriate one to use in HTMLInputElement.idl to fix this. The ones for properties seem to focus on the getter side rather than the setter side.

Somehow we overlooked this when converting HTMLInputElement to auto-generated DOM. The old hand-written DOM binding must have handled this.
Comment 4 Sam Weinig 2007-04-23 08:57:12 PDT
The property keyword that is appropriate here is [ConvertNullToNullString].  It seems that the "name" attribute suffers from the same issue.  I am going to investigate what other attributes might also be affected.
Comment 5 Sam Weinig 2007-04-24 08:02:58 PDT
It seems that all of the attribute that set/get DOMStrings for HTMLInputElement suffer from the same issue except 'type' which treats any unknown value the same as the empty string so the value 'null' is just ignored.  I have a patch which fixes these issues but we should file a followup patch to look into what other elements might also have this issue.  We should also consider, if it makes sense, making conversion from js null to the empty string the default. 
Comment 6 Sam Weinig 2007-04-24 08:07:34 PDT
Created attachment 14158 [details]
Comment 7 mitz 2007-04-24 08:15:03 PDT
Comment on attachment 14158 [details]

Comment 8 Sam Weinig 2007-04-24 08:26:39 PDT
Landed in r21070.
Comment 9 Darin Adler 2007-04-24 09:32:17 PDT
I understand that this is right for the setter side. But is it right for the getter side too?