Skip to content

Commit

Permalink
Reset: Fall back to innerHTML when jQuery isn't available. Fixes #44
Browse files Browse the repository at this point in the history
  • Loading branch information
jzaefferer committed Nov 1, 2010
1 parent 2b3e049 commit 22a0b9b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 8 additions & 1 deletion qunit/qunit.js
Expand Up @@ -403,10 +403,17 @@ extend(QUnit, {

/**
* Resets the test setup. Useful for tests that modify the DOM.
*
* If jQuery is available, uses jQuery's html(), otherwise just innerHTML.
*/
reset: function() {
if ( window.jQuery ) {
jQuery("#main, #qunit-fixture").html( config.fixture );
jQuery( "#main, #qunit-fixture" ).html( config.fixture );
} else {
var main = id( 'main' ) || id( 'qunit-fixture' );
if ( main ) {
main.innerHTML = config.fixture;
}
}
},

Expand Down
2 changes: 0 additions & 2 deletions test/test.js
Expand Up @@ -220,12 +220,10 @@ test("raises", function() {
raises(thrower3, 'Custom!', 'throwing custom object');
});

/* currently fixture reset depends on jQuery's html() method, can't test that, yet
module("fixture");
test("setup", function() {
document.getElementById("qunit-fixture").innerHTML = "foobar";
});
test("basics", function() {
equal( document.getElementById("qunit-fixture").innerHTML, "test markup", "automatically reset" );
});
*/

0 comments on commit 22a0b9b

Please sign in to comment.