diff --git a/build/release-notes.js b/build/release-notes.js
index 37b9d389..0166732e 100644
--- a/build/release-notes.js
+++ b/build/release-notes.js
@@ -9,9 +9,9 @@ var fs = require("fs"),
extract = /(.*?)<[^"]+"component">\s*(\S+)/g;
var opts = {
- version: "1.6",
- short_version: "1.6",
- final_version: "1.6",
+ version: "1.6.1 RC 1",
+ short_version: "1.6rc1",
+ final_version: "1.6.1",
categories: []
};
diff --git a/src/attributes.js b/src/attributes.js
index c207a001..9b8c4bf0 100644
--- a/src/attributes.js
+++ b/src/attributes.js
@@ -7,7 +7,7 @@ var rclass = /[\n\t\r]/g,
rfocusable = /^(?:button|input|object|select|textarea)$/i,
rclickable = /^a(?:rea)?$/i,
rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
- rinvalidChar = /\:/,
+ rinvalidChar = /\:|^on/,
formHook, boolHook;
jQuery.fn.extend({
@@ -20,11 +20,11 @@ jQuery.fn.extend({
jQuery.removeAttr( this, name );
});
},
-
+
prop: function( name, value ) {
return jQuery.access( this, name, value, true, jQuery.prop );
},
-
+
removeProp: function( name ) {
name = jQuery.propFix[ name ] || name;
return this.each(function() {
@@ -156,7 +156,7 @@ jQuery.fn.extend({
val: function( value ) {
var hooks, ret,
elem = this[0];
-
+
if ( !arguments.length ) {
if ( elem ) {
hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ];
@@ -165,7 +165,13 @@ jQuery.fn.extend({
return ret;
}
- return (elem.value || "").replace(rreturn, "");
+ ret = elem.value;
+
+ return typeof ret === "string" ?
+ // handle most common string cases
+ ret.replace(rreturn, "") :
+ // handle cases where value is null/undef or number
+ ret == null ? "" : ret;
}
return undefined;
@@ -284,15 +290,15 @@ jQuery.extend({
height: true,
offset: true
},
-
+
attrFix: {
// Always normalize to ensure hook usage
tabindex: "tabIndex"
},
-
+
attr: function( elem, name, value, pass ) {
var nType = elem.nodeType;
-
+
// don't get/set attributes on text, comment and attribute nodes
if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
return undefined;
@@ -301,10 +307,15 @@ jQuery.extend({
if ( pass && name in jQuery.attrFn ) {
return jQuery( elem )[ name ]( value );
}
-
+
+ // Fallback to prop when attributes are not supported
+ if ( !("getAttribute" in elem) ) {
+ return jQuery.prop( elem, name, value );
+ }
+
var ret, hooks,
notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
-
+
// Normalize the name if needed
name = notxml && jQuery.attrFix[ name ] || name;
@@ -312,13 +323,14 @@ jQuery.extend({
if ( !hooks ) {
// Use boolHook for boolean attributes
- if ( rboolean.test( name ) &&
- (typeof value === "boolean" || value === undefined || value.toLowerCase() === name.toLowerCase()) ) {
+ if ( rboolean.test( name ) ) {
hooks = boolHook;
// Use formHook for forms and if the name contains certain characters
- } else if ( formHook && (jQuery.nodeName( elem, "form" ) || rinvalidChar.test( name )) ) {
+ } else if ( formHook && name !== "className" &&
+ (jQuery.nodeName( elem, "form" ) || rinvalidChar.test( name )) ) {
+
hooks = formHook;
}
}
@@ -337,8 +349,8 @@ jQuery.extend({
return value;
}
- } else if ( hooks && "get" in hooks && notxml ) {
- return hooks.get( elem, name );
+ } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) {
+ return ret;
} else {
@@ -355,7 +367,7 @@ jQuery.extend({
var propName;
if ( elem.nodeType === 1 ) {
name = jQuery.attrFix[ name ] || name;
-
+
if ( jQuery.support.getSetAttribute ) {
// Use removeAttribute in browsers that support it
elem.removeAttribute( name );
@@ -381,7 +393,7 @@ jQuery.extend({
// Setting the type on a radio button after the value resets the value in IE6-9
// Reset value to it's default in case type is set after value
// This is for element creation
- var val = elem.getAttribute("value");
+ var val = elem.value;
elem.setAttribute( "type", value );
if ( val ) {
elem.value = val;
@@ -404,7 +416,7 @@ jQuery.extend({
}
}
},
-
+
propFix: {
tabindex: "tabIndex",
readonly: "readOnly",
@@ -419,41 +431,41 @@ jQuery.extend({
frameborder: "frameBorder",
contenteditable: "contentEditable"
},
-
+
prop: function( elem, name, value ) {
var nType = elem.nodeType;
-
+
// don't get/set properties on text, comment and attribute nodes
if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
return undefined;
}
-
+
var ret, hooks,
notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
-
+
// Try to normalize/fix the name
name = notxml && jQuery.propFix[ name ] || name;
-
+
hooks = jQuery.propHooks[ name ];
-
+
if ( value !== undefined ) {
if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
return ret;
-
+
} else {
return (elem[ name ] = value);
}
-
+
} else {
if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== undefined ) {
return ret;
-
+
} else {
return elem[ name ];
}
}
},
-
+
propHooks: {}
});
@@ -461,7 +473,7 @@ jQuery.extend({
boolHook = {
get: function( elem, name ) {
// Align boolean attributes with corresponding properties
- return elem[ jQuery.propFix[ name ] || name ] ?
+ return jQuery.prop( elem, name ) ?
name.toLowerCase() :
undefined;
},
@@ -476,7 +488,7 @@ boolHook = {
propName = jQuery.propFix[ name ] || name;
if ( propName in elem ) {
// Only set the IDL specifically if it already exists on the element
- elem[ propName ] = value;
+ elem[ propName ] = true;
}
elem.setAttribute( name, name.toLowerCase() );
@@ -485,14 +497,34 @@ boolHook = {
}
};
+// Use the value property for back compat
+// Use the formHook for button elements in IE6/7 (#1954)
+jQuery.attrHooks.value = {
+ get: function( elem, name ) {
+ if ( formHook && jQuery.nodeName( elem, "button" ) ) {
+ return formHook.get( elem, name );
+ }
+ return name in elem ?
+ elem.value :
+ null;
+ },
+ set: function( elem, value, name ) {
+ if ( formHook && jQuery.nodeName( elem, "button" ) ) {
+ return formHook.set( elem, value, name );
+ }
+ // Does not return so that setAttribute is also used
+ elem.value = value;
+ }
+};
+
// IE6/7 do not support getting/setting some attributes with get/setAttribute
if ( !jQuery.support.getSetAttribute ) {
// propFix is more comprehensive and contains all fixes
jQuery.attrFix = jQuery.propFix;
-
+
// Use this for any attribute on a form in IE6/7
- formHook = jQuery.attrHooks.name = jQuery.attrHooks.value = jQuery.valHooks.button = {
+ formHook = jQuery.attrHooks.name = jQuery.attrHooks.title = jQuery.valHooks.button = {
get: function( elem, name ) {
var ret;
ret = elem.getAttributeNode( name );
diff --git a/src/css.js b/src/css.js
index 318cd597..661d800d 100644
--- a/src/css.js
+++ b/src/css.js
@@ -96,6 +96,8 @@ jQuery.extend({
// convert relative number strings (+= or -=) to relative numbers. #7345
if ( type === "string" && rrelNum.test( value ) ) {
value = +value.replace( rrelNumFilter, "" ) + parseFloat( jQuery.css( elem, name ) );
+ // Fixes bug #9237
+ type = "number";
}
// If a number was passed in, add 'px' to the (except for certain CSS properties)
diff --git a/src/data.js b/src/data.js
index 9e5d1ab0..c019a64e 100644
--- a/src/data.js
+++ b/src/data.js
@@ -98,7 +98,7 @@ jQuery.extend({
}
if ( data !== undefined ) {
- thisCache[ name ] = data;
+ thisCache[ jQuery.camelCase( name ) ] = data;
}
// TODO: This is a hack for 1.5 ONLY. It will be removed in 1.6. Users should
@@ -108,7 +108,7 @@ jQuery.extend({
return thisCache[ internalKey ] && thisCache[ internalKey ].events;
}
- return getByName ? thisCache[ name ] : thisCache;
+ return getByName ? thisCache[ jQuery.camelCase( name ) ] : thisCache;
},
removeData: function( elem, name, pvt /* Internal Use Only */ ) {
diff --git a/src/effects.js b/src/effects.js
index 88661e0e..22496277 100644
--- a/src/effects.js
+++ b/src/effects.js
@@ -258,7 +258,6 @@ jQuery.fn.extend({
if ( !gotoEnd ) {
jQuery._unmark( true, this );
}
- // go in reverse order so anything added to the queue during the loop is ignored
while ( i-- ) {
if ( timers[i].elem === this ) {
if (gotoEnd) {
@@ -331,15 +330,15 @@ jQuery.extend({
// Queueing
opt.old = opt.complete;
opt.complete = function( noUnmark ) {
+ if ( jQuery.isFunction( opt.old ) ) {
+ opt.old.call( this );
+ }
+
if ( opt.queue !== false ) {
jQuery.dequeue( this );
} else if ( noUnmark !== false ) {
jQuery._unmark( this );
}
-
- if ( jQuery.isFunction( opt.old ) ) {
- opt.old.call( this );
- }
};
return opt;
@@ -522,11 +521,9 @@ jQuery.fx.prototype = {
jQuery.extend( jQuery.fx, {
tick: function() {
- var timers = jQuery.timers,
- i = timers.length;
- while ( i-- ) {
+ for ( var timers = jQuery.timers, i = 0 ; i < timers.length ; ++i ) {
if ( !timers[i]() ) {
- timers.splice(i, 1);
+ timers.splice(i--, 1);
}
}
@@ -577,7 +574,8 @@ function defaultDisplay( nodeName ) {
if ( !elemdisplay[ nodeName ] ) {
- var elem = jQuery( "<" + nodeName + ">" ).appendTo( "body" ),
+ var body = document.body,
+ elem = jQuery( "<" + nodeName + ">" ).appendTo( body ),
display = elem.css( "display" );
elem.remove();
@@ -591,14 +589,15 @@ function defaultDisplay( nodeName ) {
iframe.frameBorder = iframe.width = iframe.height = 0;
}
- document.body.appendChild( iframe );
+ body.appendChild( iframe );
// Create a cacheable copy of the iframe document on first call.
- // IE and Opera will allow us to reuse the iframeDoc without re-writing the fake html
- // document to it, Webkit & Firefox won't allow reusing the iframe document
+ // IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML
+ // document to it; WebKit & Firefox won't allow reusing the iframe document.
if ( !iframeDoc || !iframe.createElement ) {
iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
- iframeDoc.write( "" );
+ iframeDoc.write( ( document.compatMode === "CSS1Compat" ? "" : "" ) + "" );
+ iframeDoc.close();
}
elem = iframeDoc.createElement( nodeName );
@@ -607,7 +606,7 @@ function defaultDisplay( nodeName ) {
display = jQuery.css( elem, "display" );
- document.body.removeChild( iframe );
+ body.removeChild( iframe );
}
// Store the correct default display
diff --git a/src/event.js b/src/event.js
index 05e79d35..d2d57d67 100644
--- a/src/event.js
+++ b/src/event.js
@@ -345,7 +345,7 @@ jQuery.event = {
event.target = elem;
// Clone any incoming data and prepend the event, creating the handler arg list
- data = data ? jQuery.makeArray( data ) : [];
+ data = data != null ? jQuery.makeArray( data ) : [];
data.unshift( event );
var cur = elem,
@@ -654,6 +654,9 @@ var withinElement = function( event ) {
// Check if mouse(over|out) are still within the same parent element
var parent = event.relatedTarget;
+ // set the correct event type
+ event.type = event.data;
+
// Firefox sometimes assigns relatedTarget a XUL element
// which we cannot access the parentNode property of
try {
@@ -663,15 +666,13 @@ var withinElement = function( event ) {
if ( parent && parent !== document && !parent.parentNode ) {
return;
}
+
// Traverse up the tree
while ( parent && parent !== this ) {
parent = parent.parentNode;
}
if ( parent !== this ) {
- // set the correct event type
- event.type = event.data;
-
// handle event if we actually just moused on to a non sub-element
jQuery.event.handle.apply( this, arguments );
}
diff --git a/src/manipulation.js b/src/manipulation.js
index e9b1ee53..a148658f 100644
--- a/src/manipulation.js
+++ b/src/manipulation.js
@@ -10,6 +10,7 @@ var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
// checked="checked" or checked
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
rscriptType = /\/(java|ecma)script/i,
+ rcleanScript = /^\s*", "" ],
legend: [ 1, "
" ],
@@ -437,8 +438,21 @@ function cloneFixAttributes( src, dest ) {
}
jQuery.buildFragment = function( args, nodes, scripts ) {
- var fragment, cacheable, cacheresults,
- doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document);
+ var fragment, cacheable, cacheresults, doc;
+
+ // nodes may contain either an explicit document object,
+ // a jQuery collection or context object.
+ // If nodes[0] contains a valid object to assign to doc
+ if ( nodes && nodes[0] ) {
+ doc = nodes[0].ownerDocument || nodes[0];
+ }
+
+ // Ensure that an attr object doesn't incorrectly stand in as a document object
+ // Chrome and Firefox seem to allow this to occur and will throw exception
+ // Fixes #8950
+ if ( !doc.createDocumentFragment ) {
+ doc = document;
+ }
// Only cache "small" (1/2 KB) HTML strings that are associated with the main document
// Cloning options loses the selected state, so don't cache them
@@ -500,7 +514,7 @@ jQuery.each({
function getAll( elem ) {
if ( "getElementsByTagName" in elem ) {
return elem.getElementsByTagName( "*" );
-
+
} else if ( "querySelectorAll" in elem ) {
return elem.querySelectorAll( "*" );
@@ -738,7 +752,7 @@ function evalScript( i, elem ) {
dataType: "script"
});
} else {
- jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );
+ jQuery.globalEval( ( elem.text || elem.textContent || elem.innerHTML || "" ).replace( rcleanScript, "/*$0*/" ) );
}
if ( elem.parentNode ) {
@@ -746,4 +760,4 @@ function evalScript( i, elem ) {
}
}
-})( jQuery );
+})( jQuery );
\ No newline at end of file
diff --git a/src/sizzle b/src/sizzle
index 4bcc0970..3ba396e4 160000
--- a/src/sizzle
+++ b/src/sizzle
@@ -1 +1 @@
-Subproject commit 4bcc09702d6dadfd0b90c7de3c8b206e97ff97f4
+Subproject commit 3ba396e439a07c2a2facafbe07cdaa1b80a24c00
diff --git a/src/support.js b/src/support.js
index 9a6a318d..4420b7fc 100644
--- a/src/support.js
+++ b/src/support.js
@@ -13,7 +13,9 @@ jQuery.support = (function() {
support,
fragment,
body,
- bodyStyle,
+ testElementParent,
+ testElement,
+ testElementStyle,
tds,
events,
eventName,
@@ -136,9 +138,11 @@ jQuery.support = (function() {
// Figure out if the W3C box model works as expected
div.style.width = div.style.paddingLeft = "1px";
- // We use our own, invisible, body
- body = document.createElement( "body" );
- bodyStyle = {
+ body = document.getElementsByTagName( "body" )[ 0 ];
+ // We use our own, invisible, body unless the body is already present
+ // in which case we use a div (#9239)
+ testElement = document.createElement( body ? "div" : "body" );
+ testElementStyle = {
visibility: "hidden",
width: 0,
height: 0,
@@ -147,11 +151,19 @@ jQuery.support = (function() {
// Set background to avoid IE crashes when removing (#9028)
background: "none"
};
- for ( i in bodyStyle ) {
- body.style[ i ] = bodyStyle[ i ];
+ if ( body ) {
+ jQuery.extend( testElementStyle, {
+ position: "absolute",
+ left: -1000,
+ top: -1000
+ });
}
- body.appendChild( div );
- documentElement.insertBefore( body, documentElement.firstChild );
+ for ( i in testElementStyle ) {
+ testElement.style[ i ] = testElementStyle[ i ];
+ }
+ testElement.appendChild( div );
+ testElementParent = body || documentElement;
+ testElementParent.insertBefore( testElement, testElementParent.firstChild );
// Check if a disconnected checkbox will retain its checked
// value of true after appended to the DOM (IE6/7)
@@ -206,12 +218,12 @@ jQuery.support = (function() {
marginDiv.style.marginRight = "0";
div.appendChild( marginDiv );
support.reliableMarginRight =
- ( parseInt( document.defaultView.getComputedStyle( marginDiv, null ).marginRight, 10 ) || 0 ) === 0;
+ ( parseInt( ( document.defaultView.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0;
}
// Remove the body element we added
- body.innerHTML = "";
- documentElement.removeChild( body );
+ testElement.innerHTML = "";
+ testElementParent.removeChild( testElement );
// Technique from Juriy Zaytsev
// http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
diff --git a/test/boxModelIE.html b/test/boxModelIE.html
deleted file mode 100644
index f8e6a431..00000000
--- a/test/boxModelIE.html
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
- jQuery Test boxModel detection in IE 6 & 7 compatMode="CSS1Compat"
- document.compatMode = ?
- jQuery.support.boxModel = ?
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/test/data/support/bodyBackground.html b/test/data/support/bodyBackground.html
new file mode 100644
index 00000000..9963c391
--- /dev/null
+++ b/test/data/support/bodyBackground.html
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/data/support/boxModelIE.html b/test/data/support/boxModelIE.html
new file mode 100644
index 00000000..1b11d2a5
--- /dev/null
+++ b/test/data/support/boxModelIE.html
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/data/support/hiddenIFrameFF.html b/test/data/support/hiddenIFrameFF.html
new file mode 100644
index 00000000..000ac851
--- /dev/null
+++ b/test/data/support/hiddenIFrameFF.html
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/delegatetest.html b/test/delegatetest.html
index c4f33aae..7d891b95 100644
--- a/test/delegatetest.html
+++ b/test/delegatetest.html
@@ -182,11 +182,21 @@
BUTTON |
DOCUMENT |
-
+
+
+ Mouseleave Tests
+
+
+
Count mouse leave event
+
+
mouse over here should not trigger the counter.
+
+
0
+
-
+ var n = 0;
+ $("div.out").live("mouseleave", function() {
+ $("p:last", this).text(++n);
+ });
+
diff --git a/test/index.html b/test/index.html
index bf5b161a..c4d0acc6 100644
--- a/test/index.html
+++ b/test/index.html
@@ -35,6 +35,7 @@
+
diff --git a/test/qunit b/test/qunit
index 98876633..d97b37ec 160000
--- a/test/qunit
+++ b/test/qunit
@@ -1 +1 @@
-Subproject commit 9887663380693009874e8c76f0bf77a921931766
+Subproject commit d97b37ec322136406790e75d03333559f38bbecb
diff --git a/test/unit/attributes.js b/test/unit/attributes.js
index ce7775d1..cd8d7777 100644
--- a/test/unit/attributes.js
+++ b/test/unit/attributes.js
@@ -6,7 +6,7 @@ var functionReturningObj = function(value) { return (function() { return value;
test("jQuery.attrFix/jQuery.propFix integrity test", function() {
expect(2);
-
+
// This must be maintained and equal jQuery.attrFix when appropriate
// Ensure that accidental or erroneous property
// overwrites don't occur
@@ -40,7 +40,7 @@ test("jQuery.attrFix/jQuery.propFix integrity test", function() {
});
test("attr(String)", function() {
- expect(37);
+ expect(45);
equals( jQuery("#text1").attr("type"), "text", "Check for type attribute" );
equals( jQuery("#radio1").attr("type"), "radio", "Check for type attribute" );
@@ -54,9 +54,10 @@ test("attr(String)", function() {
equals( jQuery("#text1").attr("name"), "action", "Check for name attribute" );
ok( jQuery("#form").attr("action").indexOf("formaction") >= 0, "Check for action attribute" );
equals( jQuery("#text1").attr("value", "t").attr("value"), "t", "Check setting the value attribute" );
+ equals( jQuery("").attr("value"), "t", "Check setting custom attr named 'value' on a div" );
equals( jQuery("#form").attr("blah", "blah").attr("blah"), "blah", "Set non-existant attribute on a form" );
equals( jQuery("#foo").attr("height"), undefined, "Non existent height attribute should return undefined" );
-
+
// [7472] & [3113] (form contains an input with name="action" or name="id")
var extras = jQuery("").appendTo("#testForm");
equals( jQuery("#form").attr("action","newformaction").attr("action"), "newformaction", "Check that action attribute was changed" );
@@ -66,7 +67,7 @@ test("attr(String)", function() {
// Bug #3685 (form contains input with name="name")
equals( jQuery("#testForm").attr("name"), undefined, "Retrieving name does not retrieve input with name=name" );
extras.remove();
-
+
equals( jQuery("#text1").attr("maxlength"), "30", "Check for maxlength attribute" );
equals( jQuery("#text1").attr("maxLength"), "30", "Check for maxLength attribute" );
equals( jQuery("#area1").attr("maxLength"), "30", "Check for maxLength attribute" );
@@ -92,6 +93,12 @@ test("attr(String)", function() {
body.removeAttribute("foo"); // Cleanup
+ var select = document.createElement("select"), optgroup = document.createElement("optgroup"), option = document.createElement("option");
+ optgroup.appendChild( option );
+ select.appendChild( optgroup );
+
+ equal( jQuery( option ).attr("selected"), "selected", "Make sure that a single option is selected, even when in an optgroup." );
+
var $img = jQuery("
").appendTo("body");
equals( $img.attr("width"), "215", "Retrieve width attribute an an element with display:none." );
equals( $img.attr("height"), "53", "Retrieve height attribute an an element with display:none." );
@@ -109,17 +116,27 @@ test("attr(String)", function() {
equals( jQuery("#table").attr("test:attrib"), undefined, "Retrieving a non-existent attribute on a table with a colon does not throw an error." );
equals( jQuery("#table").attr("test:attrib", "foobar").attr("test:attrib"), "foobar", "Setting an attribute on a table with a colon does not throw an error." );
+ var $form = jQuery("").appendTo("#qunit-fixture");
+ equal( $form.attr("class"), "something", "Retrieve the class attribute on a form." );
+
+ var $a = jQuery("Click").appendTo("#qunit-fixture");
+ equal( $a.attr("onclick"), "something()", "Retrieve ^on attribute without anonymous function wrapper." );
+
ok( jQuery("").attr("doesntexist") === undefined, "Make sure undefined is returned when no attribute is found." );
+ ok( jQuery("").attr("title") === undefined, "Make sure undefined is returned when no attribute is found." );
+ equal( jQuery("").attr("title", "something").attr("title"), "something", "Set the title attribute." );
ok( jQuery().attr("doesntexist") === undefined, "Make sure undefined is returned when no element is there." );
+ equal( jQuery("").attr("value"), undefined, "An unset value on a div returns undefined." );
+ equal( jQuery("").attr("value"), "", "An unset value on an input returns current value." );
});
if ( !isLocal ) {
test("attr(String) in XML Files", function() {
expect(2);
stop();
- jQuery.get("data/dashboard.xml", function(xml) {
- equals( jQuery("locations", xml).attr("class"), "foo", "Check class attribute in XML document" );
- equals( jQuery("location", xml).attr("for"), "bar", "Check for attribute in XML document" );
+ jQuery.get("data/dashboard.xml", function( xml ) {
+ equals( jQuery( "locations", xml ).attr("class"), "foo", "Check class attribute in XML document" );
+ equals( jQuery( "location", xml ).attr("for"), "bar", "Check for attribute in XML document" );
start();
});
});
@@ -144,7 +161,7 @@ test("attr(Hash)", function() {
});
test("attr(String, Object)", function() {
- expect(59);
+ expect(69);
var div = jQuery("div").attr("foo", "bar"),
fail = false;
@@ -193,6 +210,11 @@ test("attr(String, Object)", function() {
equals( jQuery("#check2").prop("checked"), false, "Set checked attribute" );
equals( jQuery("#check2").attr("checked"), undefined, "Set checked attribute" );
+ jQuery("#check2").attr("checked", "checked");
+ equal( document.getElementById("check2").checked, true, "Set checked attribute with 'checked'" );
+ equal( jQuery("#check2").prop("checked"), true, "Set checked attribute" );
+ equal( jQuery("#check2").attr("checked"), "checked", "Set checked attribute" );
+
jQuery("#text1").prop("readOnly", true);
equals( document.getElementById("text1").readOnly, true, "Set readonly attribute" );
equals( jQuery("#text1").prop("readOnly"), true, "Set readonly attribute" );
@@ -206,9 +228,6 @@ test("attr(String, Object)", function() {
equals( document.getElementById("name").maxLength, 5, "Set maxlength attribute" );
jQuery("#name").attr("maxLength", "10");
equals( document.getElementById("name").maxLength, 10, "Set maxlength attribute" );
- var $p = jQuery("#firstp").attr("nonexisting", "foo");
- equals( $p.attr("nonexisting"), "foo", "attr(name, value) works correctly for non existing attributes (bug #7500).");
- $p.removeAttr("nonexisting");
var $text = jQuery("#text1").attr("autofocus", true);
if ( "autofocus" in $text[0] ) {
@@ -227,12 +246,19 @@ test("attr(String, Object)", function() {
var attributeNode = document.createAttribute("irrelevant"),
commentNode = document.createComment("some comment"),
- textNode = document.createTextNode("some text");
-
- jQuery.each( [commentNode, textNode, attributeNode], function( i, ele ) {
- var $ele = jQuery( ele );
- $ele.attr( "nonexisting", "foo" );
- strictEqual( $ele.attr("nonexisting"), undefined, "attr(name, value) works correctly on comment and text nodes (bug #7500)." );
+ textNode = document.createTextNode("some text"),
+ obj = {};
+
+ jQuery.each( [commentNode, textNode, attributeNode], function( i, elem ) {
+ var $elem = jQuery( elem );
+ $elem.attr( "nonexisting", "foo" );
+ strictEqual( $elem.attr("nonexisting"), undefined, "attr(name, value) works correctly on comment and text nodes (bug #7500)." );
+ });
+
+ jQuery.each( [window, document, obj, "#firstp"], function( i, elem ) {
+ var $elem = jQuery( elem );
+ strictEqual( $elem.attr("nonexisting"), undefined, "attr works correctly for non existing attributes (bug #7500)." );
+ equal( $elem.attr("something", "foo" ).attr("something"), "foo", "attr falls back to prop on unsupported arguments" );
});
var table = jQuery("#table").append("cell |
cell | cell |
cell | cell |
"),
@@ -244,7 +270,7 @@ test("attr(String, Object)", function() {
table.attr("cellspacing", "2");
equals( table[0].cellSpacing, "2", "Check cellspacing is correctly set" );
- equals( jQuery("#area1").attr("value"), undefined, "Value attribute retrieved correctly on textarea." );
+ equals( jQuery("#area1").attr("value"), "foobar", "Value attribute retrieves the property for backwards compatibility." );
// for #1070
jQuery("#name").attr("someAttr", "0");
@@ -262,7 +288,7 @@ test("attr(String, Object)", function() {
j.removeAttr("name");
QUnit.reset();
-
+
// Type
var type = jQuery("#check2").attr("type");
var thrown = false;
@@ -350,10 +376,10 @@ if ( !isLocal ) {
test("attr(String, Object) - Loaded via XML document", function() {
expect(2);
stop();
- jQuery.get("data/dashboard.xml", function(xml) {
+ jQuery.get("data/dashboard.xml", function( xml ) {
var titles = [];
- jQuery("tab", xml).each(function() {
- titles.push(jQuery(this).attr("title"));
+ jQuery( "tab", xml ).each(function() {
+ titles.push( jQuery(this).attr("title") );
});
equals( titles[0], "Location", "attr() in XML context: Check first title" );
equals( titles[1], "Users", "attr() in XML context: Check second title" );
@@ -424,7 +450,7 @@ test("removeAttr(String)", function() {
equals( jQuery("#foo").attr("style", "position:absolute;").removeAttr("style").attr("style"), undefined, "Check removing style attribute" );
equals( jQuery("#form").attr("style", "position:absolute;").removeAttr("style").attr("style"), undefined, "Check removing style attribute on a form" );
equals( jQuery("#fx-test-group").attr("height", "3px").removeAttr("height").css("height"), "1px", "Removing height attribute has no effect on height set with style attribute" );
-
+
jQuery("#check1").removeAttr("checked").prop("checked", true).removeAttr("checked");
equals( document.getElementById("check1").checked, false, "removeAttr sets boolean properties to false" );
jQuery("#text1").prop("readOnly", true).removeAttr("readonly");
@@ -581,10 +607,34 @@ test("val()", function() {
var $button = jQuery("").insertAfter("#button");
equals( $button.val(), "foobar", "Value retrieval on a button does not return innerHTML" );
equals( $button.val("baz").html(), "text", "Setting the value does not change innerHTML" );
-
+
equals( jQuery("").val("test").attr("value"), "test", "Setting value sets the value attribute" );
});
+if ( "value" in document.createElement("meter") &&
+ "value" in document.createElement("progress") ) {
+
+ test("val() respects numbers without exception (Bug #9319)", function() {
+
+ expect(4);
+
+ var $meter = jQuery(""),
+ $progress = jQuery("");
+
+ try {
+ equal( typeof $meter.val(), "number", "meter, returns a number and does not throw exception" );
+ equal( $meter.val(), $meter[0].value, "meter, api matches host and does not throw exception" );
+
+ equal( typeof $progress.val(), "number", "progress, returns a number and does not throw exception" );
+ equal( $progress.val(), $progress[0].value, "progress, api matches host and does not throw exception" );
+
+ } catch(e) {}
+
+ $meter.remove();
+ $progress.remove();
+ });
+}
+
var testVal = function(valueObj) {
expect(8);
@@ -708,7 +758,7 @@ test("val(select) after form.reset() (Bug #2551)", function() {
same( jQuery("#select3").val(), ["1", "2"], "Call val() on a multiple=\"multiple\" select" );
jQuery("#kk").remove();
-});
+});
var testAddClass = function(valueObj) {
expect(5);
@@ -752,7 +802,7 @@ test("addClass(Function) with incoming value", function() {
var div = jQuery("div"), old = div.map(function(){
return jQuery(this).attr("class") || "";
});
-
+
div.addClass(function(i, val) {
if ( this.id !== "_firebugConsole") {
equals( val, old[i], "Make sure the incoming value is correct." );
diff --git a/test/unit/css.js b/test/unit/css.js
index 380709d1..e631f496 100644
--- a/test/unit/css.js
+++ b/test/unit/css.js
@@ -109,11 +109,13 @@ test("css(String|Hash)", function() {
});
test("css() explicit and relative values", function() {
- expect(9);
+ expect(27);
var $elem = jQuery("#nothiddendiv");
- $elem.css({ width: 1, height: 1 });
+ $elem.css({ width: 1, height: 1, paddingLeft: "1px", opacity: 1 });
equals( $elem.width(), 1, "Initial css set or width/height works (hash)" );
+ equals( $elem.css("paddingLeft"), "1px", "Initial css set of paddingLeft works (hash)" );
+ equals( $elem.css("opacity"), "1", "Initial css set of opacity works (hash)" );
$elem.css({ width: "+=9" });
equals( $elem.width(), 10, "'+=9' on width (hash)" );
@@ -138,6 +140,54 @@ test("css() explicit and relative values", function() {
$elem.css( "width", "-=9px" );
equals( $elem.width(), 1, "'-=9px' on width (params)" );
+
+ $elem.css({ paddingLeft: "+=4" });
+ equals( $elem.css("paddingLeft"), "5px", "'+=4' on paddingLeft (hash)" );
+
+ $elem.css({ paddingLeft: "-=4" });
+ equals( $elem.css("paddingLeft"), "1px", "'-=4' on paddingLeft (hash)" );
+
+ $elem.css({ paddingLeft: "+=4px" });
+ equals( $elem.css("paddingLeft"), "5px", "'+=4px' on paddingLeft (hash)" );
+
+ $elem.css({ paddingLeft: "-=4px" });
+ equals( $elem.css("paddingLeft"), "1px", "'-=4px' on paddingLeft (hash)" );
+
+ $elem.css({ "padding-left": "+=4" });
+ equals( $elem.css("paddingLeft"), "5px", "'+=4' on padding-left (hash)" );
+
+ $elem.css({ "padding-left": "-=4" });
+ equals( $elem.css("paddingLeft"), "1px", "'-=4' on padding-left (hash)" );
+
+ $elem.css({ "padding-left": "+=4px" });
+ equals( $elem.css("paddingLeft"), "5px", "'+=4px' on padding-left (hash)" );
+
+ $elem.css({ "padding-left": "-=4px" });
+ equals( $elem.css("paddingLeft"), "1px", "'-=4px' on padding-left (hash)" );
+
+ $elem.css( "paddingLeft", "+=4" );
+ equals( $elem.css("paddingLeft"), "5px", "'+=4' on paddingLeft (params)" );
+
+ $elem.css( "paddingLeft", "-=4" );
+ equals( $elem.css("paddingLeft"), "1px", "'-=4' on paddingLeft (params)" );
+
+ $elem.css( "padding-left", "+=4px" );
+ equals( $elem.css("paddingLeft"), "5px", "'+=4px' on padding-left (params)" );
+
+ $elem.css( "padding-left", "-=4px" );
+ equals( $elem.css("paddingLeft"), "1px", "'-=4px' on padding-left (params)" );
+
+ $elem.css({ opacity: "-=0.5" });
+ equals( $elem.css("opacity"), "0.5", "'-=0.5' on opacity (hash)" );
+
+ $elem.css({ opacity: "+=0.5" });
+ equals( $elem.css("opacity"), "1", "'+=0.5' on opacity (hash)" );
+
+ $elem.css( "opacity", "-=0.5" );
+ equals( $elem.css("opacity"), "0.5", "'-=0.5' on opacity (params)" );
+
+ $elem.css( "opacity", "+=0.5" );
+ equals( $elem.css("opacity"), "1", "'+=0.5' on opacity (params)" );
});
test("css(String, Object)", function() {
diff --git a/test/unit/data.js b/test/unit/data.js
index 8b5ce961..1af2077e 100644
--- a/test/unit/data.js
+++ b/test/unit/data.js
@@ -488,7 +488,7 @@ if (window.JSON && window.JSON.stringify) {
}
test("jQuery.data should follow html5 specification regarding camel casing", function() {
- expect(6);
+ expect(8);
var div = jQuery("")
.prependTo("body");
@@ -501,5 +501,10 @@ test("jQuery.data should follow html5 specification regarding camel casing", fun
equals(div.data("fooBar"), "b", "Verify multiple word data-* key");
equals(div.data("fooBarBaz"), "c", "Verify multiple word data-* key");
+ div.data("foo-bar", "d");
+
+ equals(div.data("fooBar"), "d", "Verify updated data-* key");
+ equals(div.data("foo-bar"), "d", "Verify updated data-* key");
+
div.remove();
-});
\ No newline at end of file
+});
diff --git a/test/unit/effects.js b/test/unit/effects.js
index ea7f4e72..864c4a40 100644
--- a/test/unit/effects.js
+++ b/test/unit/effects.js
@@ -1029,3 +1029,19 @@ test( "animate properties missing px w/ opacity as last (#9074)", 2, function()
start();
}, 100);
});
+
+test("callbacks should fire in correct order (#9100)", function() {
+ stop();
+ var a = 1,
+ cb = 0,
+ $lis = jQuery("").appendTo("#qunit-fixture")
+ // The test will always pass if no properties are animated or if the duration is 0
+ .animate({fontSize: 12}, 13, function() {
+ a *= jQuery(this).data("operation") === "*2" ? 2 : a;
+ cb++;
+ if ( cb === 2 ) {
+ equal( a, 4, "test value has been *2 and _then_ ^2");
+ start();
+ }
+ });
+});
diff --git a/test/unit/event.js b/test/unit/event.js
index 13877e01..f71c7b29 100644
--- a/test/unit/event.js
+++ b/test/unit/event.js
@@ -14,6 +14,26 @@ test("null or undefined handler", function() {
} catch (e) {}
});
+test("bind(),live(),delegate() with non-null,defined data", function() {
+
+ expect(3);
+
+ var handler = function( event, data ) {
+ equal( data, 0, "non-null, defined data (zero) is correctly passed" );
+ };
+
+ jQuery("#foo").bind("foo", handler);
+ jQuery("#foo").live("foo", handler);
+ jQuery("div").delegate("#foo", "foo", handler);
+
+ jQuery("#foo").trigger("foo", 0);
+
+ jQuery("#foo").unbind("foo", handler);
+ jQuery("#foo").die("foo", handler);
+ jQuery("div").undelegate("#foo", "foo");
+
+});
+
test("bind(), with data", function() {
expect(4);
var handler = function(event) {
diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js
index 972cfaf9..ad3d0484 100644
--- a/test/unit/manipulation.js
+++ b/test/unit/manipulation.js
@@ -1044,7 +1044,7 @@ test("clone(form element) (Bug #3879, #6655)", function() {
equals( clone.is(":checked"), element.is(":checked"), "Checked input cloned correctly" );
equals( clone[0].defaultValue, "foo", "Checked input defaultValue cloned correctly" );
-
+
// defaultChecked also gets set now due to setAttribute in attr, is this check still valid?
// equals( clone[0].defaultChecked, !jQuery.support.noCloneChecked, "Checked input defaultChecked cloned correctly" );
@@ -1393,6 +1393,41 @@ test("jQuery.buildFragment - no plain-text caching (Bug #6779)", function() {
}
catch(e) {}
}
- equals($f.text(), bad.join(""), "Cached strings that match Object properties");
+ equals($f.text(), bad.join(""), "Cached strings that match Object properties");
$f.remove();
});
+
+test( "jQuery.html - execute scripts escaped with html comment or CDATA (#9221)", function() {
+ expect( 3 );
+ jQuery( [
+ ''
+ ].join ( "\n" ) ).appendTo( "#qunit-fixture" );
+ jQuery( [
+ ''
+ ].join ( "\n" ) ).appendTo( "#qunit-fixture" );
+ jQuery( [
+ ''
+ ].join ( "\n" ) ).appendTo( "#qunit-fixture" );
+});
+
+test("jQuery.buildFragment - plain objects are not a document #8950", function() {
+ expect(1);
+
+ try {
+ jQuery('', {});
+ ok( true, "Does not allow attribute object to be treated like a doc object");
+ } catch (e) {}
+
+});
diff --git a/test/unit/queue.js b/test/unit/queue.js
index 9b612ce3..c5c387a4 100644
--- a/test/unit/queue.js
+++ b/test/unit/queue.js
@@ -107,7 +107,31 @@ test("queue() passes in the next item in the queue as a parameter to fx queues",
equals(counter, 2, "Deferreds resolved");
start();
});
+});
+test("callbacks keep their place in the queue", function() {
+ expect(5);
+ stop();
+ var div = jQuery(""),
+ counter = 0;
+
+ div.queue(function( next ) {
+ equal( ++counter, 1, "Queue/callback order: first called" );
+ setTimeout( next, 200 );
+ }).show(100, function() {
+ equal( ++counter, 2, "Queue/callback order: second called" );
+ jQuery(this).hide(100, function() {
+ equal( ++counter, 4, "Queue/callback order: fourth called" );
+ });
+ }).queue(function( next ) {
+ equal( ++counter, 3, "Queue/callback order: third called" );
+ next();
+ });
+
+ div.promise("fx").done(function() {
+ equals(counter, 4, "Deferreds resolved");
+ start();
+ });
});
test("delay()", function() {
diff --git a/test/unit/support.js b/test/unit/support.js
new file mode 100644
index 00000000..36dc3553
--- /dev/null
+++ b/test/unit/support.js
@@ -0,0 +1,55 @@
+module("support", { teardown: moduleTeardown });
+
+function supportIFrameTest( title, url, noDisplay, func ) {
+
+ if ( noDisplay !== true ) {
+ func = noDisplay;
+ noDisplay = false;
+ }
+
+ test( title, function() {
+ var iframe;
+
+ stop();
+ window.supportCallback = function() {
+ var self = this,
+ args = arguments;
+ setTimeout( function() {
+ window.supportCallback = undefined;
+ iframe.remove();
+ func.apply( self, args );
+ start();
+ }, 0 );
+ };
+ iframe = jQuery( "
" ).css( "display", noDisplay ? "none" : "block" ).append(
+ jQuery( "
" ).attr( "src", "data/support/" + url + ".html" )
+ ).appendTo( "body" );
+ });
+}
+
+supportIFrameTest( "proper boxModel in compatMode CSS1Compat (IE6 and IE7)", "boxModelIE", function( compatMode, boxModel ) {
+ ok( compatMode !== "CSS1Compat" || boxModel, "boxModel properly detected" );
+});
+
+supportIFrameTest( "body background is not lost if set prior to loading jQuery (#9238)", "bodyBackground", function( color, support ) {
+ expect( 2 );
+ var okValue = {
+ "#000000": true,
+ "rgb(0, 0, 0)": true
+ };
+ ok( okValue[ color ], "color was not reset (" + color + ")" );
+ var i, passed = true;
+ for ( i in jQuery.support ) {
+ if ( jQuery.support[ i ] !== support[ i ] ) {
+ passed = false;
+ strictEquals( jQuery.support[ i ], support[ i ], "Support property " + i + " is different" );
+ }
+ }
+ for ( i in support ) {
+ if ( !( i in jQuery.support ) ) {
+ ok = false;
+ strictEquals( src[ i ], dest[ i ], "Unexpected property: " + i );
+ }
+ }
+ ok( passed, "Same support properties" );
+});
diff --git a/version.txt b/version.txt
index 29349dd5..22e67ce2 100644
--- a/version.txt
+++ b/version.txt
@@ -1 +1 @@
-1.6.1pre
\ No newline at end of file
+1.6.2pre
\ No newline at end of file