Changeset 104864 in webkit


Ignore:
Timestamp:
Jan 12, 2012 2:57:14 PM (12 years ago)
Author:
jonlee@apple.com
Message:

Setting value on a select element to a non existing option value should clear selection
https://bugs.webkit.org/show_bug.cgi?id=67233
<rdar://problem/10057159>

Reviewed by Darin Adler.

Source/WebCore:

Test: fast/forms/select/setting-to-invalid-value.html

  • html/HTMLSelectElement.cpp:

(WebCore::HTMLSelectElement::setValue): Clear the selection in the cases where we cannot
find an option with the specified value. The spec states to clear the selectedness of all
options first. To avoid calling setSelectedIndex() multiple times, we clear the selected
option(s) only when don't find the appropriate option.

Also, correct the sentence style of a comment.

LayoutTests:

New tests check to see that setting the value of a select element clears the
selection, even if the value is invalid, null, or undefined.

  • fast/forms/select/setting-to-invalid-value-expected.txt: Added.
  • fast/forms/select/setting-to-invalid-value.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r104851 r104864  
     12012-01-12  Jon Lee  <jonlee@apple.com>
     2
     3        Setting value on a select element to a non existing option value should clear selection
     4        https://bugs.webkit.org/show_bug.cgi?id=67233
     5        <rdar://problem/10057159>
     6
     7        Reviewed by Darin Adler.
     8
     9        New tests check to see that setting the value of a select element clears the
     10        selection, even if the value is invalid, null, or undefined.
     11
     12        * fast/forms/select/setting-to-invalid-value-expected.txt: Added.
     13        * fast/forms/select/setting-to-invalid-value.html: Added.
     14
    1152012-01-12  Simon Fraser  <simon.fraser@apple.com>
    216
  • trunk/Source/WebCore/ChangeLog

    r104863 r104864  
     12012-01-12  Jon Lee  <jonlee@apple.com>
     2
     3        Setting value on a select element to a non existing option value should clear selection
     4        https://bugs.webkit.org/show_bug.cgi?id=67233
     5        <rdar://problem/10057159>
     6
     7        Reviewed by Darin Adler.
     8
     9        Test: fast/forms/select/setting-to-invalid-value.html
     10
     11        * html/HTMLSelectElement.cpp:
     12        (WebCore::HTMLSelectElement::setValue): Clear the selection in the cases where we cannot
     13        find an option with the specified value. The spec states to clear the selectedness of all
     14        options first. To avoid calling setSelectedIndex() multiple times, we clear the selected
     15        option(s) only when don't find the appropriate option.
     16
     17        Also, correct the sentence style of a comment.
     18
    1192012-01-12  Jer Noble  <jer.noble@apple.com>
    220
  • trunk/Source/WebCore/html/HTMLSelectElement.cpp

    r104383 r104864  
    248248void HTMLSelectElement::setValue(const String &value)
    249249{
    250     if (value.isNull())
     250    // We clear the previously selected option(s) when needed, to guarantee calling setSelectedIndex() only once.
     251    if (value.isNull()) {
     252        setSelectedIndex(-1);
    251253        return;
    252     // find the option with value() matching the given parameter
    253     // and make it the current selection.
     254    }
     255
     256    // Find the option with value() matching the given parameter and make it the current selection.
    254257    const Vector<HTMLElement*>& items = listItems();
    255258    unsigned optionIndex = 0;
     
    263266        }
    264267    }
     268
     269    setSelectedIndex(-1);
    265270}
    266271
Note: See TracChangeset for help on using the changeset viewer.