X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fjquery%2Fjquery.js;h=97038331c668237e08f5eb331cc535aa8b38e219;hb=060c55bf043922401cb033117a3091ad24dbf047;hp=11cd56e6a6f5aa644afb46ce5f1d5ef502c950cc;hpb=f6ecc6a95c4046f53d1f0d75af213305c2bd7ea7;p=jquery.git diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js index 11cd56e..9703833 100644 --- a/src/jquery/jquery.js +++ b/src/jquery/jquery.js @@ -587,19 +587,17 @@ jQuery.fn = jQuery.prototype = { * and finds the deepest ancestor element within its * structure - it is that element that will en-wrap everything else. * + * This does not work with elements that contain text. Any necessary text + * must be added after the wrapping is done. + * * @example $("p").wrap("
"); * @before

Test Paragraph.

* @result

Test Paragraph.

* * @test var defaultText = 'Try them out:' * var result = $('#first').wrap('
').text(); - * ok( defaultText == result, 'Check for simple wrapping' ); - * ok( $('#first').parent().parent().is('.red'), 'Check if wrapper div has class "red"' ); - * - * @test var defaultText = 'Try them out:' - * var result = $('#first').wrap('
xxyy
').text() - * ok( 'xx' + defaultText + 'yy' == result, 'Check for wrapping' ); - * ok( $('#first').parent().parent().is('.red'), 'Check if wrapper div has class "red"' ); + * ok( defaultText == result, 'Check for wrapping of on-the-fly html' ); + * ok( $('#first').parent().parent().is('.red'), 'Check if wrapper has class "red"' ); * * @name wrap * @type jQuery @@ -617,9 +615,17 @@ jQuery.fn = jQuery.prototype = { * provided and finding the deepest ancestor element within its * structure - it is that element that will en-wrap everything else. * - * @example $("p").wrap("
"); - * @before

Test Paragraph.

- * @result

Test Paragraph.

+ * This does not work with elements that contain text. Any necessary text + * must be added after the wrapping is done. + * + * @example $("p").wrap( document.getElementById('content') ); + * @before

Test Paragraph.

+ * @result

Test Paragraph.

+ * + * @test var defaultText = 'Try them out:' + * var result = $('#first').wrap(document.getElementById('empty')).parent(); + * ok( result.is('ol'), 'Check for element wrapping' ); + * ok( result.text() == defaultText, 'Check for element wrapping' ); * * @name wrap * @type jQuery @@ -1165,7 +1171,7 @@ jQuery.fn = jQuery.prototype = { return this.each(function(){ var obj = this; - if ( table && this.nodeName == "TABLE" && a[0].nodeName != "THEAD" ) { + if ( table && this.nodeName.toUpperCase() == "TABLE" && a[0].nodeName.toUpperCase() != "THEAD" ) { var tbody = this.getElementsByTagName("tbody"); if ( !tbody.length ) { @@ -1212,7 +1218,20 @@ jQuery.fn = jQuery.prototype = { }; /** - * + * Extends the jQuery object itself. Can be used to add both static + * functions and plugin methods. + * + * @example $.fn.extend({ + * check: function() { + * this.each(function() { this.checked = true; }); + * ), + * uncheck: function() { + * this.each(function() { this.checked = false; }); + * } + * }); + * $("input[@type=checkbox]").check(); + * $("input[@type=radio]").uncheck(); + * @desc Adds two plugin methods. * * @private * @name extend @@ -1522,9 +1541,9 @@ jQuery.extend({ "@": { "=": "z==m[4]", "!=": "z!=m[4]", - "^=": "!z.indexOf(m[4])", - "$=": "z.substr(z.length - m[4].length,m[4].length)==m[4]", - "*=": "z.indexOf(m[4])>=0", + "^=": "z && !z.indexOf(m[4])", + "$=": "z && z.substr(z.length - m[4].length,m[4].length)==m[4]", + "*=": "z && z.indexOf(m[4])>=0", "": "z" }, "[": "jQuery.find(m[2],a).length" @@ -1583,6 +1602,11 @@ jQuery.extend({ * @test t( "Attribute Exists", "a[@title]", ["google"] ); * @test t( "Attribute Exists", "*[@title]", ["google"] ); * @test t( "Attribute Exists", "[@title]", ["google"] ); + * + * @test t( "Non-existing part of attribute [@name*=bla]", "[@name*=bla]", [] ); + * @test t( "Non-existing start of attribute [@name^=bla]", "[@name^=bla]", [] ); + * @test t( "Non-existing end of attribute [@name$=bla]", "[@name$=bla]", [] ); + * * @test t( "Attribute Equals", "a[@rel='bookmark']", ["simon1"] ); * @test t( "Attribute Equals", 'a[@rel="bookmark"]', ["simon1"] ); * @test t( "Attribute Equals", "a[@rel=bookmark]", ["simon1"] ); @@ -1638,6 +1662,10 @@ jQuery.extend({ * @test t( "All Children of ID", "#foo/*", ["sndp", "en", "sap"] ); * @test t( "All Children of ID with no children", "#firstUL/*", [] ); * + * @test t( ":not() Existing attribute", "input:not([@name])", ["text2", "check2"]); + * @test t( ":not() Equals attribute", "select:not([@name=select1])", ["select2", "select3"]); + * @test t( ":not() Equals quoted attribute", "select:not([@name='select1'])", ["select2", "select3"]); + * * @name $.find * @type Array * @private @@ -1892,15 +1920,17 @@ jQuery.extend({ */ sibling: function(elem, pos, not) { var elems = []; - - var siblings = elem.parentNode.childNodes; - for ( var i = 0; i < siblings.length; i++ ) { - if ( not === true && siblings[i] == elem ) continue; - - if ( siblings[i].nodeType == 1 ) - elems.push( siblings[i] ); - if ( siblings[i] == elem ) - elems.n = elems.length - 1; + + if(elem) { + var siblings = elem.parentNode.childNodes; + for ( var i = 0; i < siblings.length; i++ ) { + if ( not === true && siblings[i] == elem ) continue; + + if ( siblings[i].nodeType == 1 ) + elems.push( siblings[i] ); + if ( siblings[i] == elem ) + elems.n = elems.length - 1; + } } return jQuery.extend( elems, { @@ -2956,7 +2986,7 @@ jQuery.macros = { * @param String expr An expression to filter the sibling Elements with * @cat DOM/Traversing */ - siblings: jQuery.sibling, + siblings: "jQuery.sibling(a, null, true)", /**