Commit 10030555 authored by tkent@chromium.org's avatar tkent@chromium.org

Default value of |size| IDL attribute of HTMLSelectElement should be 0.

https://html.spec.whatwg.org/multipage/forms.html#dom-select-size
> The size IDL attribute has a default value of zero.

The new behavior is compatible with IE and Firefox.

BUG=415456

Review URL: https://codereview.chromium.org/579133002

git-svn-id: svn://svn.chromium.org/blink/trunk@182223 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 4019db89
Test HTMLSelectElement::size behavior.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS select.size is 0
PASS select.setAttribute("size", "1"); select.size is 1
PASS select.setAttribute("size", "2"); select.size is 2
PASS select.setAttribute("size", "3"); select.size is 3
PASS select.setAttribute("size", "4"); select.size is 4
PASS select.setAttribute("size", "0"); select.size is 0
PASS select.setAttribute("size", "-1"); select.size is 0
PASS select.setAttribute("size", "abc"); select.size is 0
PASS select.setAttribute("size", "3.14"); select.size is 3
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<script src="../../../resources/js-test.js"></script>
<select></select>
<script>
description('Test HTMLSelectElement::size behavior.');
var select = document.querySelector('select');
shouldBe('select.size', '0');
shouldBe('select.setAttribute("size", "1"); select.size', '1');
shouldBe('select.setAttribute("size", "2"); select.size', '2');
shouldBe('select.setAttribute("size", "3"); select.size', '3');
shouldBe('select.setAttribute("size", "4"); select.size', '4');
shouldBe('select.setAttribute("size", "0"); select.size', '0');
shouldBe('select.setAttribute("size", "-1"); select.size', '0');
shouldBe('select.setAttribute("size", "abc"); select.size', '0');
shouldBe('select.setAttribute("size", "3.14"); select.size', '3');
</script>
......@@ -337,7 +337,7 @@ void HTMLSelectElement::parseAttribute(const QualifiedName& name, const AtomicSt
if (Attribute* sizeAttribute = ensureUniqueElementData().attributes().find(sizeAttr))
sizeAttribute->setValue(attrSize);
}
size = std::max(size, 1);
size = std::max(size, 0);
// Ensure that we've determined selectedness of the items at least once prior to changing the size.
if (oldSize != size)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment