Permalink
Browse files

Optimize the hiding of passed tests.

  • Loading branch information...
1 parent 53688a7 commit 39a23dfb97c34894c3790158bf2b6f792cc175bb @jitter committed Feb 15, 2011
Showing with 10 additions and 10 deletions.
  1. +4 −0 qunit/qunit.css
  2. +6 −10 qunit/qunit.js
View
4 qunit/qunit.css
@@ -74,6 +74,10 @@
list-style-position: inside;
}
+#qunit-tests.hidepass li.pass {
+ display: none;
+}
+
#qunit-tests li strong {
cursor: pointer;
}
View
16 qunit/qunit.js
@@ -177,7 +177,6 @@ Test.prototype = {
var li = id(this.id);
li.className = bad ? "fail" : "pass";
- li.style.display = resultDisplayStyle(!bad);
li.removeChild( li.firstChild );
li.appendChild( b );
li.appendChild( ol );
@@ -675,11 +674,12 @@ addEvent(window, "load", function() {
filter.type = "checkbox";
filter.id = "qunit-filter-pass";
addEvent( filter, "click", function() {
- var li = document.getElementsByTagName("li");
- for ( var i = 0; i < li.length; i++ ) {
- if ( li[i].className.indexOf("pass") > -1 ) {
- li[i].style.display = filter.checked ? "none" : "";
- }
+ var ol = document.getElementById("qunit-tests")
+ if ( filter.checked ) {
+ ol.className = ol.className + " hidepass";
+ } else {
+ var tmp = " " + ol.className.replace( /[\n\t\r]/g, " " ) + " ";
+ ol.className = tmp.replace(/ hidepass /, " ");
}
if ( defined.sessionStorage ) {
sessionStorage.setItem("qunit-filter-passed-tests", filter.checked ? "true" : "");
@@ -796,10 +796,6 @@ function sourceFromStacktrace() {
}
}
-function resultDisplayStyle(passed) {
- return passed && id("qunit-filter-pass") && id("qunit-filter-pass").checked ? 'none' : '';
-}
-
function escapeHtml(s) {
if (!s) {
return "";

0 comments on commit 39a23df

Please sign in to comment.