X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;ds=inline;f=src%2Fjquery%2Fjquery.js;h=9f2189eb9e0bb625f8b9b8ee86f46316742d9246;hb=3b4eeab0444e7295802a4f090257ac5dac6f556a;hp=0b6b1f4fb9c773eae1d9ef6da543701f47466773;hpb=c12bce204620fd2ca95099030da98013a9490c37;p=jquery.git
diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js
index 0b6b1f4..9f2189e 100644
--- a/src/jquery/jquery.js
+++ b/src/jquery/jquery.js
@@ -31,7 +31,7 @@ window.undefined = window.undefined;
jQuery = function(a,c) {
// Shortcut for document ready (because $(document).each() is silly)
- if ( a && a.constructor == Function && jQuery.fn.ready )
+ if ( a && typeof a == "function" && jQuery.fn.ready )
return jQuery(document).ready(a);
// Make sure that a selection was provided
@@ -65,7 +65,7 @@ jQuery = function(a,c) {
var fn = arguments[ arguments.length - 1 ];
// If so, execute it in context
- if ( fn && fn.constructor == Function )
+ if ( fn && typeof fn == "function" )
this.each(fn);
};
@@ -667,6 +667,12 @@ jQuery.fn = jQuery.prototype = {
* var result = $('#first').append('buga');
* ok( result.text() == defaultText + 'buga', 'Check if text appending works' );
*
+ * @test reset();
+ * var expected = "Try them out: bla ";
+ * $('#first').append(" ");
+ * $('#first').append("bla ");
+ * ok( expected == $('#first').text(), "Check for appending of spaces" );
+ *
* @name append
* @type jQuery
* @param String html A string of HTML, that will be created on the fly and appended to the target.
@@ -1013,7 +1019,7 @@ jQuery.fn = jQuery.prototype = {
t.constructor == Boolean &&
( t ? this.get() : [] ) ||
- t.constructor == Function &&
+ typeof t == "function" &&
jQuery.grep( this, t ) ||
jQuery.filter(t,this).r, arguments );
@@ -1208,7 +1214,7 @@ jQuery.fn = jQuery.prototype = {
} else {
var old = this.get();
this.get( a );
- if ( fn.constructor == Function )
+ if ( typeof fn == "function" )
this.each( fn );
this.get( old );
}
@@ -1367,9 +1373,22 @@ jQuery.extend({
o.className += ( o.className ? " " : "" ) + c;
},
remove: function(o,c){
+ /*
o.className = !c ? "" :
o.className.replace(
- new RegExp("(^|\\s*\\b[^-])"+c+"($|\\b(?=[^-]))", "g"), "");
+ new RegExp("(^|\\s*\\b[^-])"+c+"($|\\b(?=[^-]))", "g"), "");*/
+ if( !c ) {
+ o.className = "";
+ } else {
+ var classes = o.className.split(" ");
+ for(var i=0; i
Hello
And Again
* @result [ Hello Again ] * + * @test isSet( $("#foo").children().get(), q("sndp", "en", "sap"), "Check for children" ); + * * @name children * @type jQuery * @cat DOM/Traversing @@ -3027,6 +3062,8 @@ jQuery.macros = { * @beforeHello Again
And Again
Hello Again
] * + * @test isSet( $("#foo").children("[code]").get(), q("sndp", "sap"), "Check for filtered children" ); + * * @name children * @type jQuery * @param String expr An expression to filter the child Elements with @@ -3156,6 +3193,14 @@ jQuery.macros = { * } * ok( pass, "Remove Class" ); * + * @test var div = $("div").addClass("test").addClass("foo").addClass("bar"); + * div.removeClass("test").removeClass("bar").removeClass("foo"); + * var pass = true; + * for ( var i = 0; i < div.size(); i++ ) { + * if ( div.get(i).className.match(/test|bar|foo/) ) pass = false; + * } + * ok( pass, "Remove multiple classes" ); + * * @name removeClass * @type jQuery * @param String class A CSS class to remove from the elements