Bug 26901

Summary: Cannot set the length of a select to zero using javascript.
Product: WebKit Reporter: Gene Chow <gene>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: RESOLVED INVALID    
Severity: Major    
Priority: P1    
Version: 528+ (Nightly build)   
Hardware: Mac (Intel)   
OS: OS X 10.5   

Description Gene Chow 2009-07-01 13:41:59 PDT
The options array for a select cannot be cleared. The code below does not work as expected using Safari 4.01 (5530.18).
-----------
<html>
<head>
	<script type="text/javascript">
		function load() {
			var sel = document.getElementById("select");
			for (var i = 0; i < 20; i++) {
				var opt = new Option('option '+i, i, false, false);
				sel.options[sel.length] = opt;
			}
			alert(sel.length);
			sel.length = 0;
			alert(sel.length);
			sel.options.length = 0;
			alert(sel.options.length);
		}
	</script>
</head>
<body onload="load()">
	<select id="select"></select>
</body>
</html>
Comment 1 Alexey Proskuryakov 2009-07-08 07:29:05 PDT
Could you please clarify why this bug was marked as INVALID?