Closed
Bug 942321
Opened 11 years ago
Closed 10 years ago
Changing a select option field via javascript doesn't update the validity status of the form
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
FIXED
mozilla32
People
(Reporter: psychicsurgeon, Assigned: agi)
References
()
Details
Attachments
(1 file, 2 obsolete files)
6.70 KB,
patch
|
agi
:
review+
|
Details | Diff | Splinter Review |
If you have a form with a required <select> element with a single <option> item without a value, and then change the value to something valid, the form still returns invalid. See this jsfiddle: http://jsfiddle.net/DxWUs/ It works in chromium, but not firefox. I'm using 23.0a1 (2013-05-09), but it was also reported on FireFox 25.0.1
What's the result in Chomium? With FF25 on Win 7, I have false/false/true.
Component: General → DOM: Core & HTML
Flags: needinfo?(psychicsurgeon)
Product: Firefox → Core
Comment 2•11 years ago
|
||
In Chromium it's false/true/true. Jonas, who's doing forms stuff now, again?
Flags: needinfo?(psychicsurgeon) → needinfo?(jonas)
Comment 4•11 years ago
|
||
I've been doing some forms work, but not touched <select>. I can have a look but I can't see me getting to that before January.
Flags: needinfo?(jwatt)
Reporter | ||
Comment 5•11 years ago
|
||
(In reply to Loic from comment #1) > What's the result in Chomium? > > With FF25 on Win 7, I have false/false/true. Chromium returns false/true/true, which is what I would think would be "correct".
Assignee | ||
Comment 6•10 years ago
|
||
I think I know where the problem is, I'll post a patch by next week.
Assignee: nobody → agi.novanta
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Version: 23 Branch → Trunk
Assignee | ||
Comment 7•10 years ago
|
||
So here the problem is what one would expect, namely that when Option's @value changes the Select element is not notified and consequently the validity state not updated. What I'm doing here is adding a new function to the Select element, OptionValueChanged. This function is called in Option's AfterSetAttr. I'm not very sure of adding this function, but I haven't find a better way of notifying the Select element. Johnny what do you think? Ah, I also added a mochitest, but if you feel is not necessary I don't mind removing it. Thanks!
Attachment #8416288 -
Flags: feedback?(jst)
Comment 8•10 years ago
|
||
Comment on attachment 8416288 [details] [diff] [review] Changing a select option field via javascript updates validity state This generally looks good to me, asking for additional feedback from bz cause the one thing that's not clear is whether or not there are any performance implications here that I'm not seeing. Thanks!
Attachment #8416288 -
Flags: feedback?(jst)
Attachment #8416288 -
Flags: feedback?(bzbarsky)
Attachment #8416288 -
Flags: feedback+
Comment 9•10 years ago
|
||
Comment on attachment 8416288 [details] [diff] [review] Changing a select option field via javascript updates validity state Having a test is good. ;) Having the new function is ok, but we could also just make UpdateValueMissingValidityState public, no? Was there a reason not to do that? However, we should probably only call it if Selected() is true, since otherwise our value doesn't affect the value-missing state, and UpdateValueMissingValidityState() is not exactly cheap.
Attachment #8416288 -
Flags: feedback?(bzbarsky) → feedback+
Assignee | ||
Comment 10•10 years ago
|
||
I thought that exposing the "UpdateValidityState" was bad because from the perspective of a user of HTMLSelectElement the validity should always be current (does that make sense?). But now I'm seeing that, e.g. HTMLInputElement exposes the same member function, so it's probably pointless to hide this bit of the implementation. Thank you both!
Attachment #8416288 -
Attachment is obsolete: true
Attachment #8416956 -
Flags: review?(bzbarsky)
Comment 11•10 years ago
|
||
Comment on attachment 8416956 [details] [diff] [review] Changing a select option field via javascript updates validity state Why mIsSelected instead of Selected()? Or if we think they mean the same thing, can we simplify Selected()? >+ HTMLSelectElement* selectInt = GetSelect(); Just call that "select"? r=me with those dealt with.
Attachment #8416956 -
Flags: review?(bzbarsky) → review+
Assignee | ||
Comment 12•10 years ago
|
||
Oh, I missed Selected()! No, probably it's not the same thing. Thanks Boris! Not asking to review again since it's just a name change. Already pushed to Try here: https://tbpl.mozilla.org/?tree=Try&rev=7e7b0bfad8dc Good to go! Thank you.
Attachment #8416956 -
Attachment is obsolete: true
Attachment #8418484 -
Flags: review+
Assignee | ||
Updated•10 years ago
|
Flags: in-testsuite+
Keywords: checkin-needed
Comment 13•10 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/ed7414cee1d8
Keywords: checkin-needed
Comment 14•10 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/ed7414cee1d8
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla32
You need to log in
before you can comment on or make changes to this bug.
Description
•