Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Change QUnit fixture reset behavior #195

Merged
merged 1 commit into from

2 participants

@conzett

Change for issue #194

Essentially, cache a clean copy of
the fixture node on load and replace subsequent fixture nodes with that.

On load, clone qunit-fixture element and set config.fixture equal to
that. Change the reset function to replace the entire qunit-fixture
element with a deep copy of the clone.

Added tests to check if properties on the fixture are cleared between
tests.

@conzett conzett Change fixture reset behavior
On load, set clone qunit-fixture element and set config.fixture equal to
that. Change the reset function to replace the entire qunit-fixture
element with a deep copy of the clone. Essentially, cache a clean copy of
the fixture node on load and replace subsequent fixture nodes with that.

Added tests to check if properties on the fixture are cleared between
tests.
b9010d4
@jzaefferer jzaefferer merged commit b9010d4 into from
@jzaefferer
Owner

Thanks, landed.

@jzaefferer jzaefferer referenced this pull request from a commit
@jzaefferer jzaefferer Revert "Change fixture reset behavior", changing #194 and #195 to won…
…tfix.

This reverts commit b9010d4.

That change turned out to cause very sublte bugs in jQuery UI testsuites, where the browser form memory would cache values between testruns. Which doesn't happen with the previous reset implementation. Unfortunate, but not worth the trouble.
24a8f2b
@jzaefferer
Owner

I had to revert this patch, as it caused very subtle trouble downstream in jQuery UI. The type of failure is bad enough that I don't want anyone else to experience that again, so have to change this (and #194) to "wontfix". I will update the documentation accordingly.

For your particular case, just leave the fixture element as-is and use a wrapper or child.

@JamesMGreene JamesMGreene referenced this pull request from a commit
@jzaefferer jzaefferer Revert "Change fixture reset behavior", changing #194 and #195 to won…
…tfix.

This reverts commit b9010d4.

That change turned out to cause very sublte bugs in jQuery UI testsuites, where the browser form memory would cache values between testruns. Which doesn't happen with the previous reset implementation. Unfortunate, but not worth the trouble.
56e37ea
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 1, 2012
  1. @conzett

    Change fixture reset behavior

    conzett authored
    On load, set clone qunit-fixture element and set config.fixture equal to
    that. Change the reset function to replace the entire qunit-fixture
    element with a deep copy of the clone. Essentially, cache a clean copy of
    the fixture node on load and replace subsequent fixture nodes with that.
    
    Added tests to check if properties on the fixture are cleared between
    tests.
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 6 deletions.
  1. +6 −6 qunit/qunit.js
  2. +2 −0  test/test.js
View
12 qunit/qunit.js
@@ -564,15 +564,15 @@ extend(QUnit, {
/**
* Resets the test setup. Useful for tests that modify the DOM.
*
- * If jQuery is available, uses jQuery's html(), otherwise just innerHTML.
+ * If jQuery is available, uses jQuery's replaceWith(), otherwise use replaceChild
*/
reset: function() {
if ( window.jQuery ) {
- jQuery( "#qunit-fixture" ).html( config.fixture );
- } else {
- var main = id( 'qunit-fixture' );
+ jQuery( "#qunit-fixture" ).replaceWith( config.fixture.outerHTML );
+ } else {
+ main = id( 'qunit-fixture' );
if ( main ) {
- main.innerHTML = config.fixture;
+ main.parentNode.replaceChild(config.fixture.cloneNode(true), main);
}
}
},
@@ -779,7 +779,7 @@ QUnit.load = function() {
var main = id('qunit-fixture');
if ( main ) {
- config.fixture = main.innerHTML;
+ config.fixture = main.cloneNode(true);
}
if (config.autostart) {
View
2  test/test.js
@@ -313,9 +313,11 @@ if (typeof document !== "undefined") {
module("fixture");
test("setup", function() {
document.getElementById("qunit-fixture").innerHTML = "foobar";
+ document.getElementById("qunit-fixture").setAttribute('title','foobar');
});
test("basics", function() {
equal( document.getElementById("qunit-fixture").innerHTML, "test markup", "automatically reset" );
+ equal( document.getElementById("qunit-fixture").getAttribute('title'), null, "properties automatically reset" );
});
}
Something went wrong with that request. Please try again.