Bug 159925 - Fix null handling of HTMLSelectElement.value attribute
Summary: Fix null handling of HTMLSelectElement.value attribute
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: WebExposed
Depends on:
Blocks:
 
Reported: 2016-07-19 10:29 PDT by Chris Dumez
Modified: 2016-07-20 10:42 PDT (History)
5 users (show)

See Also:


Attachments
Patch (5.22 KB, patch)
2016-07-19 10:32 PDT, Chris Dumez
benjamin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2016-07-19 10:29:47 PDT
Fix null handling of HTMLSelectElement.value attribute:
https://html.spec.whatwg.org/multipage/forms.html#htmlselectelement

We currently treat null as the null String which ends up setting selectedIndex to -1. However, we should treat null as the String "null" which would set the selectedIndex to the Index of the <option> element whose value is "null".

Firefox and Chrome match the specification.
Comment 1 Chris Dumez 2016-07-19 10:32:35 PDT
Created attachment 284019 [details]
Patch
Comment 2 Benjamin Poulain 2016-07-19 21:46:51 PDT
Comment on attachment 284019 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=284019&action=review

> LayoutTests/fast/dom/HTMLSelectElement/value-null-handling.html:19
> +evalAndLog("select.value = null");
> +shouldBeEqualToString("select.value", "null");
> +shouldBe("select.selectedIndex", "1");

You are missing a case. Setting the value to null and not having a value==="null" in the select element.
Comment 3 Chris Dumez 2016-07-20 09:38:39 PDT
Committed r203456: <http://trac.webkit.org/changeset/203456>
Comment 4 Chris Dumez 2016-07-20 10:42:44 PDT
(In reply to comment #2)
> Comment on attachment 284019 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=284019&action=review
> 
> > LayoutTests/fast/dom/HTMLSelectElement/value-null-handling.html:19
> > +evalAndLog("select.value = null");
> > +shouldBeEqualToString("select.value", "null");
> > +shouldBe("select.selectedIndex", "1");
> 
> You are missing a case. Setting the value to null and not having a
> value==="null" in the select element.

I added it before landing, thanks.