var functionReturningObj = function(value) { return (function() { return value; }); };
test("attr(String)", function() {
- expect(28);
+ expect(30);
// This one sometimes fails randomly ?!
equals( jQuery('#text1').attr('value'), "Test", 'Check for value attribute' );
select.appendChild( optgroup );
equals( jQuery(option).attr("selected"), true, "Make sure that a single option is selected, even when in an optgroup." );
+
+ ok( jQuery("<div/>").attr("doesntexist") === undefined, "Make sure undefined is returned when no attribute is found." );
+ ok( jQuery().attr("doesntexist") === undefined, "Make sure undefined is returned when no element is there." );
});
if ( !isLocal ) {
});
var testAddClass = function(valueObj) {
- expect(2);
+ expect(5);
var div = jQuery("div");
div.addClass( valueObj("test") );
var pass = true;
var j = jQuery("#nonnodes").contents();
j.addClass( valueObj("asdf") );
ok( j.hasClass("asdf"), "Check node,textnode,comment for addClass" );
+
+ div = jQuery("<div/>");
+
+ div.addClass( valueObj("test") );
+ equals( div.attr("class"), "test", "Make sure there's no extra whitespace." );
+
+ div.attr("class", " foo");
+ div.addClass( valueObj("test") );
+ equals( div.attr("class"), "foo test", "Make sure there's no extra whitespace." );
+
+ div.attr("class", "foo");
+ div.addClass( valueObj("bar baz") );
+ equals( div.attr("class"), "foo bar baz", "Make sure there isn't too much trimming." );
};
test("addClass(String)", function() {
});
div.addClass(function(i, val) {
- equals( val, old[i], "Make sure the incoming value is correct." );
- return "test";
+ if ( this.id !== "_firebugConsole" ) {
+ equals( val, old[i], "Make sure the incoming value is correct." );
+ return "test";
+ }
});
var pass = true;
});
var testRemoveClass = function(valueObj) {
- expect(5);
+ expect(7);
var $divs = jQuery('div');
var j = jQuery("#nonnodes").contents();
j.removeClass( valueObj("asdf") );
ok( !j.hasClass("asdf"), "Check node,textnode,comment for removeClass" );
+
+ var div = document.createElement("div");
+ div.className = " test foo ";
+
+ jQuery(div).removeClass( valueObj("foo") );
+ equals( div.className, "test", "Make sure remaining className is trimmed." );
+
+ div.className = " test ";
+
+ jQuery(div).removeClass( valueObj("test") );
+ equals( div.className, "", "Make sure there is nothing left after everything is removed." );
};
test("removeClass(String) - simple", function() {
});
$divs.removeClass(function(i, val) {
- equals( val, old[i], "Make sure the incoming value is correct." );
- return "test";
+ if ( this.id !== "_firebugConsole" ) {
+ equals( val, old[i], "Make sure the incoming value is correct." );
+ return "test";
+ }
});
ok( !$divs.is('.test'), "Remove Class" );