Skip to content

Commit 6f0c9a5

Browse files
committed
Added support for "first option is auto-selected in a drop-down" functionality.
1 parent 52c6739 commit 6f0c9a5

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

build/runtest/env.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,27 @@ var window = this;
305305
set checked(val) { return this.setAttribute("checked",val); },
306306

307307
get selected() {
308+
if ( !this._selectDone ) {
309+
this._selectDone = true;
310+
311+
if ( this.nodeName == "OPTION" && !this.parentNode.getAttribute("multiple") ) {
312+
var opt = this.parentNode.getElementsByTagName("option");
313+
314+
if ( this == opt[0] ) {
315+
var select = true;
316+
317+
for ( var i = 1; i < opt.length; i++ )
318+
if ( opt[i].selected ) {
319+
select = false;
320+
break;
321+
}
322+
323+
if ( select )
324+
this.selected = true;
325+
}
326+
}
327+
}
328+
308329
var val = this.getAttribute("selected");
309330
return val != "false" && !!val;
310331
},

0 commit comments

Comments
 (0)