X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fjquery%2Fjquery.js;h=deb214bcd7f3f34ea4507a6a9c06920a9e4f0c84;hb=3527e8f6745786e65dc209f1518372f3270a9920;hp=041b262a2ba005f7be95c166bb447028d1627590;hpb=a4f25f9311c46c086eb6bb58b0afdcf66e4099d4;p=jquery.git
diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js
index 041b262..deb214b 100644
--- a/src/jquery/jquery.js
+++ b/src/jquery/jquery.js
@@ -16,22 +16,22 @@ window.undefined = window.undefined;
* Create a new jQuery Object
*
* @test ok( Array.prototype.push, "Array.push()" );
- * @test ok( Function.prototype.apply, "Function.apply()" );
- * @test ok( document.getElementById, "getElementById" );
- * @test ok( document.getElementsByTagName, "getElementsByTagName" );
- * @test ok( RegExp, "RegExp" );
- * @test ok( jQuery, "jQuery" );
- * @test ok( $, "$()" );
+ * ok( Function.prototype.apply, "Function.apply()" );
+ * ok( document.getElementById, "getElementById" );
+ * ok( document.getElementsByTagName, "getElementsByTagName" );
+ * ok( RegExp, "RegExp" );
+ * ok( jQuery, "jQuery" );
+ * ok( $, "$()" );
*
* @constructor
* @private
* @name jQuery
* @cat Core
*/
-function jQuery(a,c) {
+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,9 +65,9 @@ function jQuery(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);
-}
+};
// Map over the $ in case of overwrite
if ( typeof $ != "undefined" )
@@ -203,7 +203,7 @@ jQuery.fn = jQuery.prototype = {
* @before
* @result 2
*
- * @test cmpOK( $("div").length, "==", 2, "Get Number of Elements Found" );
+ * @test ok( $("div").length == 2, "Get Number of Elements Found" );
*
* @property
* @name length
@@ -218,7 +218,7 @@ jQuery.fn = jQuery.prototype = {
* @before
* @result 2
*
- * @test cmpOK( $("div").size(), "==", 2, "Get Number of Elements Found" );
+ * @test ok( $("div").size() == 2, "Get Number of Elements Found" );
*
* @name size
* @type Number
@@ -252,7 +252,7 @@ jQuery.fn = jQuery.prototype = {
* @before
* @result [ ]
*
- * @test cmpOK( $("div").get(0), "==", document.getElementById("main"), "Get A Single Element" );
+ * @test ok( $("div").get(0) == document.getElementById("main"), "Get A Single Element" );
*
* @name get
* @type Element
@@ -349,14 +349,14 @@ jQuery.fn = jQuery.prototype = {
* @result -1
*
* @test ok( $([window, document]).index(window) == 0, "Check for index of elements" );
- * @test ok( $([window, document]).index(document) == 1, "Check for index of elements" );
- * @test var inputElements = $('#radio1,#radio2,#check1,#check2');
- * @test ok( inputElements.index(document.getElementById('radio1')) == 0, "Check for index of elements" );
- * @test ok( inputElements.index(document.getElementById('radio2')) == 1, "Check for index of elements" );
- * @test ok( inputElements.index(document.getElementById('check1')) == 2, "Check for index of elements" );
- * @test ok( inputElements.index(document.getElementById('check2')) == 3, "Check for index of elements" );
- * @test ok( inputElements.index(window) == -1, "Check for not found index" );
- * @test ok( inputElements.index(document) == -1, "Check for not found index" );
+ * ok( $([window, document]).index(document) == 1, "Check for index of elements" );
+ * var inputElements = $('#radio1,#radio2,#check1,#check2');
+ * ok( inputElements.index(document.getElementById('radio1')) == 0, "Check for index of elements" );
+ * ok( inputElements.index(document.getElementById('radio2')) == 1, "Check for index of elements" );
+ * ok( inputElements.index(document.getElementById('check1')) == 2, "Check for index of elements" );
+ * ok( inputElements.index(document.getElementById('check2')) == 3, "Check for index of elements" );
+ * ok( inputElements.index(window) == -1, "Check for not found index" );
+ * ok( inputElements.index(document) == -1, "Check for not found index" );
*
* @name index
* @type Number
@@ -381,16 +381,18 @@ jQuery.fn = jQuery.prototype = {
* @result test.jpg
*
* @test ok( $('#text1').attr('value') == "Test", 'Check for value attribute' );
- * @test ok( $('#text1').attr('type') == "text", 'Check for type attribute' );
- * @test ok( $('#radio1').attr('type') == "radio", 'Check for type attribute' );
- * @test ok( $('#check1').attr('type') == "checkbox", 'Check for type attribute' );
- * @test ok( $('#simon1').attr('rel') == "bookmark", 'Check for rel attribute' );
- * @test ok( $('#google').attr('title') == "Google!", 'Check for title attribute' );
- * @test ok( $('#mark').attr('hreflang') == "en", 'Check for hreflang attribute' );
- * @test ok( $('#en').attr('lang') == "en", 'Check for lang attribute' );
- * @test ok( $('#simon').attr('class') == "blog link", 'Check for class attribute' );
- * @test ok( $('#name').attr('name') == "name", 'Check for name attribute' );
- *
+ * ok( $('#text1').attr('type') == "text", 'Check for type attribute' );
+ * ok( $('#radio1').attr('type') == "radio", 'Check for type attribute' );
+ * ok( $('#check1').attr('type') == "checkbox", 'Check for type attribute' );
+ * ok( $('#simon1').attr('rel') == "bookmark", 'Check for rel attribute' );
+ * ok( $('#google').attr('title') == "Google!", 'Check for title attribute' );
+ * ok( $('#mark').attr('hreflang') == "en", 'Check for hreflang attribute' );
+ * ok( $('#en').attr('lang') == "en", 'Check for lang attribute' );
+ * 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').indexOf("formaction") >= 0, 'Check for action attribute' );
+ *
* @name attr
* @type Object
* @param String name The name of the property to access.
@@ -433,9 +435,9 @@ jQuery.fn = jQuery.prototype = {
* }
* ok( pass, "Set Attribute" );
*
- * @test $("#name").attr('name', 'something');
+ * $("#name").attr('name', 'something');
* ok( $("#name").name() == 'something', 'Set name attribute' );
- * @test $("#check2").attr('checked', true);
+ * $("#check2").attr('checked', true);
* ok( document.getElementById('check2').checked == true, 'Set checked attribute' );
* $("#check2").attr('checked', false);
* ok( document.getElementById('check2').checked == false, 'Set checked attribute' );
@@ -491,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
@@ -509,9 +511,9 @@ jQuery.fn = jQuery.prototype = {
* @result
Test Paragraph.
*
* @test ok( $('#foo').is(':visible'), 'Modifying CSS display: Assert element is visible');
- * @test $('#foo').css({display: 'none'});
+ * $('#foo').css({display: 'none'});
* ok( !$('#foo').is(':visible'), 'Modified CSS display: Assert element is hidden');
- * @test $('#foo').css({display: 'block'});
+ * $('#foo').css({display: 'block'});
* ok( $('#foo').is(':visible'), 'Modified CSS display: Assert element is visible');
*
* @name css
@@ -530,9 +532,9 @@ jQuery.fn = jQuery.prototype = {
*
*
* @test ok( $('#foo').is(':visible'), 'Modifying CSS display: Assert element is visible');
- * @test $('#foo').css('display', 'none');
+ * $('#foo').css('display', 'none');
* ok( !$('#foo').is(':visible'), 'Modified CSS display: Assert element is hidden');
- * @test $('#foo').css('display', 'block');
+ * $('#foo').css('display', 'block');
* ok( $('#foo').is(':visible'), 'Modified CSS display: Assert element is visible');
*
* @name css
@@ -585,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
@@ -615,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
@@ -968,6 +976,12 @@ jQuery.fn = jQuery.prototype = {
* @result $("p").filter(".selected") == [