X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fjquery%2Fjquery.js;h=deb214bcd7f3f34ea4507a6a9c06920a9e4f0c84;hb=3527e8f6745786e65dc209f1518372f3270a9920;hp=70c3c605c41f3c47e4b7eda44ce53f9c74208dfb;hpb=401b58c17e5b1e666ea30c262399254ae0a60a0e;p=jquery.git diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js index 70c3c60..deb214b 100644 --- a/src/jquery/jquery.js +++ b/src/jquery/jquery.js @@ -391,8 +391,8 @@ jQuery.fn = jQuery.prototype = { * ok( $('#simon').attr('class') == "blog link", 'Check for class attribute' ); * ok( $('#name').attr('name') == "name", 'Check for name attribute' ); * ok( $('#text1').attr('name') == "action", 'Check for name attribute' ); - * ok( $('#form').attr('action') == "formaction", 'Check for action attribute' ); - * + * ok( $('#form').attr('action').indexOf("formaction") >= 0, 'Check for action attribute' ); + * * @name attr * @type Object * @param String name The name of the property to access. @@ -493,7 +493,7 @@ jQuery.fn = jQuery.prototype = { * representation of itself. Eg. fontWeight, fontSize, fontFamily, borderWidth, * borderStyle, borderBottomWidth etc. * - * @test ok( $('#foo').css("display") == 'block', 'Check for css property "display"'); + * @test ok( $('#main').css("display") == 'none', 'Check for css property "display"'); * * @name css * @type Object @@ -667,12 +667,6 @@ jQuery.fn = jQuery.prototype = { * var result = $('#first').append('buga'); * ok( result.text() == defaultText + 'buga', 'Check if text appending works' ); * - * 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. @@ -982,6 +976,12 @@ jQuery.fn = jQuery.prototype = { * @result $("p").filter(".selected") == [

Hello

] * * @test isSet( $("input").filter(":checked").get(), q("radio2", "check1"), "Filter elements" ); + * @test $("input").filter(":checked",function(i){ + * ok( this == q("radio2", "check1")[i], "Filter elements, context" ); + * }); + * @test $("#main > p#ap > a").filter("#foobar",function(){},function(i){ + * ok( this == q("google","groups", "mark")[i], "Filter elements, else context" ); + * }); * * @name filter * @type jQuery @@ -1047,6 +1047,7 @@ jQuery.fn = jQuery.prototype = { * @example $("p").not("#selected") * @before

Hello

Hello Again

* @result [

Hello

] + * * @test ok($("#main > p#ap > a").not("#google").length == 2, ".not") * * @name not @@ -1157,7 +1158,7 @@ jQuery.fn = jQuery.prototype = { is: function(expr) { return expr ? jQuery.filter(expr,this).r.length > 0 : false; }, - + /** * * @@ -1206,17 +1207,23 @@ jQuery.fn = jQuery.prototype = { */ pushStack: function(a,args) { var fn = args && args[args.length-1]; + var fn2 = args && args[args.length-2]; + + if ( fn && fn.constructor != Function ) fn = null; + if ( fn2 && fn2.constructor != Function ) fn2 = null; - if ( !fn || fn.constructor != Function ) { + if ( !fn ) { if ( !this.stack ) this.stack = []; this.stack.push( this.get() ); this.get( a ); } else { var old = this.get(); this.get( a ); - if ( typeof fn == "function" ) - this.each( fn ); - this.get( old ); + + if ( fn2 && a.length || !fn2 ) + this.each( fn2 || fn ).get( old ); + else + this.get( old ).each( fn ); } return this; @@ -1824,6 +1831,8 @@ jQuery.extend({ if ( fix[name] ) { if ( value != undefined ) elem[fix[name]] = value; return elem[fix[name]]; + } else if( value == undefined && $.browser.msie && elem.nodeName && elem.nodeName.toUpperCase() == 'FORM' && (name == 'action' || name == 'method') ) { + return elem.getAttributeNode(name).nodeValue; } else if ( elem.getAttribute != undefined ) { if ( value != undefined ) elem.setAttribute( name, value ); return elem.getAttribute( name, 2 ); @@ -1837,13 +1846,13 @@ jQuery.extend({ // The regular expressions that power the parsing engine parse: [ // Match: [@value='test'], [@foo] - "\\[ *(@)S *([!*$^=]*)Q\\]", + "\\[ *(@)S *([!*$^=]*) *('?\"?)(.*?)\\4 *\\]", // Match: [div], [div p] - "(\\[)Q\\]", + "(\\[)\s*(.*?)\s*\\]", // Match: :contains('foo') - "(:)S\\(Q\\)", + "(:)S\\(\"?'?([^\\)]*?)\"?'?\\)", // Match: :even, :last-chlid "([:.#]*)S" @@ -1859,28 +1868,19 @@ jQuery.extend({ var p = jQuery.parse; for ( var i = 0; i < p.length; i++ ) { - // get number for backreference - var br = 0; - if(p[i].indexOf('Q') != -1){ - br = p[i].replace(/\\\(/g,'').match(/\(|S/g).length+1; - } - var re = new RegExp( "^" + p[i] - - // Look for a string-like sequence - .replace( 'S', "([a-z*_-][a-z0-9_-]*)" ) - - // Look for something (optionally) enclosed with quotes - .replace( 'Q', " *('|\"|)([^'\"]*?)\\"+br+" *" ), "i" ); + + // Look for, and replace, string-like sequences + // and finally build a regexp out of it + var re = new RegExp( + "^" + p[i].replace("S", "([a-z*_-][a-z0-9_-]*)"), "i" ); var m = re.exec( t ); if ( m ) { - // Re-organize the match - if(br == 4){ + // Re-organize the first match + if ( !i ) m = ["",m[1], m[3], m[2], m[5]]; - } else if(br != 0) { - m.splice(br,1); - } + // Remove what we just matched t = t.replace( re, "" );