Skip to content

Commit 264ffbc

Browse files
committed
Fixed #1074 where .html() was incorrectly changing the selected value of an option.
1 parent 32b3ac4 commit 264ffbc

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,7 @@ jQuery.extend({
932932
var wrap =
933933
// option or optgroup
934934
!tags.indexOf("<opt") &&
935-
[ 1, "<select>", "</select>" ] ||
935+
[ 1, "<select multiple='multiple'>", "</select>" ] ||
936936

937937
!tags.indexOf("<leg") &&
938938
[ 1, "<fieldset>", "</fieldset>" ] ||

test/unit/core.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -882,15 +882,19 @@ test("val(String)", function() {
882882
var scriptorder = 0;
883883

884884
test("html(String)", function() {
885-
expect(9);
885+
expect(10);
886886
var div = $("div");
887887
div.html("<b>test</b>");
888888
var pass = true;
889889
for ( var i = 0; i < div.size(); i++ ) {
890-
if ( div.get(i).childNodes.length == 0 ) pass = false;
890+
if ( div.get(i).childNodes.length == 0 ) pass = false;
891891
}
892892
ok( pass, "Set HTML" );
893893

894+
$("#main").html("<select/>");
895+
$("#main select").html("<option>O1</option><option selected='selected'>O2</option><option>O3</option>");
896+
equals( $("#main select").val(), "O2", "Selected option correct" );
897+
894898
stop();
895899

896900
$("#main").html('<script type="text/javascript">ok( true, "$().html().evalScripts() Evals Scripts Twice in Firefox, see #975" );</script>');

0 commit comments

Comments
 (0)