Skip to content

Commit

Permalink
Fixed #1074 where .html() was incorrectly changing the selected value…
Browse files Browse the repository at this point in the history
… of an option.
  • Loading branch information
davids549 committed Nov 17, 2007
1 parent 32b3ac4 commit 264ffbc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ jQuery.extend({
var wrap =
// option or optgroup
!tags.indexOf("<opt") &&
[ 1, "<select>", "</select>" ] ||
[ 1, "<select multiple='multiple'>", "</select>" ] ||

!tags.indexOf("<leg") &&
[ 1, "<fieldset>", "</fieldset>" ] ||
Expand Down
8 changes: 6 additions & 2 deletions test/unit/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -882,15 +882,19 @@ test("val(String)", function() {
var scriptorder = 0;

test("html(String)", function() {
expect(9);
expect(10);
var div = $("div");
div.html("<b>test</b>");
var pass = true;
for ( var i = 0; i < div.size(); i++ ) {
if ( div.get(i).childNodes.length == 0 ) pass = false;
if ( div.get(i).childNodes.length == 0 ) pass = false;
}
ok( pass, "Set HTML" );

$("#main").html("<select/>");
$("#main select").html("<option>O1</option><option selected='selected'>O2</option><option>O3</option>");
equals( $("#main select").val(), "O2", "Selected option correct" );

stop();

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

0 comments on commit 264ffbc

Please sign in to comment.