Merge branch 'master' of github.com:jquery/jquery into 1.7/callbacks
Conflicts: test/index.html
This commit is contained in:
commit
1ed70e056d
25 changed files with 529 additions and 143 deletions
|
@ -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 );
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 */ ) {
|
||||
|
|
29
src/effects.js
vendored
29
src/effects.js
vendored
|
@ -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( "<!doctype><html><body></body></html>" );
|
||||
iframeDoc.write( ( document.compatMode === "CSS1Compat" ? "<!doctype html>" : "" ) + "<html><body>" );
|
||||
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
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
|
|
@ -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*<!(?:\[CDATA\[|\-\-)/,
|
||||
wrapMap = {
|
||||
option: [ 1, "<select multiple='multiple'>", "</select>" ],
|
||||
legend: [ 1, "<fieldset>", "</fieldset>" ],
|
||||
|
@ -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 );
|
|
@ -1 +1 @@
|
|||
Subproject commit 4bcc09702d6dadfd0b90c7de3c8b206e97ff97f4
|
||||
Subproject commit 3ba396e439a07c2a2facafbe07cdaa1b80a24c00
|
|
@ -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/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue