Merge branch 'master' of http://github.com/jquery/jquery into effectsCleanup
This commit is contained in:
commit
8806435a77
27 changed files with 1556 additions and 1284 deletions
2
Makefile
2
Makefile
|
@ -111,7 +111,7 @@ update_submodules:
|
|||
|
||||
# update the submodules to the latest at the most logical branch
|
||||
pull_submodules:
|
||||
@@git submodule foreach "git pull origin \$$(git branch --no-color --contains \$$(git rev-parse HEAD) | grep -v \( | head -1)"
|
||||
@@git submodule foreach "git pull \$$(git config remote.origin.url)"
|
||||
@@git submodule summary
|
||||
|
||||
pull: pull_submodules
|
||||
|
|
|
@ -63,7 +63,7 @@ As the source code is handled by the version control system Git, it's useful to
|
|||
|
||||
### Submodules ###
|
||||
|
||||
The repository uses submodules, which normally are handles directly by the Makefile, but sometimes you want to
|
||||
The repository uses submodules, which normally are handled directly by the Makefile, but sometimes you want to
|
||||
be able to work with them manually.
|
||||
|
||||
Following are the steps to manually get the submodules:
|
||||
|
@ -86,7 +86,7 @@ If you want to work inside a submodule, it is possible, but first you need to ch
|
|||
1. `cd src/sizzle`
|
||||
2. `git checkout master`
|
||||
|
||||
After you've commited your changes to the submodule, you'll update the jquery project to point to the new commit,
|
||||
After you've committed your changes to the submodule, you'll update the jquery project to point to the new commit,
|
||||
but remember to push the submodule changes before pushing the new jquery commit:
|
||||
|
||||
1. `cd src/sizzle`
|
||||
|
@ -99,12 +99,12 @@ The makefile has some targets to simplify submodule handling:
|
|||
|
||||
#### `make update_submodules` ####
|
||||
|
||||
checks out the commit pointed to byu jquery, but merges your local changes, if any. This target is executed
|
||||
checks out the commit pointed to by jquery, but merges your local changes, if any. This target is executed
|
||||
when you are doing a normal `make`.
|
||||
|
||||
#### `make pull_submodules` ####
|
||||
|
||||
updates the content of the submoduels to what is probably the latest upstream code
|
||||
updates the content of the submodules to what is probably the latest upstream code.
|
||||
|
||||
#### `make pull` ####
|
||||
|
||||
|
|
|
@ -14,13 +14,12 @@ jQuery.ajaxSetup({
|
|||
// Detect, normalize options and install callbacks for jsonp requests
|
||||
jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
|
||||
|
||||
var dataIsString = ( typeof s.data === "string" );
|
||||
var inspectData = s.contentType === "application/x-www-form-urlencoded" &&
|
||||
( typeof s.data === "string" );
|
||||
|
||||
if ( s.dataTypes[ 0 ] === "jsonp" ||
|
||||
originalSettings.jsonpCallback ||
|
||||
originalSettings.jsonp != null ||
|
||||
s.jsonp !== false && ( jsre.test( s.url ) ||
|
||||
dataIsString && jsre.test( s.data ) ) ) {
|
||||
inspectData && jsre.test( s.data ) ) ) {
|
||||
|
||||
var responseContainer,
|
||||
jsonpCallback = s.jsonpCallback =
|
||||
|
@ -28,20 +27,12 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
|
|||
previous = window[ jsonpCallback ],
|
||||
url = s.url,
|
||||
data = s.data,
|
||||
replace = "$1" + jsonpCallback + "$2",
|
||||
cleanUp = function() {
|
||||
// Set callback back to previous value
|
||||
window[ jsonpCallback ] = previous;
|
||||
// Call if it was a function and we have a response
|
||||
if ( responseContainer && jQuery.isFunction( previous ) ) {
|
||||
window[ jsonpCallback ]( responseContainer[ 0 ] );
|
||||
}
|
||||
};
|
||||
replace = "$1" + jsonpCallback + "$2";
|
||||
|
||||
if ( s.jsonp !== false ) {
|
||||
url = url.replace( jsre, replace );
|
||||
if ( s.url === url ) {
|
||||
if ( dataIsString ) {
|
||||
if ( inspectData ) {
|
||||
data = data.replace( jsre, replace );
|
||||
}
|
||||
if ( s.data === data ) {
|
||||
|
@ -59,8 +50,15 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
|
|||
responseContainer = [ response ];
|
||||
};
|
||||
|
||||
// Install cleanUp function
|
||||
jqXHR.then( cleanUp, cleanUp );
|
||||
// Clean-up function
|
||||
jqXHR.always(function() {
|
||||
// Set callback back to previous value
|
||||
window[ jsonpCallback ] = previous;
|
||||
// Call if it was a function and we have a response
|
||||
if ( responseContainer && jQuery.isFunction( previous ) ) {
|
||||
window[ jsonpCallback ]( responseContainer[ 0 ] );
|
||||
}
|
||||
});
|
||||
|
||||
// Use data converter to retrieve json after script execution
|
||||
s.converters["script json"] = function() {
|
||||
|
|
|
@ -479,7 +479,7 @@ jQuery.each([ "selected", "checked", "readOnly", "disabled" ], function( i, name
|
|||
|
||||
// Some attributes require a special call on IE
|
||||
if ( !jQuery.support.hrefNormalized ) {
|
||||
jQuery.each([ "href", "src", "width", "height", "list" ], function( i, name ) {
|
||||
jQuery.each([ "href", "src", "width", "height" ], function( i, name ) {
|
||||
jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
|
||||
get: function( elem ) {
|
||||
var ret = elem.getAttribute( name, 2 );
|
||||
|
|
47
src/core.js
47
src/core.js
|
@ -358,9 +358,11 @@ jQuery.extend = jQuery.fn.extend = function() {
|
|||
|
||||
jQuery.extend({
|
||||
noConflict: function( deep ) {
|
||||
window.$ = _$;
|
||||
if ( window.$ === jQuery ) {
|
||||
window.$ = _$;
|
||||
}
|
||||
|
||||
if ( deep ) {
|
||||
if ( deep && window.jQuery === jQuery ) {
|
||||
window.jQuery = _jQuery;
|
||||
}
|
||||
|
||||
|
@ -436,7 +438,7 @@ jQuery.extend({
|
|||
} else if ( document.attachEvent ) {
|
||||
// ensure firing before onload,
|
||||
// maybe late but safe also for iframes
|
||||
document.attachEvent("onreadystatechange", DOMContentLoaded);
|
||||
document.attachEvent( "onreadystatechange", DOMContentLoaded );
|
||||
|
||||
// A fallback to window.onload, that will always work
|
||||
window.attachEvent( "onload", jQuery.ready );
|
||||
|
@ -587,7 +589,7 @@ jQuery.extend({
|
|||
each: function( object, callback, args ) {
|
||||
var name, i = 0,
|
||||
length = object.length,
|
||||
isObj = length === undefined || jQuery.isFunction(object);
|
||||
isObj = length === undefined || jQuery.isFunction( object );
|
||||
|
||||
if ( args ) {
|
||||
if ( isObj ) {
|
||||
|
@ -613,8 +615,11 @@ jQuery.extend({
|
|||
}
|
||||
}
|
||||
} else {
|
||||
for ( var value = object[0];
|
||||
i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {}
|
||||
for ( ; i < length; ) {
|
||||
if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -645,7 +650,7 @@ jQuery.extend({
|
|||
// The extra typeof function check is to prevent crashes
|
||||
// in Safari 2 (See: #3039)
|
||||
// Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
|
||||
var type = jQuery.type(array);
|
||||
var type = jQuery.type( array );
|
||||
|
||||
if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
|
||||
push.call( ret, array );
|
||||
|
@ -841,24 +846,24 @@ jQuery.extend({
|
|||
},
|
||||
|
||||
sub: function() {
|
||||
function jQuerySubclass( selector, context ) {
|
||||
return new jQuerySubclass.fn.init( selector, context );
|
||||
function jQuerySub( selector, context ) {
|
||||
return new jQuerySub.fn.init( selector, context );
|
||||
}
|
||||
jQuery.extend( true, jQuerySubclass, this );
|
||||
jQuerySubclass.superclass = this;
|
||||
jQuerySubclass.fn = jQuerySubclass.prototype = this();
|
||||
jQuerySubclass.fn.constructor = jQuerySubclass;
|
||||
jQuerySubclass.subclass = this.subclass;
|
||||
jQuerySubclass.fn.init = function init( selector, context ) {
|
||||
if ( context && context instanceof jQuery && !(context instanceof jQuerySubclass) ) {
|
||||
context = jQuerySubclass(context);
|
||||
jQuery.extend( true, jQuerySub, this );
|
||||
jQuerySub.superclass = this;
|
||||
jQuerySub.fn = jQuerySub.prototype = this();
|
||||
jQuerySub.fn.constructor = jQuerySub;
|
||||
jQuerySub.sub = this.sub;
|
||||
jQuerySub.fn.init = function init( selector, context ) {
|
||||
if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
|
||||
context = jQuerySub( context );
|
||||
}
|
||||
|
||||
return jQuery.fn.init.call( this, selector, context, rootjQuerySubclass );
|
||||
return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
|
||||
};
|
||||
jQuerySubclass.fn.init.prototype = jQuerySubclass.fn;
|
||||
var rootjQuerySubclass = jQuerySubclass(document);
|
||||
return jQuerySubclass;
|
||||
jQuerySub.fn.init.prototype = jQuerySub.fn;
|
||||
var rootjQuerySub = jQuerySub(document);
|
||||
return jQuerySub;
|
||||
},
|
||||
|
||||
browser: {}
|
||||
|
|
37
src/css.js
37
src/css.js
|
@ -93,7 +93,7 @@ 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 ) );
|
||||
value = +value.replace( rrelNumFilter, "" ) + parseFloat( jQuery.css( elem, name ) );
|
||||
}
|
||||
|
||||
// If a number was passed in, add 'px' to the (except for certain CSS properties)
|
||||
|
@ -122,11 +122,17 @@ jQuery.extend({
|
|||
},
|
||||
|
||||
css: function( elem, name, extra ) {
|
||||
// Make sure that we're working with the right name
|
||||
var ret, origName = jQuery.camelCase( name ),
|
||||
hooks = jQuery.cssHooks[ origName ];
|
||||
var ret, hooks;
|
||||
|
||||
name = jQuery.cssProps[ origName ] || origName;
|
||||
// Make sure that we're working with the right name
|
||||
name = jQuery.camelCase( name );
|
||||
hooks = jQuery.cssHooks[ name ];
|
||||
name = jQuery.cssProps[ name ] || name;
|
||||
|
||||
// cssFloat needs a special treatment
|
||||
if ( name === "cssFloat" ) {
|
||||
name = "float";
|
||||
}
|
||||
|
||||
// If a hook was provided get the computed value from there
|
||||
if ( hooks && "get" in hooks && (ret = hooks.get( elem, true, extra )) !== undefined ) {
|
||||
|
@ -134,7 +140,7 @@ jQuery.extend({
|
|||
|
||||
// Otherwise, if a way to get the computed value exists, use that
|
||||
} else if ( curCSS ) {
|
||||
return curCSS( elem, name, origName );
|
||||
return curCSS( elem, name );
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -225,27 +231,28 @@ if ( !jQuery.support.opacity ) {
|
|||
jQuery.cssHooks.opacity = {
|
||||
get: function( elem, computed ) {
|
||||
// IE uses filters for opacity
|
||||
return ropacity.test((computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "") ?
|
||||
(parseFloat(RegExp.$1) / 100) + "" :
|
||||
return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
|
||||
( parseFloat( RegExp.$1 ) / 100 ) + "" :
|
||||
computed ? "1" : "";
|
||||
},
|
||||
|
||||
set: function( elem, value ) {
|
||||
var style = elem.style;
|
||||
var style = elem.style,
|
||||
currentStyle = elem.currentStyle;
|
||||
|
||||
// IE has trouble with opacity if it does not have layout
|
||||
// Force it by setting the zoom level
|
||||
style.zoom = 1;
|
||||
|
||||
// Set the alpha filter to set the opacity
|
||||
var opacity = jQuery.isNaN(value) ?
|
||||
var opacity = jQuery.isNaN( value ) ?
|
||||
"" :
|
||||
"alpha(opacity=" + value * 100 + ")",
|
||||
filter = style.filter || "";
|
||||
filter = currentStyle && currentStyle.filter || style.filter || "";
|
||||
|
||||
style.filter = ralpha.test(filter) ?
|
||||
filter.replace(ralpha, opacity) :
|
||||
style.filter + ' ' + opacity;
|
||||
style.filter = ralpha.test( filter ) ?
|
||||
filter.replace( ralpha, opacity ) :
|
||||
filter + " " + opacity;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -273,7 +280,7 @@ jQuery(function() {
|
|||
});
|
||||
|
||||
if ( document.defaultView && document.defaultView.getComputedStyle ) {
|
||||
getComputedStyle = function( elem, newName, name ) {
|
||||
getComputedStyle = function( elem, name ) {
|
||||
var ret, defaultView, computedStyle;
|
||||
|
||||
name = name.replace( rupper, "-$1" ).toLowerCase();
|
||||
|
|
17
src/effects.js
vendored
17
src/effects.js
vendored
|
@ -152,13 +152,17 @@ jQuery.fn.extend({
|
|||
var optall = jQuery.speed(speed, easing, callback);
|
||||
|
||||
if ( jQuery.isEmptyObject( prop ) ) {
|
||||
return this.each( optall.complete );
|
||||
return this.each( optall.complete, [ false ] );
|
||||
}
|
||||
|
||||
return this[ optall.queue === false ? "each" : "queue" ](function() {
|
||||
// XXX 'this' does not always have a nodeName when running the
|
||||
// test suite
|
||||
|
||||
if ( optall.queue === false ) {
|
||||
jQuery._mark( this );
|
||||
}
|
||||
|
||||
var opt = jQuery.extend({}, optall), p,
|
||||
isElement = this.nodeType === 1,
|
||||
hidden = isElement && jQuery(this).is(":hidden"),
|
||||
|
@ -268,6 +272,10 @@ jQuery.fn.extend({
|
|||
}
|
||||
|
||||
this.each(function() {
|
||||
// clear marker counters if we know they won't be
|
||||
if ( !gotoEnd ) {
|
||||
jQuery._unmark( true, this );
|
||||
}
|
||||
// go in reverse order so anything added to the queue during the loop is ignored
|
||||
for ( var i = timers.length - 1; i >= 0; i-- ) {
|
||||
if ( timers[i].elem === this ) {
|
||||
|
@ -319,10 +327,13 @@ jQuery.extend({
|
|||
|
||||
// Queueing
|
||||
opt.old = opt.complete;
|
||||
opt.complete = function() {
|
||||
opt.complete = function( noUnmark ) {
|
||||
if ( opt.queue !== false ) {
|
||||
jQuery(this).dequeue();
|
||||
jQuery.dequeue( this );
|
||||
} else if ( noUnmark !== false ) {
|
||||
jQuery._unmark( this );
|
||||
}
|
||||
|
||||
if ( jQuery.isFunction( opt.old ) ) {
|
||||
opt.old.call( this );
|
||||
}
|
||||
|
|
105
src/event.js
105
src/event.js
|
@ -24,17 +24,6 @@ jQuery.event = {
|
|||
return;
|
||||
}
|
||||
|
||||
// TODO :: Use a try/catch until it's safe to pull this out (likely 1.6)
|
||||
// Minor release fix for bug #8018
|
||||
try {
|
||||
// For whatever reason, IE has trouble passing the window object
|
||||
// around, causing it to be cloned in the process
|
||||
if ( jQuery.isWindow( elem ) && ( elem !== window && !elem.frameElement ) ) {
|
||||
elem = window;
|
||||
}
|
||||
}
|
||||
catch ( e ) {}
|
||||
|
||||
if ( handler === false ) {
|
||||
handler = returnFalse;
|
||||
} else if ( !handler ) {
|
||||
|
@ -277,34 +266,53 @@ jQuery.event = {
|
|||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Events that are safe to short-circuit if no handlers are attached.
|
||||
// Native DOM events should not be added, they may have inline handlers.
|
||||
customEvent: {
|
||||
"getData": true,
|
||||
"setData": true,
|
||||
"changeData": true
|
||||
},
|
||||
|
||||
trigger: function( event, data, elem ) {
|
||||
// Event object or event type
|
||||
var type = event.type || event,
|
||||
namespaces = [];
|
||||
namespaces = [],
|
||||
exclusive;
|
||||
|
||||
if ( type.indexOf("!") >= 0 ) {
|
||||
// Exclusive events trigger only for the exact event (no namespaces)
|
||||
type = type.slice(0, -1);
|
||||
exclusive = true;
|
||||
}
|
||||
|
||||
if ( type.indexOf(".") >= 0 ) {
|
||||
// Namespaced trigger; create a regexp to match event type in handle()
|
||||
namespaces = type.split(".");
|
||||
type = namespaces.shift();
|
||||
namespaces.sort();
|
||||
}
|
||||
|
||||
if ( jQuery.event.customEvent[ type ] && !jQuery.event.global[ type ] ) {
|
||||
// No jQuery handlers for this event type, and it can't have inline handlers
|
||||
return;
|
||||
}
|
||||
|
||||
// Caller can pass in an Event, Object, or just an event type string
|
||||
event = typeof event === "object" ?
|
||||
// jQuery.Event object
|
||||
event[ jQuery.expando ] ? event :
|
||||
// Object literal
|
||||
jQuery.extend( jQuery.Event(type), event ) :
|
||||
new jQuery.Event( type, event ) :
|
||||
// Just the event type (string)
|
||||
jQuery.Event(type);
|
||||
new jQuery.Event( type );
|
||||
|
||||
if ( type.indexOf("!") >= 0 ) {
|
||||
// Exclusive events trigger only for the bare event type (no namespaces)
|
||||
event.type = type = type.slice(0, -1);
|
||||
event.exclusive = true;
|
||||
}
|
||||
if ( type.indexOf(".") >= 0 ) {
|
||||
// Namespaced trigger; create a regexp to match event type in handle()
|
||||
namespaces = type.split(".");
|
||||
event.type = type = namespaces.shift();
|
||||
namespaces.sort();
|
||||
}
|
||||
event.type = type;
|
||||
event.namespace = namespaces.join(".");
|
||||
event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)");
|
||||
|
||||
event.exclusive = exclusive;
|
||||
|
||||
// Handle a global trigger
|
||||
if ( !elem ) {
|
||||
// Don't bubble custom events when global (to avoid too much overhead)
|
||||
|
@ -338,12 +346,12 @@ jQuery.event = {
|
|||
event.target = elem;
|
||||
|
||||
// Clone any incoming data and prepend the event, creating the handler arg list
|
||||
data = jQuery.makeArray( data );
|
||||
data = data ? jQuery.makeArray( data ) : [];
|
||||
data.unshift( event );
|
||||
|
||||
var cur = elem,
|
||||
// IE doesn't like method names with a colon (#3533, #8272)
|
||||
ontype = type.indexOf(":") < 0? "on" + type : "";
|
||||
ontype = type.indexOf(":") < 0 ? "on" + type : "";
|
||||
|
||||
// Fire event on the current element, then bubble up the DOM tree
|
||||
do {
|
||||
|
@ -355,7 +363,7 @@ jQuery.event = {
|
|||
}
|
||||
|
||||
// Trigger an inline bound script
|
||||
if ( ontype &&jQuery.acceptData( cur ) && cur[ ontype ] && cur[ ontype ].apply( cur, data ) === false ) {
|
||||
if ( ontype && jQuery.acceptData( cur ) && cur[ ontype ] && cur[ ontype ].apply( cur, data ) === false ) {
|
||||
event.result = false;
|
||||
event.preventDefault();
|
||||
}
|
||||
|
@ -403,7 +411,7 @@ jQuery.event = {
|
|||
// Snapshot the handlers list since a called handler may add/remove events.
|
||||
var handlers = ((jQuery._data( this, "events" ) || {})[ event.type ] || []).slice(0),
|
||||
run_all = !event.exclusive && !event.namespace,
|
||||
args = jQuery.makeArray( arguments );
|
||||
args = Array.prototype.slice.call( arguments, 0 );
|
||||
|
||||
// Use the fix-ed Event rather than the (read-only) native event
|
||||
args[0] = event;
|
||||
|
@ -555,24 +563,16 @@ jQuery.removeEvent = document.removeEventListener ?
|
|||
}
|
||||
};
|
||||
|
||||
jQuery.Event = function( src ) {
|
||||
jQuery.Event = function( src, props ) {
|
||||
// Allow instantiation without the 'new' keyword
|
||||
if ( !this.preventDefault ) {
|
||||
return new jQuery.Event( src );
|
||||
return new jQuery.Event( src, props );
|
||||
}
|
||||
|
||||
// Event object
|
||||
if ( src && src.type ) {
|
||||
this.originalEvent = src;
|
||||
|
||||
// Push explicitly provided properties onto the event object
|
||||
for ( var prop in src ) {
|
||||
// Ensure we don't clobber jQuery.Event prototype
|
||||
// with own properties.
|
||||
if ( hasOwn.call( src, prop ) ) {
|
||||
this[ prop ] = src[ prop ];
|
||||
}
|
||||
}
|
||||
this.type = src.type;
|
||||
|
||||
// Events bubbling up the document may have been marked as prevented
|
||||
// by a handler lower down the tree; reflect the correct value.
|
||||
|
@ -584,6 +584,11 @@ jQuery.Event = function( src ) {
|
|||
this.type = src;
|
||||
}
|
||||
|
||||
// Put explicitly provided properties onto the event object
|
||||
if ( props ) {
|
||||
jQuery.extend( this, props );
|
||||
}
|
||||
|
||||
// timeStamp is buggy for some events on Firefox(#3843)
|
||||
// So we won't rely on the native value
|
||||
this.timeStamp = jQuery.now();
|
||||
|
@ -790,7 +795,7 @@ if ( !jQuery.support.changeBubbles ) {
|
|||
beforedeactivate: testChange,
|
||||
|
||||
click: function( e ) {
|
||||
var elem = e.target, type = elem.type;
|
||||
var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : "";
|
||||
|
||||
if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) {
|
||||
testChange.call( this, e );
|
||||
|
@ -800,7 +805,7 @@ if ( !jQuery.support.changeBubbles ) {
|
|||
// Change has to be called before submit
|
||||
// Keydown will be called before keypress, which is used in submit-event delegation
|
||||
keydown: function( e ) {
|
||||
var elem = e.target, type = elem.type;
|
||||
var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : "";
|
||||
|
||||
if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") ||
|
||||
(e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
|
||||
|
@ -955,7 +960,7 @@ jQuery.fn.extend({
|
|||
|
||||
undelegate: function( selector, types, fn ) {
|
||||
if ( arguments.length === 0 ) {
|
||||
return this.unbind( "live" );
|
||||
return this.unbind( "live" );
|
||||
|
||||
} else {
|
||||
return this.die( types, null, fn, selector );
|
||||
|
@ -970,7 +975,7 @@ jQuery.fn.extend({
|
|||
|
||||
triggerHandler: function( type, data ) {
|
||||
if ( this[0] ) {
|
||||
var event = jQuery.Event( type );
|
||||
var event = new jQuery.Event( type );
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
jQuery.event.trigger( event, data, this[0] );
|
||||
|
@ -1030,10 +1035,18 @@ jQuery.each(["live", "die"], function( i, name ) {
|
|||
return this;
|
||||
}
|
||||
|
||||
if ( name === "die" && !types &&
|
||||
origSelector && origSelector.charAt(0) === "." ) {
|
||||
|
||||
context.unbind( origSelector );
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
if ( data === false || jQuery.isFunction( data ) ) {
|
||||
fn = data || returnFalse;
|
||||
data = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
types = (types || "").split(" ");
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
|
|||
rnocache = /<(?:script|object|embed|option|style)/i,
|
||||
// checked="checked" or checked
|
||||
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
|
||||
rscriptType = /\/(java|ecma)script/i,
|
||||
wrapMap = {
|
||||
option: [ 1, "<select multiple='multiple'>", "</select>" ],
|
||||
legend: [ 1, "<fieldset>", "</fieldset>" ],
|
||||
|
@ -387,11 +388,15 @@ function cloneFixAttributes( src, dest ) {
|
|||
|
||||
// clearAttributes removes the attributes, which we don't want,
|
||||
// but also removes the attachEvent events, which we *do* want
|
||||
dest.clearAttributes();
|
||||
if ( dest.clearAttributes ) {
|
||||
dest.clearAttributes();
|
||||
}
|
||||
|
||||
// mergeAttributes, in contrast, only merges back on the
|
||||
// original attributes, not the events
|
||||
dest.mergeAttributes(src);
|
||||
if ( dest.mergeAttributes ) {
|
||||
dest.mergeAttributes( src );
|
||||
}
|
||||
|
||||
// IE6-8 fail to clone children inside object elements that use
|
||||
// the proprietary classid attribute value (rather than the type
|
||||
|
@ -552,6 +557,8 @@ jQuery.extend({
|
|||
},
|
||||
|
||||
clean: function( elems, context, fragment, scripts ) {
|
||||
var checkScriptType;
|
||||
|
||||
context = context || document;
|
||||
|
||||
// !context.createElement fails in IE with an error but returns typeof 'object'
|
||||
|
@ -629,13 +636,18 @@ jQuery.extend({
|
|||
}
|
||||
|
||||
if ( fragment ) {
|
||||
checkScriptType = function( elem ) {
|
||||
return !elem.type || rscriptType.test( elem.type );
|
||||
};
|
||||
for ( i = 0; ret[i]; i++ ) {
|
||||
if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
|
||||
scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
|
||||
|
||||
} else {
|
||||
if ( ret[i].nodeType === 1 ) {
|
||||
ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) );
|
||||
var jsTags = jQuery.grep( ret[i].getElementsByTagName( "script" ), checkScriptType );
|
||||
|
||||
ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
|
||||
}
|
||||
fragment.appendChild( ret[i] );
|
||||
}
|
||||
|
|
|
@ -180,17 +180,19 @@ jQuery.offset = {
|
|||
curOffset = curElem.offset(),
|
||||
curCSSTop = jQuery.css( elem, "top" ),
|
||||
curCSSLeft = jQuery.css( elem, "left" ),
|
||||
calculatePosition = (position === "absolute" || position === "fixed") && jQuery.inArray('auto', [curCSSTop, curCSSLeft]) > -1,
|
||||
calculatePosition = (position === "absolute" || position === "fixed") && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1,
|
||||
props = {}, curPosition = {}, curTop, curLeft;
|
||||
|
||||
// need to be able to calculate position if either top or left is auto and position is either absolute or fixed
|
||||
if ( calculatePosition ) {
|
||||
curPosition = curElem.position();
|
||||
curTop = curPosition.top;
|
||||
curLeft = curPosition.left;
|
||||
} else {
|
||||
curTop = parseFloat( curCSSTop ) || 0;
|
||||
curLeft = parseFloat( curCSSLeft ) || 0;
|
||||
}
|
||||
|
||||
curTop = calculatePosition ? curPosition.top : parseInt( curCSSTop, 10 ) || 0;
|
||||
curLeft = calculatePosition ? curPosition.left : parseInt( curCSSLeft, 10 ) || 0;
|
||||
|
||||
if ( jQuery.isFunction( options ) ) {
|
||||
options = options.call( elem, i, curOffset );
|
||||
}
|
||||
|
@ -259,29 +261,16 @@ jQuery.fn.extend({
|
|||
jQuery.each( ["Left", "Top"], function( i, name ) {
|
||||
var method = "scroll" + name;
|
||||
|
||||
jQuery.fn[ method ] = function(val) {
|
||||
var elem = this[0], win;
|
||||
jQuery.fn[ method ] = function( val ) {
|
||||
var elem, win;
|
||||
|
||||
if ( !elem ) {
|
||||
return null;
|
||||
}
|
||||
if ( val === undefined ) {
|
||||
elem = this[ 0 ];
|
||||
|
||||
if ( val !== undefined ) {
|
||||
// Set the scroll offset
|
||||
return this.each(function() {
|
||||
win = getWindow( this );
|
||||
if ( !elem ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ( win ) {
|
||||
win.scrollTo(
|
||||
!i ? val : jQuery(win).scrollLeft(),
|
||||
i ? val : jQuery(win).scrollTop()
|
||||
);
|
||||
|
||||
} else {
|
||||
this[ method ] = val;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
win = getWindow( elem );
|
||||
|
||||
// Return the scroll offset
|
||||
|
@ -290,6 +279,21 @@ jQuery.each( ["Left", "Top"], function( i, name ) {
|
|||
win.document.body[ method ] :
|
||||
elem[ method ];
|
||||
}
|
||||
|
||||
// Set the scroll offset
|
||||
return this.each(function() {
|
||||
win = getWindow( this );
|
||||
|
||||
if ( win ) {
|
||||
win.scrollTo(
|
||||
!i ? val : jQuery( win ).scrollLeft(),
|
||||
i ? val : jQuery( win ).scrollTop()
|
||||
);
|
||||
|
||||
} else {
|
||||
this[ method ] = val;
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
|
|
95
src/queue.js
95
src/queue.js
|
@ -1,27 +1,67 @@
|
|||
(function( jQuery ) {
|
||||
|
||||
function handleQueueMarkDefer( elem, type, src ) {
|
||||
var deferDataKey = type + "defer",
|
||||
queueDataKey = type + "queue",
|
||||
markDataKey = type + "mark",
|
||||
defer = jQuery.data( elem, deferDataKey, undefined, true );
|
||||
if ( defer &&
|
||||
( src === "queue" || !jQuery.data( elem, queueDataKey, undefined, true ) ) &&
|
||||
( src === "mark" || !jQuery.data( elem, markDataKey, undefined, true ) ) ) {
|
||||
// Give room for hard-coded callbacks to fire first
|
||||
// and eventually mark/queue something else on the element
|
||||
setTimeout( function() {
|
||||
if ( !jQuery.data( elem, queueDataKey, undefined, true ) &&
|
||||
!jQuery.data( elem, markDataKey, undefined, true ) ) {
|
||||
jQuery.removeData( elem, deferDataKey, true );
|
||||
defer.resolve();
|
||||
}
|
||||
}, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
jQuery.extend({
|
||||
queue: function( elem, type, data ) {
|
||||
if ( !elem ) {
|
||||
return;
|
||||
|
||||
_mark: function( elem, type ) {
|
||||
if ( elem ) {
|
||||
type = (type || "fx") + "mark";
|
||||
jQuery.data( elem, type, (jQuery.data(elem,type,undefined,true) || 0) + 1, true );
|
||||
}
|
||||
},
|
||||
|
||||
type = (type || "fx") + "queue";
|
||||
var q = jQuery._data( elem, type );
|
||||
_unmark: function( force, elem, type ) {
|
||||
if ( force !== true ) {
|
||||
type = elem;
|
||||
elem = force;
|
||||
force = false;
|
||||
}
|
||||
if ( elem ) {
|
||||
type = type || "fx";
|
||||
var key = type + "mark",
|
||||
count = force ? 0 : ( (jQuery.data( elem, key, undefined, true) || 1 ) - 1 );
|
||||
if ( count ) {
|
||||
jQuery.data( elem, key, count, true );
|
||||
} else {
|
||||
jQuery.removeData( elem, key, true );
|
||||
handleQueueMarkDefer( elem, type, "mark" );
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Speed up dequeue by getting out quickly if this is just a lookup
|
||||
if ( !data ) {
|
||||
queue: function( elem, type, data ) {
|
||||
if ( elem ) {
|
||||
type = (type || "fx") + "queue";
|
||||
var q = jQuery.data( elem, type, undefined, true );
|
||||
// Speed up dequeue by getting out quickly if this is just a lookup
|
||||
if ( data ) {
|
||||
if ( !q || jQuery.isArray(data) ) {
|
||||
q = jQuery.data( elem, type, jQuery.makeArray(data), true );
|
||||
} else {
|
||||
q.push( data );
|
||||
}
|
||||
}
|
||||
return q || [];
|
||||
}
|
||||
|
||||
if ( !q || jQuery.isArray(data) ) {
|
||||
q = jQuery._data( elem, type, jQuery.makeArray(data) );
|
||||
|
||||
} else {
|
||||
q.push( data );
|
||||
}
|
||||
|
||||
return q;
|
||||
},
|
||||
|
||||
dequeue: function( elem, type ) {
|
||||
|
@ -50,17 +90,7 @@ jQuery.extend({
|
|||
|
||||
if ( !queue.length ) {
|
||||
jQuery.removeData( elem, type + "queue", true );
|
||||
// Look if we have observers and resolve if needed
|
||||
if (( defer = jQuery.data( elem, type + "defer", undefined, true ) )) {
|
||||
// Give room for hard-coded callbacks to fire first
|
||||
// and eventually add another animation on the element
|
||||
setTimeout( function() {
|
||||
if ( !jQuery.data( elem, type + "queue", undefined, true ) ) {
|
||||
jQuery.removeData( elem, type + "defer", true );
|
||||
defer.resolve();
|
||||
}
|
||||
}, 0 );
|
||||
}
|
||||
handleQueueMarkDefer( elem, type, "queue" );
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -75,7 +105,7 @@ jQuery.fn.extend({
|
|||
if ( data === undefined ) {
|
||||
return jQuery.queue( this[0], type );
|
||||
}
|
||||
return this.each(function( i ) {
|
||||
return this.each(function() {
|
||||
var queue = jQuery.queue( this, type, data );
|
||||
|
||||
if ( type === "fx" && queue[0] !== "inprogress" ) {
|
||||
|
@ -88,7 +118,6 @@ jQuery.fn.extend({
|
|||
jQuery.dequeue( this, type );
|
||||
});
|
||||
},
|
||||
|
||||
// Based off of the plugin by Clint Helfers, with permission.
|
||||
// http://blindsignals.com/index.php/2009/07/jquery-delay/
|
||||
delay: function( time, type ) {
|
||||
|
@ -102,11 +131,9 @@ jQuery.fn.extend({
|
|||
}, time );
|
||||
});
|
||||
},
|
||||
|
||||
clearQueue: function( type ) {
|
||||
return this.queue( type || "fx", [] );
|
||||
},
|
||||
|
||||
// Get a promise resolved when queues of a certain type
|
||||
// are emptied (fx is the type by default)
|
||||
promise: function( type, object ) {
|
||||
|
@ -120,7 +147,8 @@ jQuery.fn.extend({
|
|||
i = elements.length,
|
||||
count = 1,
|
||||
deferDataKey = type + "defer",
|
||||
queueDataKey = type + "queue";
|
||||
queueDataKey = type + "queue",
|
||||
markDataKey = type + "mark";
|
||||
function resolve() {
|
||||
if ( !( --count ) ) {
|
||||
defer.resolveWith( elements, [ elements ] );
|
||||
|
@ -128,7 +156,8 @@ jQuery.fn.extend({
|
|||
}
|
||||
while( i-- ) {
|
||||
if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) ||
|
||||
jQuery.data( elements[ i ], queueDataKey, undefined, true ) &&
|
||||
( jQuery.data( elements[ i ], queueDataKey, undefined, true ) ||
|
||||
jQuery.data( elements[ i ], markDataKey, undefined, true ) ) &&
|
||||
jQuery.data( elements[ i ], deferDataKey, jQuery._Deferred(), true ) )) {
|
||||
count++;
|
||||
tmp.done( resolve );
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit c50b0cddec48494ba882606d03e14cce647d243b
|
||||
Subproject commit 69ecd019852c1421cbd81fe6ceb4e22a81022ea7
|
|
@ -8,6 +8,7 @@ jQuery.support = (function() {
|
|||
select,
|
||||
opt,
|
||||
input,
|
||||
marginDiv,
|
||||
support,
|
||||
fragment,
|
||||
body,
|
||||
|
@ -72,7 +73,7 @@ jQuery.support = (function() {
|
|||
// Make sure that a selected-by-default option has a working selected property.
|
||||
// (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
|
||||
optSelected: opt.selected,
|
||||
|
||||
|
||||
// Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
|
||||
getSetAttribute: div.className !== "t",
|
||||
|
||||
|
@ -190,10 +191,12 @@ jQuery.support = (function() {
|
|||
// Fails in WebKit before Feb 2011 nightlies
|
||||
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
|
||||
if ( document.defaultView && document.defaultView.getComputedStyle ) {
|
||||
div.style.width = "1px";
|
||||
div.style.marginRight = "0";
|
||||
marginDiv = document.createElement('div');
|
||||
marginDiv.style.width = "0";
|
||||
marginDiv.style.marginRight = "0";
|
||||
div.appendChild( marginDiv );
|
||||
support.reliableMarginRight =
|
||||
( parseInt( document.defaultView.getComputedStyle(div).marginRight, 10 ) || 0 ) === 0;
|
||||
( parseInt( document.defaultView.getComputedStyle( marginDiv, null ).marginRight, 10 ) || 0 ) === 0;
|
||||
}
|
||||
|
||||
// Remove the body element we added
|
||||
|
@ -221,9 +224,6 @@ jQuery.support = (function() {
|
|||
}
|
||||
}
|
||||
|
||||
// release memory in IE
|
||||
body = div = all = a = tds = undefined;
|
||||
|
||||
return support;
|
||||
})();
|
||||
|
||||
|
|
|
@ -73,9 +73,9 @@ jQuery.fn.extend({
|
|||
},
|
||||
|
||||
is: function( selector ) {
|
||||
return !!selector && (typeof selector === "string" ?
|
||||
return !!selector && ( typeof selector === "string" ?
|
||||
jQuery.filter( selector, this ).length > 0 :
|
||||
this.filter( selector ).length > 0);
|
||||
this.filter( selector ).length > 0 );
|
||||
},
|
||||
|
||||
closest: function( selectors, context ) {
|
||||
|
@ -298,13 +298,18 @@ jQuery.extend({
|
|||
|
||||
// Implement the identical functionality for filter and not
|
||||
function winnow( elements, qualifier, keep ) {
|
||||
|
||||
// Can't pass null or undefined to indexOf in Firefox 4
|
||||
// Set to 0 to skip string check
|
||||
qualifier = qualifier || 0;
|
||||
|
||||
if ( jQuery.isFunction( qualifier ) ) {
|
||||
return jQuery.grep(elements, function( elem, i ) {
|
||||
var retVal = !!qualifier.call( elem, i, elem );
|
||||
return retVal === keep;
|
||||
});
|
||||
|
||||
} else if ( qualifier && qualifier.nodeType ) {
|
||||
} else if ( qualifier.nodeType ) {
|
||||
return jQuery.grep(elements, function( elem, i ) {
|
||||
return (elem === qualifier) === keep;
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* for testing opacity set in styles in IE */
|
||||
ol#empty { opacity: 0; filter:Alpha(opacity=0); }
|
||||
ol#empty { opacity: 0; filter:Alpha(opacity=0) progid:DXImageTransform.Microsoft.gradient(startColorStr='#ffff0000', EndColorStr='#ffffffff'); }
|
||||
|
||||
div#fx-tests h4 {
|
||||
background: red;
|
||||
|
@ -109,3 +109,6 @@ div#show-tests * { display: none; }
|
|||
#nothiddendiv { font-size: 16px; }
|
||||
#nothiddendivchild.em { font-size: 2em; }
|
||||
#nothiddendivchild.prct { font-size: 150%; }
|
||||
|
||||
/* For testing type on vml in IE #7071 */
|
||||
v\:oval { behavior:url(#default#VML); display:inline-block; }
|
|
@ -14,7 +14,7 @@ test("jQuery.ajax() - success callbacks", function() {
|
|||
|
||||
stop();
|
||||
|
||||
jQuery('#foo').ajaxStart(function(){
|
||||
jQuery("#foo").ajaxStart(function(){
|
||||
ok( true, "ajaxStart" );
|
||||
}).ajaxStop(function(){
|
||||
ok( true, "ajaxStop" );
|
||||
|
@ -46,7 +46,7 @@ test("jQuery.ajax() - success callbacks - (url, options) syntax", function() {
|
|||
stop();
|
||||
|
||||
setTimeout(function(){
|
||||
jQuery('#foo').ajaxStart(function(){
|
||||
jQuery("#foo").ajaxStart(function(){
|
||||
ok( true, "ajaxStart" );
|
||||
}).ajaxStop(function(){
|
||||
ok( true, "ajaxStop" );
|
||||
|
@ -78,7 +78,7 @@ test("jQuery.ajax() - success callbacks (late binding)", function() {
|
|||
stop();
|
||||
|
||||
setTimeout(function(){
|
||||
jQuery('#foo').ajaxStart(function(){
|
||||
jQuery("#foo").ajaxStart(function(){
|
||||
ok( true, "ajaxStart" );
|
||||
}).ajaxStop(function(){
|
||||
ok( true, "ajaxStop" );
|
||||
|
@ -111,7 +111,7 @@ test("jQuery.ajax() - success callbacks (oncomplete binding)", function() {
|
|||
stop();
|
||||
|
||||
setTimeout(function(){
|
||||
jQuery('#foo').ajaxStart(function(){
|
||||
jQuery("#foo").ajaxStart(function(){
|
||||
ok( true, "ajaxStart" );
|
||||
}).ajaxStop(function(){
|
||||
ok( true, "ajaxStop" );
|
||||
|
@ -147,7 +147,7 @@ test("jQuery.ajax() - success callbacks (very late binding)", function() {
|
|||
stop();
|
||||
|
||||
setTimeout(function(){
|
||||
jQuery('#foo').ajaxStart(function(){
|
||||
jQuery("#foo").ajaxStart(function(){
|
||||
ok( true, "ajaxStart" );
|
||||
}).ajaxStop(function(){
|
||||
ok( true, "ajaxStop" );
|
||||
|
@ -214,7 +214,7 @@ test("jQuery.ajax() - error callbacks", function() {
|
|||
expect( 8 );
|
||||
stop();
|
||||
|
||||
jQuery('#foo').ajaxStart(function(){
|
||||
jQuery("#foo").ajaxStart(function(){
|
||||
ok( true, "ajaxStart" );
|
||||
}).ajaxStop(function(){
|
||||
ok( true, "ajaxStop" );
|
||||
|
@ -247,10 +247,10 @@ test( "jQuery.ajax - multiple method signatures introduced in 1.5 ( #8107)", fun
|
|||
stop();
|
||||
|
||||
jQuery.when(
|
||||
jQuery.ajax().success(function() { ok( true, 'With no arguments' ); }),
|
||||
jQuery.ajax('data/name.html').success(function() { ok( true, 'With only string URL argument' ); }),
|
||||
jQuery.ajax('data/name.html', {} ).success(function() { ok( true, 'With string URL param and map' ); }),
|
||||
jQuery.ajax({ url: 'data/name.html'} ).success(function() { ok( true, 'With only map' ); })
|
||||
jQuery.ajax().success(function() { ok( true, "With no arguments" ); }),
|
||||
jQuery.ajax("data/name.html").success(function() { ok( true, "With only string URL argument" ); }),
|
||||
jQuery.ajax("data/name.html", {} ).success(function() { ok( true, "With string URL param and map" ); }),
|
||||
jQuery.ajax({ url: "data/name.html"} ).success(function() { ok( true, "With only map" ); })
|
||||
).then( start, start );
|
||||
|
||||
});
|
||||
|
@ -348,7 +348,7 @@ test(".ajax() - headers" , function() {
|
|||
|
||||
stop();
|
||||
|
||||
jQuery('#foo').ajaxSend(function( evt, xhr ) {
|
||||
jQuery("#foo").ajaxSend(function( evt, xhr ) {
|
||||
xhr.setRequestHeader( "ajax-send", "test" );
|
||||
});
|
||||
|
||||
|
@ -509,7 +509,7 @@ test("jQuery ajax - cross-domain detection", function() {
|
|||
|
||||
jQuery.ajax({
|
||||
dataType: "jsonp",
|
||||
url: 'app:/path',
|
||||
url: "app:/path",
|
||||
beforeSend: function( _ , s ) {
|
||||
ok( s.crossDomain , "Adobe AIR app:/ URL detected as cross-domain" );
|
||||
return false;
|
||||
|
@ -518,7 +518,7 @@ test("jQuery ajax - cross-domain detection", function() {
|
|||
|
||||
jQuery.ajax({
|
||||
dataType: "jsonp",
|
||||
url: loc.protocol + '//somewebsitethatdoesnotexist-656329477541.com:' + ( loc.port || 80 ),
|
||||
url: loc.protocol + "//somewebsitethatdoesnotexist-656329477541.com:" + ( loc.port || 80 ),
|
||||
beforeSend: function( _ , s ) {
|
||||
ok( s.crossDomain , "Test different hostnames are detected as cross-domain" );
|
||||
return false;
|
||||
|
@ -559,7 +559,7 @@ test(".load() - 404 error callbacks", function() {
|
|||
expect( 6 );
|
||||
stop();
|
||||
|
||||
jQuery('#foo').ajaxStart(function(){
|
||||
jQuery("#foo").ajaxStart(function(){
|
||||
ok( true, "ajaxStart" );
|
||||
}).ajaxStop(function(){
|
||||
ok( true, "ajaxStop" );
|
||||
|
@ -583,7 +583,7 @@ test("jQuery.ajax() - abort", function() {
|
|||
expect( 8 );
|
||||
stop();
|
||||
|
||||
jQuery('#foo').ajaxStart(function(){
|
||||
jQuery("#foo").ajaxStart(function(){
|
||||
ok( true, "ajaxStart" );
|
||||
}).ajaxStop(function(){
|
||||
ok( true, "ajaxStop" );
|
||||
|
@ -628,7 +628,7 @@ test("Ajax events with context", function() {
|
|||
};
|
||||
}
|
||||
|
||||
jQuery('#foo').add(context)
|
||||
jQuery("#foo").add(context)
|
||||
.ajaxSend(event)
|
||||
.ajaxComplete(event)
|
||||
.ajaxError(event)
|
||||
|
@ -650,7 +650,7 @@ test("Ajax events with context", function() {
|
|||
complete: function(){
|
||||
callback("complete").call(this);
|
||||
|
||||
jQuery('#foo').add(context).unbind();
|
||||
jQuery("#foo").add(context).unbind();
|
||||
|
||||
jQuery.ajax({
|
||||
url: url("data/404.html"),
|
||||
|
@ -734,7 +734,7 @@ test("jQuery.ajax() - disabled globals", function() {
|
|||
expect( 3 );
|
||||
stop();
|
||||
|
||||
jQuery('#foo').ajaxStart(function(){
|
||||
jQuery("#foo").ajaxStart(function(){
|
||||
ok( false, "ajaxStart" );
|
||||
}).ajaxStop(function(){
|
||||
ok( false, "ajaxStop" );
|
||||
|
@ -768,9 +768,9 @@ test("jQuery.ajax - xml: non-namespace elements inside namespaced elements", fun
|
|||
url: url("data/with_fries.xml"),
|
||||
dataType: "xml",
|
||||
success: function(resp) {
|
||||
equals( jQuery("properties", resp).length, 1, 'properties in responseXML' );
|
||||
equals( jQuery("jsconf", resp).length, 1, 'jsconf in responseXML' );
|
||||
equals( jQuery("thing", resp).length, 2, 'things in responseXML' );
|
||||
equals( jQuery("properties", resp).length, 1, "properties in responseXML" );
|
||||
equals( jQuery("jsconf", resp).length, 1, "jsconf in responseXML" );
|
||||
equals( jQuery("thing", resp).length, 2, "things in responseXML" );
|
||||
start();
|
||||
}
|
||||
});
|
||||
|
@ -783,9 +783,9 @@ test("jQuery.ajax - xml: non-namespace elements inside namespaced elements (over
|
|||
url: url("data/with_fries_over_jsonp.php"),
|
||||
dataType: "jsonp xml",
|
||||
success: function(resp) {
|
||||
equals( jQuery("properties", resp).length, 1, 'properties in responseXML' );
|
||||
equals( jQuery("jsconf", resp).length, 1, 'jsconf in responseXML' );
|
||||
equals( jQuery("thing", resp).length, 2, 'things in responseXML' );
|
||||
equals( jQuery("properties", resp).length, 1, "properties in responseXML" );
|
||||
equals( jQuery("jsconf", resp).length, 1, "jsconf in responseXML" );
|
||||
equals( jQuery("thing", resp).length, 2, "things in responseXML" );
|
||||
start();
|
||||
},
|
||||
error: function(_1,_2,error) {
|
||||
|
@ -804,7 +804,7 @@ test("jQuery.ajax - HEAD requests", function() {
|
|||
type: "HEAD",
|
||||
success: function(data, status, xhr){
|
||||
var h = xhr.getAllResponseHeaders();
|
||||
ok( /Date/i.test(h), 'No Date in HEAD response' );
|
||||
ok( /Date/i.test(h), "No Date in HEAD response" );
|
||||
|
||||
jQuery.ajax({
|
||||
url: url("data/name.html"),
|
||||
|
@ -812,7 +812,7 @@ test("jQuery.ajax - HEAD requests", function() {
|
|||
type: "HEAD",
|
||||
success: function(data, status, xhr){
|
||||
var h = xhr.getAllResponseHeaders();
|
||||
ok( /Date/i.test(h), 'No Date in HEAD response with data' );
|
||||
ok( /Date/i.test(h), "No Date in HEAD response with data" );
|
||||
start();
|
||||
}
|
||||
});
|
||||
|
@ -891,8 +891,8 @@ test("jQuery.ajax - dataType html", function() {
|
|||
stop();
|
||||
|
||||
var verifyEvaluation = function() {
|
||||
equals( testFoo, "foo", 'Check if script was evaluated for datatype html' );
|
||||
equals( foobar, "bar", 'Check if script src was evaluated for datatype html' );
|
||||
equals( testFoo, "foo", "Check if script was evaluated for datatype html" );
|
||||
equals( foobar, "bar", "Check if script src was evaluated for datatype html" );
|
||||
|
||||
start();
|
||||
};
|
||||
|
@ -902,7 +902,7 @@ test("jQuery.ajax - dataType html", function() {
|
|||
url: url("data/test.html"),
|
||||
success: function(data) {
|
||||
jQuery("#ap").html(data);
|
||||
ok( data.match(/^html text/), 'Check content for datatype html' );
|
||||
ok( data.match(/^html text/), "Check content for datatype html" );
|
||||
setTimeout(verifyEvaluation, 600);
|
||||
}
|
||||
});
|
||||
|
@ -913,34 +913,34 @@ test("serialize()", function() {
|
|||
|
||||
// Add html5 elements only for serialize because selector can't yet find them on non-html5 browsers
|
||||
jQuery("#search").after(
|
||||
'<input type="email" id="html5email" name="email" value="dave@jquery.com" />'+
|
||||
'<input type="number" id="html5number" name="number" value="43" />'
|
||||
"<input type='email' id='html5email' name='email' value='dave@jquery.com' />"+
|
||||
"<input type='number' id='html5number' name='number' value='43' />"
|
||||
);
|
||||
|
||||
equals( jQuery('#form').serialize(),
|
||||
equals( jQuery("#form").serialize(),
|
||||
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&select5=3",
|
||||
'Check form serialization as query string');
|
||||
"Check form serialization as query string");
|
||||
|
||||
equals( jQuery('#form :input').serialize(),
|
||||
equals( jQuery("#form :input").serialize(),
|
||||
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&select5=3",
|
||||
'Check input serialization as query string');
|
||||
"Check input serialization as query string");
|
||||
|
||||
equals( jQuery('#testForm').serialize(),
|
||||
'T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=',
|
||||
'Check form serialization as query string');
|
||||
equals( jQuery("#testForm").serialize(),
|
||||
"T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
|
||||
"Check form serialization as query string");
|
||||
|
||||
equals( jQuery('#testForm :input').serialize(),
|
||||
'T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=',
|
||||
'Check input serialization as query string');
|
||||
equals( jQuery("#testForm :input").serialize(),
|
||||
"T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
|
||||
"Check input serialization as query string");
|
||||
|
||||
equals( jQuery('#form, #testForm').serialize(),
|
||||
equals( jQuery("#form, #testForm").serialize(),
|
||||
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&select5=3&T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
|
||||
'Multiple form serialization as query string');
|
||||
"Multiple form serialization as query string");
|
||||
|
||||
/* Temporarily disabled. Opera 10 has problems with form serialization.
|
||||
equals( jQuery('#form, #testForm :input').serialize(),
|
||||
equals( jQuery("#form, #testForm :input").serialize(),
|
||||
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
|
||||
'Mixed form/input serialization as query string');
|
||||
"Mixed form/input serialization as query string");
|
||||
*/
|
||||
jQuery("#html5email, #html5number").remove();
|
||||
});
|
||||
|
@ -956,13 +956,13 @@ test("jQuery.param()", function() {
|
|||
params = {someName: [1, 2, 3], regularThing: "blah" };
|
||||
equals( jQuery.param(params), "someName%5B%5D=1&someName%5B%5D=2&someName%5B%5D=3®ularThing=blah", "with array" );
|
||||
|
||||
params = {foo: ['a', 'b', 'c']};
|
||||
params = {foo: ["a", "b", "c"]};
|
||||
equals( jQuery.param(params), "foo%5B%5D=a&foo%5B%5D=b&foo%5B%5D=c", "with array of strings" );
|
||||
|
||||
params = {foo: ["baz", 42, "All your base are belong to us"] };
|
||||
equals( jQuery.param(params), "foo%5B%5D=baz&foo%5B%5D=42&foo%5B%5D=All+your+base+are+belong+to+us", "more array" );
|
||||
|
||||
params = {foo: { bar: 'baz', beep: 42, quux: 'All your base are belong to us' } };
|
||||
params = {foo: { bar: "baz", beep: 42, quux: "All your base are belong to us" } };
|
||||
equals( jQuery.param(params), "foo%5Bbar%5D=baz&foo%5Bbeep%5D=42&foo%5Bquux%5D=All+your+base+are+belong+to+us", "even more arrays" );
|
||||
|
||||
params = { a:[1,2], b:{ c:3, d:[4,5], e:{ x:[6], y:7, z:[8,9] }, f:true, g:false, h:undefined }, i:[10,11], j:true, k:false, l:[undefined,0], m:"cowboy hat?" };
|
||||
|
@ -974,7 +974,7 @@ test("jQuery.param()", function() {
|
|||
params = { a:[1,2], b:{ c:3, d:[4,5], e:{ x:[6], y:7, z:[8,9] }, f:true, g:false, h:undefined }, i:[10,11], j:true, k:false, l:[undefined,0], m:"cowboy hat?" };
|
||||
equals( jQuery.param(params,true), "a=1&a=2&b=%5Bobject+Object%5D&i=10&i=11&j=true&k=false&l=undefined&l=0&m=cowboy+hat%3F", "huge structure, forced traditional" );
|
||||
|
||||
equals( decodeURIComponent( jQuery.param({ a: [1,2,3], 'b[]': [4,5,6], 'c[d]': [7,8,9], e: { f: [10], g: [11,12], h: 13 } }) ), "a[]=1&a[]=2&a[]=3&b[]=4&b[]=5&b[]=6&c[d][]=7&c[d][]=8&c[d][]=9&e[f][]=10&e[g][]=11&e[g][]=12&e[h]=13", "Make sure params are not double-encoded." );
|
||||
equals( decodeURIComponent( jQuery.param({ a: [1,2,3], "b[]": [4,5,6], "c[d]": [7,8,9], e: { f: [10], g: [11,12], h: 13 } }) ), "a[]=1&a[]=2&a[]=3&b[]=4&b[]=5&b[]=6&c[d][]=7&c[d][]=8&c[d][]=9&e[f][]=10&e[g][]=11&e[g][]=12&e[h]=13", "Make sure params are not double-encoded." );
|
||||
|
||||
// Make sure empty arrays and objects are handled #6481
|
||||
equals( jQuery.param({"foo": {"bar": []} }), "foo%5Bbar%5D=", "Empty array param" );
|
||||
|
@ -992,7 +992,7 @@ test("jQuery.param()", function() {
|
|||
params = {someName: [1, 2, 3], regularThing: "blah" };
|
||||
equals( jQuery.param(params), "someName=1&someName=2&someName=3®ularThing=blah", "with array" );
|
||||
|
||||
params = {foo: ['a', 'b', 'c']};
|
||||
params = {foo: ["a", "b", "c"]};
|
||||
equals( jQuery.param(params), "foo=a&foo=b&foo=c", "with array of strings" );
|
||||
|
||||
params = {"foo[]":["baz", 42, "All your base are belong to us"]};
|
||||
|
@ -1013,7 +1013,7 @@ test("jQuery.param()", function() {
|
|||
params = { param1: null };
|
||||
equals( jQuery.param(params,false), "param1=null", "Make sure that null params aren't traversed." );
|
||||
|
||||
params = {'test': {'length': 3, 'foo': 'bar'} };
|
||||
params = {"test": {"length": 3, "foo": "bar"} };
|
||||
equals( jQuery.param( params, false ), "test%5Blength%5D=3&test%5Bfoo%5D=bar", "Sub-object with a length property" );
|
||||
});
|
||||
|
||||
|
@ -1044,10 +1044,10 @@ test("pass-through request object", function() {
|
|||
errorCount++;
|
||||
errorEx += ": " + xml.status;
|
||||
});
|
||||
jQuery("#foo").one('ajaxStop', function () {
|
||||
jQuery("#foo").one("ajaxStop", function () {
|
||||
equals(successCount, 5, "Check all ajax calls successful");
|
||||
equals(errorCount, 0, "Check no ajax errors (status" + errorEx + ")");
|
||||
jQuery("#foo").unbind('ajaxError');
|
||||
jQuery("#foo").unbind("ajaxError");
|
||||
|
||||
start();
|
||||
});
|
||||
|
@ -1101,17 +1101,17 @@ test("global ajaxSettings", function() {
|
|||
var orig = { url: "data/with_fries.xml" };
|
||||
var t;
|
||||
|
||||
jQuery.ajaxSetup({ data: {foo: 'bar', bar: 'BAR'} });
|
||||
jQuery.ajaxSetup({ data: {foo: "bar", bar: "BAR"} });
|
||||
|
||||
t = jQuery.extend({}, orig);
|
||||
t.data = {};
|
||||
jQuery.ajax(t);
|
||||
ok( t.url.indexOf('foo') > -1 && t.url.indexOf('bar') > -1, "Check extending {}" );
|
||||
ok( t.url.indexOf("foo") > -1 && t.url.indexOf("bar") > -1, "Check extending {}" );
|
||||
|
||||
t = jQuery.extend({}, orig);
|
||||
t.data = { zoo: 'a', ping: 'b' };
|
||||
t.data = { zoo: "a", ping: "b" };
|
||||
jQuery.ajax(t);
|
||||
ok( t.url.indexOf('ping') > -1 && t.url.indexOf('zoo') > -1 && t.url.indexOf('foo') > -1 && t.url.indexOf('bar') > -1, "Check extending { zoo: 'a', ping: 'b' }" );
|
||||
ok( t.url.indexOf("ping") > -1 && t.url.indexOf("zoo") > -1 && t.url.indexOf("foo") > -1 && t.url.indexOf("bar") > -1, "Check extending { zoo: "a", ping: "b" }" );
|
||||
|
||||
jQuery.ajaxSettings = tmp;
|
||||
});
|
||||
|
@ -1120,13 +1120,13 @@ test("global ajaxSettings", function() {
|
|||
test("load(String)", function() {
|
||||
expect(1);
|
||||
stop(); // check if load can be called with only url
|
||||
jQuery('#first').load("data/name.html", start);
|
||||
jQuery("#first").load("data/name.html", start);
|
||||
});
|
||||
|
||||
test("load('url selector')", function() {
|
||||
expect(1);
|
||||
stop(); // check if load can be called with only url
|
||||
jQuery('#first').load("data/test3.html div.user", function(){
|
||||
jQuery("#first").load("data/test3.html div.user", function(){
|
||||
equals( jQuery(this).children("div").length, 2, "Verify that specific elements were injected" );
|
||||
start();
|
||||
});
|
||||
|
@ -1142,14 +1142,14 @@ test("load(String, Function) with ajaxSetup on dataType json, see #2046", functi
|
|||
jQuery.ajaxSetup({ dataType: "" });
|
||||
start();
|
||||
});
|
||||
jQuery('#first').load("data/test3.html");
|
||||
jQuery("#first").load("data/test3.html");
|
||||
});
|
||||
|
||||
test("load(String, Function) - simple: inject text into DOM", function() {
|
||||
expect(2);
|
||||
stop();
|
||||
jQuery('#first').load(url("data/name.html"), function() {
|
||||
ok( /^ERROR/.test(jQuery('#first').text()), 'Check if content was injected into the DOM' );
|
||||
jQuery("#first").load(url("data/name.html"), function() {
|
||||
ok( /^ERROR/.test(jQuery("#first").text()), "Check if content was injected into the DOM" );
|
||||
start();
|
||||
});
|
||||
});
|
||||
|
@ -1159,15 +1159,15 @@ test("load(String, Function) - check scripts", function() {
|
|||
stop();
|
||||
|
||||
var verifyEvaluation = function() {
|
||||
equals( foobar, "bar", 'Check if script src was evaluated after load' );
|
||||
equals( jQuery('#ap').html(), 'bar', 'Check if script evaluation has modified DOM');
|
||||
equals( foobar, "bar", "Check if script src was evaluated after load" );
|
||||
equals( jQuery("#ap").html(), "bar", "Check if script evaluation has modified DOM");
|
||||
|
||||
start();
|
||||
};
|
||||
jQuery('#first').load(url('data/test.html'), function() {
|
||||
ok( jQuery('#first').html().match(/^html text/), 'Check content after loading html' );
|
||||
equals( jQuery('#foo').html(), 'foo', 'Check if script evaluation has modified DOM');
|
||||
equals( testFoo, "foo", 'Check if script was evaluated after load' );
|
||||
jQuery("#first").load(url("data/test.html"), function() {
|
||||
ok( jQuery("#first").html().match(/^html text/), "Check content after loading html" );
|
||||
equals( jQuery("#foo").html(), "foo", "Check if script evaluation has modified DOM");
|
||||
equals( testFoo, "foo", "Check if script was evaluated after load" );
|
||||
setTimeout(verifyEvaluation, 600);
|
||||
});
|
||||
});
|
||||
|
@ -1176,9 +1176,9 @@ test("load(String, Function) - check file with only a script tag", function() {
|
|||
expect(3);
|
||||
stop();
|
||||
|
||||
jQuery('#first').load(url('data/test2.html'), function() {
|
||||
equals( jQuery('#foo').html(), 'foo', 'Check if script evaluation has modified DOM');
|
||||
equals( testFoo, "foo", 'Check if script was evaluated after load' );
|
||||
jQuery("#first").load(url("data/test2.html"), function() {
|
||||
equals( jQuery("#foo").html(), "foo", "Check if script evaluation has modified DOM");
|
||||
equals( testFoo, "foo", "Check if script was evaluated after load" );
|
||||
|
||||
start();
|
||||
});
|
||||
|
@ -1200,10 +1200,10 @@ test("load(String, Object, Function)", function() {
|
|||
expect(2);
|
||||
stop();
|
||||
|
||||
jQuery('<div />').load(url('data/params_html.php'), { foo:3, bar:'ok' }, function() {
|
||||
var $post = jQuery(this).find('#post');
|
||||
equals( $post.find('#foo').text(), '3', 'Check if a hash of data is passed correctly');
|
||||
equals( $post.find('#bar').text(), 'ok', 'Check if a hash of data is passed correctly');
|
||||
jQuery("<div />").load(url("data/params_html.php"), { foo: 3, bar: "ok" }, function() {
|
||||
var $post = jQuery(this).find("#post");
|
||||
equals( $post.find("#foo").text(), "3", "Check if a hash of data is passed correctly");
|
||||
equals( $post.find("#bar").text(), "ok", "Check if a hash of data is passed correctly");
|
||||
start();
|
||||
});
|
||||
});
|
||||
|
@ -1212,10 +1212,10 @@ test("load(String, String, Function)", function() {
|
|||
expect(2);
|
||||
stop();
|
||||
|
||||
jQuery('<div />').load(url('data/params_html.php'), 'foo=3&bar=ok', function() {
|
||||
var $get = jQuery(this).find('#get');
|
||||
equals( $get.find('#foo').text(), '3', 'Check if a string of data is passed correctly');
|
||||
equals( $get.find('#bar').text(), 'ok', 'Check if a of data is passed correctly');
|
||||
jQuery("<div />").load(url("data/params_html.php"), "foo=3&bar=ok", function() {
|
||||
var $get = jQuery(this).find("#get");
|
||||
equals( $get.find("#foo").text(), "3", "Check if a string of data is passed correctly");
|
||||
equals( $get.find("#bar").text(), "ok", "Check if a of data is passed correctly");
|
||||
start();
|
||||
});
|
||||
});
|
||||
|
@ -1226,8 +1226,8 @@ test("jQuery.get(String, Function) - data in ajaxSettings (#8277)", function() {
|
|||
jQuery.ajaxSetup({
|
||||
data: "helloworld"
|
||||
});
|
||||
jQuery.get(url('data/echoQuery.php'), function(data) {
|
||||
ok( /helloworld$/.test( data ), 'Data from ajaxSettings was used');
|
||||
jQuery.get(url("data/echoQuery.php"), function(data) {
|
||||
ok( /helloworld$/.test( data ), "Data from ajaxSettings was used");
|
||||
jQuery.ajaxSetup({
|
||||
data: null
|
||||
});
|
||||
|
@ -1238,13 +1238,13 @@ test("jQuery.get(String, Function) - data in ajaxSettings (#8277)", function() {
|
|||
test("jQuery.get(String, Hash, Function) - parse xml and use text() on nodes", function() {
|
||||
expect(2);
|
||||
stop();
|
||||
jQuery.get(url('data/dashboard.xml'), function(xml) {
|
||||
jQuery.get(url("data/dashboard.xml"), function(xml) {
|
||||
var content = [];
|
||||
jQuery('tab', xml).each(function() {
|
||||
jQuery("tab", xml).each(function() {
|
||||
content.push(jQuery(this).text());
|
||||
});
|
||||
equals( content[0], 'blabla', 'Check first tab');
|
||||
equals( content[1], 'blublu', 'Check second tab');
|
||||
equals( content[0], "blabla", "Check first tab");
|
||||
equals( content[1], "blublu", "Check second tab");
|
||||
start();
|
||||
});
|
||||
});
|
||||
|
@ -1253,7 +1253,7 @@ test("jQuery.getScript(String, Function) - with callback", function() {
|
|||
expect(3);
|
||||
stop();
|
||||
jQuery.getScript(url("data/test.js"), function( data, _, jqXHR ) {
|
||||
equals( foobar, "bar", 'Check if script was evaluated' );
|
||||
equals( foobar, "bar", "Check if script was evaluated" );
|
||||
strictEqual( data, jqXHR.responseText, "Same-domain script requests returns the source of the script (#8082)" );
|
||||
setTimeout(start, 100);
|
||||
});
|
||||
|
@ -1636,10 +1636,10 @@ test("jQuery.ajax() - json by content-type", function() {
|
|||
data: { header: "json", json: "array" },
|
||||
success: function( json ) {
|
||||
ok( json.length >= 2, "Check length");
|
||||
equals( json[0].name, 'John', 'Check JSON: first, name' );
|
||||
equals( json[0].age, 21, 'Check JSON: first, age' );
|
||||
equals( json[1].name, 'Peter', 'Check JSON: second, name' );
|
||||
equals( json[1].age, 25, 'Check JSON: second, age' );
|
||||
equals( json[0].name, "John", "Check JSON: first, name" );
|
||||
equals( json[0].age, 21, "Check JSON: first, age" );
|
||||
equals( json[1].name, "Peter", "Check JSON: second, name" );
|
||||
equals( json[1].age, 25, "Check JSON: second, age" );
|
||||
start();
|
||||
}
|
||||
});
|
||||
|
@ -1660,10 +1660,10 @@ test("jQuery.ajax() - json by content-type disabled with options", function() {
|
|||
equals( typeof text , "string" , "json wasn't auto-determined" );
|
||||
var json = jQuery.parseJSON( text );
|
||||
ok( json.length >= 2, "Check length");
|
||||
equals( json[0].name, 'John', 'Check JSON: first, name' );
|
||||
equals( json[0].age, 21, 'Check JSON: first, age' );
|
||||
equals( json[1].name, 'Peter', 'Check JSON: second, name' );
|
||||
equals( json[1].age, 25, 'Check JSON: second, age' );
|
||||
equals( json[0].name, "John", "Check JSON: first, name" );
|
||||
equals( json[0].age, 21, "Check JSON: first, age" );
|
||||
equals( json[1].name, "Peter", "Check JSON: second, name" );
|
||||
equals( json[1].age, 25, "Check JSON: second, age" );
|
||||
start();
|
||||
}
|
||||
});
|
||||
|
@ -1674,10 +1674,10 @@ test("jQuery.getJSON(String, Hash, Function) - JSON array", function() {
|
|||
stop();
|
||||
jQuery.getJSON(url("data/json.php"), {json: "array"}, function(json) {
|
||||
ok( json.length >= 2, "Check length");
|
||||
equals( json[0].name, 'John', 'Check JSON: first, name' );
|
||||
equals( json[0].age, 21, 'Check JSON: first, age' );
|
||||
equals( json[1].name, 'Peter', 'Check JSON: second, name' );
|
||||
equals( json[1].age, 25, 'Check JSON: second, age' );
|
||||
equals( json[0].name, "John", "Check JSON: first, name" );
|
||||
equals( json[0].age, 21, "Check JSON: first, age" );
|
||||
equals( json[1].name, "Peter", "Check JSON: second, name" );
|
||||
equals( json[1].age, 25, "Check JSON: second, age" );
|
||||
start();
|
||||
});
|
||||
});
|
||||
|
@ -1687,8 +1687,8 @@ test("jQuery.getJSON(String, Function) - JSON object", function() {
|
|||
stop();
|
||||
jQuery.getJSON(url("data/json.php"), function(json) {
|
||||
if (json && json.data) {
|
||||
equals( json.data.lang, 'en', 'Check JSON: lang' );
|
||||
equals( json.data.length, 25, 'Check JSON: length' );
|
||||
equals( json.data.lang, "en", "Check JSON: lang" );
|
||||
equals( json.data.length, 25, "Check JSON: length" );
|
||||
}
|
||||
start();
|
||||
});
|
||||
|
@ -1720,8 +1720,8 @@ test("jQuery.getJSON(String, Function) - JSON object with absolute url to local
|
|||
|
||||
stop();
|
||||
jQuery.getJSON(url(base + "data/json.php"), function(json) {
|
||||
equals( json.data.lang, 'en', 'Check JSON: lang' );
|
||||
equals( json.data.length, 25, 'Check JSON: length' );
|
||||
equals( json.data.lang, "en", "Check JSON: lang" );
|
||||
equals( json.data.length, 25, "Check JSON: length" );
|
||||
start();
|
||||
});
|
||||
});
|
||||
|
@ -1731,23 +1731,23 @@ test("jQuery.post - data", 3, function() {
|
|||
|
||||
jQuery.when(
|
||||
jQuery.post( url( "data/name.php" ), { xml: "5-2", length: 3 }, function( xml ) {
|
||||
jQuery( 'math', xml ).each( function() {
|
||||
equals( jQuery( 'calculation', this ).text(), '5-2', 'Check for XML' );
|
||||
equals( jQuery( 'result', this ).text(), '3', 'Check for XML' );
|
||||
jQuery( "math", xml ).each( function() {
|
||||
equals( jQuery( "calculation", this ).text(), "5-2", "Check for XML" );
|
||||
equals( jQuery( "result", this ).text(), "3", "Check for XML" );
|
||||
});
|
||||
}),
|
||||
|
||||
jQuery.ajax({
|
||||
url: url('data/echoData.php'),
|
||||
url: url("data/echoData.php"),
|
||||
type: "POST",
|
||||
data: {
|
||||
'test': {
|
||||
'length': 7,
|
||||
'foo': 'bar'
|
||||
"test": {
|
||||
"length": 7,
|
||||
"foo": "bar"
|
||||
}
|
||||
},
|
||||
success: function( data ) {
|
||||
strictEqual( data, 'test%5Blength%5D=7&test%5Bfoo%5D=bar', 'Check if a sub-object with a length param is serialized correctly');
|
||||
strictEqual( data, "test%5Blength%5D=7&test%5Bfoo%5D=bar", "Check if a sub-object with a length param is serialized correctly");
|
||||
}
|
||||
})
|
||||
).then( start, start );
|
||||
|
@ -1760,17 +1760,17 @@ test("jQuery.post(String, Hash, Function) - simple with xml", function() {
|
|||
var done = 0;
|
||||
|
||||
jQuery.post(url("data/name.php"), {xml: "5-2"}, function(xml){
|
||||
jQuery('math', xml).each(function() {
|
||||
equals( jQuery('calculation', this).text(), '5-2', 'Check for XML' );
|
||||
equals( jQuery('result', this).text(), '3', 'Check for XML' );
|
||||
jQuery("math", xml).each(function() {
|
||||
equals( jQuery("calculation", this).text(), "5-2", "Check for XML" );
|
||||
equals( jQuery("result", this).text(), "3", "Check for XML" );
|
||||
});
|
||||
if ( ++done === 2 ) start();
|
||||
});
|
||||
|
||||
jQuery.post(url("data/name.php?xml=5-2"), {}, function(xml){
|
||||
jQuery('math', xml).each(function() {
|
||||
equals( jQuery('calculation', this).text(), '5-2', 'Check for XML' );
|
||||
equals( jQuery('result', this).text(), '3', 'Check for XML' );
|
||||
jQuery("math", xml).each(function() {
|
||||
equals( jQuery("calculation", this).text(), "5-2", "Check for XML" );
|
||||
equals( jQuery("result", this).text(), "3", "Check for XML" );
|
||||
});
|
||||
if ( ++done === 2 ) start();
|
||||
});
|
||||
|
@ -1786,18 +1786,18 @@ test("jQuery.ajaxSetup({timeout: Number}) - with global timeout", function() {
|
|||
var pass = function() {
|
||||
passed++;
|
||||
if ( passed == 2 ) {
|
||||
ok( true, 'Check local and global callbacks after timeout' );
|
||||
jQuery('#main').unbind("ajaxError");
|
||||
ok( true, "Check local and global callbacks after timeout" );
|
||||
jQuery("#main").unbind("ajaxError");
|
||||
start();
|
||||
}
|
||||
};
|
||||
|
||||
var fail = function(a,b,c) {
|
||||
ok( false, 'Check for timeout failed ' + a + ' ' + b );
|
||||
ok( false, "Check for timeout failed " + a + " " + b );
|
||||
start();
|
||||
};
|
||||
|
||||
jQuery('#main').ajaxError(pass);
|
||||
jQuery("#main").ajaxError(pass);
|
||||
|
||||
jQuery.ajax({
|
||||
type: "GET",
|
||||
|
@ -1819,11 +1819,11 @@ test("jQuery.ajaxSetup({timeout: Number}) with localtimeout", function() {
|
|||
timeout: 15000,
|
||||
url: url("data/name.php?wait=1"),
|
||||
error: function() {
|
||||
ok( false, 'Check for local timeout failed' );
|
||||
ok( false, "Check for local timeout failed" );
|
||||
start();
|
||||
},
|
||||
success: function() {
|
||||
ok( true, 'Check for local timeout' );
|
||||
ok( true, "Check for local timeout" );
|
||||
start();
|
||||
}
|
||||
});
|
||||
|
@ -1839,7 +1839,7 @@ test("jQuery.ajax - simple get", function() {
|
|||
type: "GET",
|
||||
url: url("data/name.php?name=foo"),
|
||||
success: function(msg){
|
||||
equals( msg, 'bar', 'Check for GET' );
|
||||
equals( msg, "bar", "Check for GET" );
|
||||
start();
|
||||
}
|
||||
});
|
||||
|
@ -1853,7 +1853,7 @@ test("jQuery.ajax - simple post", function() {
|
|||
url: url("data/name.php"),
|
||||
data: "name=peter",
|
||||
success: function(msg){
|
||||
equals( msg, 'pan', 'Check for POST' );
|
||||
equals( msg, "pan", "Check for POST" );
|
||||
start();
|
||||
}
|
||||
});
|
||||
|
@ -1865,7 +1865,7 @@ test("ajaxSetup()", function() {
|
|||
jQuery.ajaxSetup({
|
||||
url: url("data/name.php?name=foo"),
|
||||
success: function(msg){
|
||||
equals( msg, 'bar', 'Check for GET' );
|
||||
equals( msg, "bar", "Check for GET" );
|
||||
start();
|
||||
}
|
||||
});
|
||||
|
@ -2027,14 +2027,14 @@ test("jQuery ajax - failing cross-domain", function() {
|
|||
var i = 2;
|
||||
|
||||
jQuery.ajax({
|
||||
url: 'http://somewebsitethatdoesnotexist-67864863574657654.com',
|
||||
url: "http://somewebsitethatdoesnotexist-67864863574657654.com",
|
||||
success: function(){ ok( false , "success" ); },
|
||||
error: function(xhr,_,e){ ok( true , "file not found: " + xhr.status + " => " + e ); },
|
||||
complete: function() { if ( ! --i ) start(); }
|
||||
});
|
||||
|
||||
jQuery.ajax({
|
||||
url: 'http://www.google.com',
|
||||
url: "http://www.google.com",
|
||||
success: function(){ ok( false , "success" ); },
|
||||
error: function(xhr,_,e){ ok( true , "access denied: " + xhr.status + " => " + e ); },
|
||||
complete: function() { if ( ! --i ) start(); }
|
||||
|
@ -2047,7 +2047,7 @@ test("jQuery ajax - atom+xml", function() {
|
|||
stop();
|
||||
|
||||
jQuery.ajax({
|
||||
url: url( 'data/atom+xml.php' ),
|
||||
url: url( "data/atom+xml.php" ),
|
||||
success: function(){ ok( true , "success" ); },
|
||||
error: function(){ ok( false , "error" ); },
|
||||
complete: function() { start(); }
|
||||
|
|
|
@ -37,19 +37,19 @@ test("jQuery.attrFix integrity test", function() {
|
|||
|
||||
test("prop(String, Object)", function() {
|
||||
expect(19);
|
||||
equals( jQuery('#text1').prop('value'), "Test", 'Check for value attribute' );
|
||||
equals( jQuery('#text1').prop('value', "Test2").prop('defaultValue'), "Test", 'Check for defaultValue attribute' );
|
||||
equals( jQuery('#select2').prop('selectedIndex'), 3, 'Check for selectedIndex attribute' );
|
||||
equals( jQuery('#foo').prop('nodeName').toUpperCase(), 'DIV', 'Check for nodeName attribute' );
|
||||
equals( jQuery('#foo').prop('tagName').toUpperCase(), 'DIV', 'Check for tagName attribute' );
|
||||
equals( jQuery("#text1").prop("value"), "Test", "Check for value attribute" );
|
||||
equals( jQuery("#text1").prop("value", "Test2").prop("defaultValue"), "Test", "Check for defaultValue attribute" );
|
||||
equals( jQuery("#select2").prop("selectedIndex"), 3, "Check for selectedIndex attribute" );
|
||||
equals( jQuery("#foo").prop("nodeName").toUpperCase(), "DIV", "Check for nodeName attribute" );
|
||||
equals( jQuery("#foo").prop("tagName").toUpperCase(), "DIV", "Check for tagName attribute" );
|
||||
equals( jQuery("<option/>").prop("selected"), false, "Check selected attribute on disconnected element." );
|
||||
|
||||
var body = document.body, $body = jQuery( body );
|
||||
ok( $body.prop('nextSibling') === null, 'Make sure a null expando returns null' );
|
||||
body.foo = 'bar';
|
||||
equals( $body.prop('foo'), 'bar', 'Make sure the expando is preferred over the dom attribute' );
|
||||
ok( $body.prop("nextSibling") === null, "Make sure a null expando returns null" );
|
||||
body.foo = "bar";
|
||||
equals( $body.prop("foo"), "bar", "Make sure the expando is preferred over the dom attribute" );
|
||||
body.foo = undefined;
|
||||
ok( $body.prop('foo') === undefined, 'Make sure the expando is preferred over the dom attribute, even if undefined' );
|
||||
ok( $body.prop("foo") === undefined, "Make sure the expando is preferred over the dom attribute, even if undefined" );
|
||||
|
||||
var select = document.createElement("select"), optgroup = document.createElement("optgroup"), option = document.createElement("option");
|
||||
optgroup.appendChild( option );
|
||||
|
@ -78,62 +78,62 @@ test("prop(String, Object)", function() {
|
|||
test("attr(String)", function() {
|
||||
expect(32);
|
||||
|
||||
equals( jQuery('#text1').attr('type'), "text", 'Check for type attribute' );
|
||||
equals( jQuery('#radio1').attr('type'), "radio", 'Check for type attribute' );
|
||||
equals( jQuery('#check1').attr('type'), "checkbox", 'Check for type attribute' );
|
||||
equals( jQuery('#simon1').attr('rel'), "bookmark", 'Check for rel attribute' );
|
||||
equals( jQuery('#google').attr('title'), "Google!", 'Check for title attribute' );
|
||||
equals( jQuery('#mark').attr('hreflang'), "en", 'Check for hreflang attribute' );
|
||||
equals( jQuery('#en').attr('lang'), "en", 'Check for lang attribute' );
|
||||
equals( jQuery('#simon').attr('class'), "blog link", 'Check for class attribute' );
|
||||
equals( jQuery('#name').attr('name'), "name", 'Check for name attribute' );
|
||||
equals( jQuery('#text1').attr('name'), "action", 'Check for name attribute' );
|
||||
ok( jQuery('#form').attr('action').indexOf("formaction") >= 0, 'Check for action attribute' );
|
||||
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' );
|
||||
equals( jQuery("#text1").attr("type"), "text", "Check for type attribute" );
|
||||
equals( jQuery("#radio1").attr("type"), "radio", "Check for type attribute" );
|
||||
equals( jQuery("#check1").attr("type"), "checkbox", "Check for type attribute" );
|
||||
equals( jQuery("#simon1").attr("rel"), "bookmark", "Check for rel attribute" );
|
||||
equals( jQuery("#google").attr("title"), "Google!", "Check for title attribute" );
|
||||
equals( jQuery("#mark").attr("hreflang"), "en", "Check for hreflang attribute" );
|
||||
equals( jQuery("#en").attr("lang"), "en", "Check for lang attribute" );
|
||||
equals( jQuery("#simon").attr("class"), "blog link", "Check for class attribute" );
|
||||
equals( jQuery("#name").attr("name"), "name", "Check for name attribute" );
|
||||
equals( jQuery("#text1").attr("name"), "action", "Check for name attribute" );
|
||||
ok( jQuery("#form").attr("action").indexOf("formaction") >= 0, "Check for action attribute" );
|
||||
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('<input name="id" name="name" /><input id="target" name="target" />').appendTo('#testForm');
|
||||
equals( jQuery('#form').attr('action','newformaction').attr('action'), 'newformaction', 'Check that action attribute was changed' );
|
||||
equals( jQuery('#testForm').attr('target'), undefined, 'Retrieving target does not equal the input with name=target' );
|
||||
equals( jQuery('#testForm').attr('target', 'newTarget').attr('target'), 'newTarget', 'Set target successfully on a form' );
|
||||
equals( jQuery('#testForm').removeAttr('id').attr('id'), undefined, 'Retrieving id does not equal the input with name=id after id is removed [#7472]' );
|
||||
var extras = jQuery("<input name='id' name='name' /><input id='target' name='target' />").appendTo("#testForm");
|
||||
equals( jQuery("#form").attr("action","newformaction").attr("action"), "newformaction", "Check that action attribute was changed" );
|
||||
equals( jQuery("#testForm").attr("target"), undefined, "Retrieving target does not equal the input with name=target" );
|
||||
equals( jQuery("#testForm").attr("target", "newTarget").attr("target"), "newTarget", "Set target successfully on a form" );
|
||||
equals( jQuery("#testForm").removeAttr("id").attr("id"), undefined, "Retrieving id does not equal the input with name=id after id is removed [#7472]" );
|
||||
// Bug #3685 (form contains input with name="name")
|
||||
equals( jQuery('#testForm').attr('name'), undefined, 'Retrieving name does not retrieve 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' );
|
||||
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" );
|
||||
|
||||
// using innerHTML in IE causes href attribute to be serialized to the full path
|
||||
jQuery('<a/>').attr({ 'id': 'tAnchor5', 'href': '#5' }).appendTo('#main');
|
||||
equals( jQuery('#tAnchor5').attr('href'), "#5", 'Check for non-absolute href (an anchor)' );
|
||||
jQuery("<a/>").attr({ "id": "tAnchor5", "href": "#5" }).appendTo("#main");
|
||||
equals( jQuery("#tAnchor5").attr("href"), "#5", "Check for non-absolute href (an anchor)" );
|
||||
|
||||
// list attribute is readonly by default in browsers that support it
|
||||
jQuery('#list-test').attr('list', 'datalist');
|
||||
equals( jQuery('#list-test').attr('list'), 'datalist', 'Check setting list attribute' );
|
||||
jQuery("#list-test").attr("list", "datalist");
|
||||
equals( jQuery("#list-test").attr("list"), "datalist", "Check setting list attribute" );
|
||||
|
||||
// Related to [5574] and [5683]
|
||||
var body = document.body, $body = jQuery(body);
|
||||
|
||||
strictEqual( $body.attr('foo'), undefined, 'Make sure that a non existent attribute returns undefined' );
|
||||
strictEqual( $body.attr("foo"), undefined, "Make sure that a non existent attribute returns undefined" );
|
||||
|
||||
body.setAttribute('foo', 'baz');
|
||||
equals( $body.attr('foo'), 'baz', 'Make sure the dom attribute is retrieved when no expando is found' );
|
||||
body.setAttribute("foo", "baz");
|
||||
equals( $body.attr("foo"), "baz", "Make sure the dom attribute is retrieved when no expando is found" );
|
||||
|
||||
$body.attr('foo','cool');
|
||||
equals( $body.attr('foo'), 'cool', 'Make sure that setting works well when both expando and dom attribute are available' );
|
||||
$body.attr("foo","cool");
|
||||
equals( $body.attr("foo"), "cool", "Make sure that setting works well when both expando and dom attribute are available" );
|
||||
|
||||
body.removeAttribute('foo'); // Cleanup
|
||||
body.removeAttribute("foo"); // Cleanup
|
||||
|
||||
var $img = jQuery('<img style="display:none" width="215" height="53" src="http://static.jquery.com/files/rocker/images/logo_jquery_215x53.gif"/>').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." );
|
||||
var $img = jQuery("<img style='display:none' width='215' height='53' src='http://static.jquery.com/files/rocker/images/logo_jquery_215x53.gif'/>").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." );
|
||||
|
||||
// Check for style support
|
||||
ok( !!~jQuery('#dl').attr('style').indexOf('position'), 'Check style attribute getter, also normalize css props to lowercase' );
|
||||
ok( !!~jQuery('#foo').attr('style', 'position:absolute;').attr('style').indexOf('position'), 'Check style setter' );
|
||||
ok( !!~jQuery("#dl").attr("style").indexOf("position"), "Check style attribute getter, also normalize css props to lowercase" );
|
||||
ok( !!~jQuery("#foo").attr("style", "position:absolute;").attr("style").indexOf("position"), "Check style setter" );
|
||||
|
||||
ok( jQuery("<div/>").attr("doesntexist") === undefined, "Make sure undefined is returned when no attribute is found." );
|
||||
ok( jQuery().attr("doesntexist") === undefined, "Make sure undefined is returned when no element is there." );
|
||||
|
@ -153,19 +153,19 @@ if ( !isLocal ) {
|
|||
|
||||
test("attr(String, Function)", function() {
|
||||
expect(2);
|
||||
equals( jQuery('#text1').attr('value', function() { return this.id; })[0].value, "text1", "Set value from id" );
|
||||
equals( jQuery('#text1').attr('title', function(i) { return i; }).attr('title'), "0", "Set value with an index");
|
||||
equals( jQuery("#text1").attr("value", function() { return this.id; })[0].value, "text1", "Set value from id" );
|
||||
equals( jQuery("#text1").attr("title", function(i) { return i; }).attr("title"), "0", "Set value with an index");
|
||||
});
|
||||
|
||||
test("attr(Hash)", function() {
|
||||
expect(3);
|
||||
var pass = true;
|
||||
jQuery("div").attr({foo: 'baz', zoo: 'ping'}).each(function(){
|
||||
if ( this.getAttribute('foo') != "baz" && this.getAttribute('zoo') != "ping" ) pass = false;
|
||||
jQuery("div").attr({foo: "baz", zoo: "ping"}).each(function(){
|
||||
if ( this.getAttribute("foo") != "baz" && this.getAttribute("zoo") != "ping" ) pass = false;
|
||||
});
|
||||
ok( pass, "Set Multiple Attributes" );
|
||||
equals( jQuery('#text1').attr({'value': function() { return this.id; }})[0].value, "text1", "Set attribute to computed value #1" );
|
||||
equals( jQuery('#text1').attr({'title': function(i) { return i; }}).attr('title'), "0", "Set attribute to computed value #2");
|
||||
equals( jQuery("#text1").attr({value: function() { return this.id; }})[0].value, "text1", "Set attribute to computed value #1" );
|
||||
equals( jQuery("#text1").attr({title: function(i) { return i; }}).attr("title"), "0", "Set attribute to computed value #2");
|
||||
|
||||
});
|
||||
|
||||
|
@ -176,7 +176,7 @@ test("attr(String, Object)", function() {
|
|||
fail = false;
|
||||
|
||||
for ( var i = 0; i < div.size(); i++ ) {
|
||||
if ( div.get(i).getAttribute('foo') != "bar" ){
|
||||
if ( div.get(i).getAttribute("foo") != "bar" ){
|
||||
fail = i;
|
||||
break;
|
||||
}
|
||||
|
@ -187,25 +187,25 @@ test("attr(String, Object)", function() {
|
|||
// Fails on IE since recent changes to .attr()
|
||||
// ok( jQuery("#foo").attr({"width": null}), "Try to set an attribute to nothing" );
|
||||
|
||||
jQuery("#name").attr('name', 'something');
|
||||
equals( jQuery("#name").attr('name'), 'something', 'Set name attribute' );
|
||||
jQuery("#name").attr('name', null);
|
||||
equals( jQuery("#name").attr('name'), undefined, 'Remove name attribute' );
|
||||
jQuery("#check2").attr('checked', true);
|
||||
equals( document.getElementById('check2').checked, true, 'Set checked attribute' );
|
||||
jQuery("#check2").attr('checked', false);
|
||||
equals( document.getElementById('check2').checked, false, 'Set checked attribute' );
|
||||
jQuery("#text1").attr('readonly', true);
|
||||
equals( document.getElementById('text1').readOnly, true, 'Set readonly attribute' );
|
||||
jQuery("#text1").attr('readonly', false);
|
||||
equals( document.getElementById('text1').readOnly, false, 'Set readonly attribute' );
|
||||
jQuery("#name").attr('maxlength', '5');
|
||||
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');
|
||||
jQuery("#name").attr("name", "something");
|
||||
equals( jQuery("#name").attr("name"), "something", "Set name attribute" );
|
||||
jQuery("#name").attr("name", null);
|
||||
equals( jQuery("#name").attr("name"), undefined, "Remove name attribute" );
|
||||
jQuery("#check2").attr("checked", true);
|
||||
equals( document.getElementById("check2").checked, true, "Set checked attribute" );
|
||||
jQuery("#check2").attr("checked", false);
|
||||
equals( document.getElementById("check2").checked, false, "Set checked attribute" );
|
||||
jQuery("#text1").attr("readonly", true);
|
||||
equals( document.getElementById("text1").readOnly, true, "Set readonly attribute" );
|
||||
jQuery("#text1").attr("readonly", false);
|
||||
equals( document.getElementById("text1").readOnly, false, "Set readonly attribute" );
|
||||
jQuery("#name").attr("maxlength", "5");
|
||||
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 attributeNode = document.createAttribute("irrelevant"),
|
||||
commentNode = document.createComment("some comment"),
|
||||
|
@ -217,8 +217,8 @@ test("attr(String, Object)", function() {
|
|||
strictEqual( $ele.attr("nonexisting"), undefined, "attr(name, value) works correctly on comment and text nodes (bug #7500)." );
|
||||
});
|
||||
|
||||
var table = jQuery('#table').append("<tr><td>cell</td></tr><tr><td>cell</td><td>cell</td></tr><tr><td>cell</td><td>cell</td></tr>"),
|
||||
td = table.find('td:first');
|
||||
var table = jQuery("#table").append("<tr><td>cell</td></tr><tr><td>cell</td><td>cell</td></tr><tr><td>cell</td><td>cell</td></tr>"),
|
||||
td = table.find("td:first");
|
||||
td.attr("rowspan", "2");
|
||||
equals( td[0].rowSpan, 2, "Check rowspan is correctly set" );
|
||||
td.attr("colspan", "2");
|
||||
|
@ -227,12 +227,12 @@ test("attr(String, Object)", function() {
|
|||
equals( table[0].cellSpacing, "2", "Check cellspacing is correctly set" );
|
||||
|
||||
// for #1070
|
||||
jQuery("#name").attr('someAttr', '0');
|
||||
equals( jQuery("#name").attr('someAttr'), '0', 'Set attribute to a string of "0"' );
|
||||
jQuery("#name").attr('someAttr', 0);
|
||||
equals( jQuery("#name").attr('someAttr'), '0', 'Set attribute to the number 0' );
|
||||
jQuery("#name").attr('someAttr', 1);
|
||||
equals( jQuery("#name").attr('someAttr'), '1', 'Set attribute to the number 1' );
|
||||
jQuery("#name").attr("someAttr", "0");
|
||||
equals( jQuery("#name").attr("someAttr"), "0", "Set attribute to a string of \"0\"" );
|
||||
jQuery("#name").attr("someAttr", 0);
|
||||
equals( jQuery("#name").attr("someAttr"), "0", "Set attribute to the number 0" );
|
||||
jQuery("#name").attr("someAttr", 1);
|
||||
equals( jQuery("#name").attr("someAttr"), "1", "Set attribute to the number 1" );
|
||||
|
||||
// using contents will get comments regular, text, and comment nodes
|
||||
var j = jQuery("#nonnodes").contents();
|
||||
|
@ -244,51 +244,51 @@ test("attr(String, Object)", function() {
|
|||
QUnit.reset();
|
||||
|
||||
// Type
|
||||
var type = jQuery("#check2").attr('type');
|
||||
var type = jQuery("#check2").attr("type");
|
||||
var thrown = false;
|
||||
try {
|
||||
jQuery("#check2").attr('type','hidden');
|
||||
jQuery("#check2").attr("type","hidden");
|
||||
} catch(e) {
|
||||
thrown = true;
|
||||
}
|
||||
ok( thrown, "Exception thrown when trying to change type property" );
|
||||
equals( type, jQuery("#check2").attr('type'), "Verify that you can't change the type of an input element" );
|
||||
equals( type, jQuery("#check2").attr("type"), "Verify that you can't change the type of an input element" );
|
||||
|
||||
var check = document.createElement("input");
|
||||
var thrown = true;
|
||||
try {
|
||||
jQuery(check).attr('type','checkbox');
|
||||
jQuery(check).attr("type", "checkbox");
|
||||
} catch(e) {
|
||||
thrown = false;
|
||||
}
|
||||
ok( thrown, "Exception thrown when trying to change type property" );
|
||||
equals( "checkbox", jQuery(check).attr('type'), "Verify that you can change the type of an input element that isn't in the DOM" );
|
||||
equals( "checkbox", jQuery(check).attr("type"), "Verify that you can change the type of an input element that isn't in the DOM" );
|
||||
|
||||
var check = jQuery("<input />");
|
||||
var thrown = true;
|
||||
try {
|
||||
check.attr('type','checkbox');
|
||||
check.attr("type","checkbox");
|
||||
} catch(e) {
|
||||
thrown = false;
|
||||
}
|
||||
ok( thrown, "Exception thrown when trying to change type property" );
|
||||
equals( "checkbox", check.attr('type'), "Verify that you can change the type of an input element that isn't in the DOM" );
|
||||
equals( "checkbox", check.attr("type"), "Verify that you can change the type of an input element that isn't in the DOM" );
|
||||
|
||||
var button = jQuery("#button");
|
||||
var thrown = false;
|
||||
try {
|
||||
button.attr('type','submit');
|
||||
button.attr("type","submit");
|
||||
} catch(e) {
|
||||
thrown = true;
|
||||
}
|
||||
ok( thrown, "Exception thrown when trying to change type property" );
|
||||
equals( "button", button.attr('type'), "Verify that you can't change the type of a button element" );
|
||||
equals( "button", button.attr("type"), "Verify that you can't change the type of a button element" );
|
||||
|
||||
// Setting attributes on svg elements (bug #3116)
|
||||
var $svg = jQuery('<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="3000" height="3000">'
|
||||
+ '<circle cx="200" cy="200" r="150" />'
|
||||
+ '</svg>').appendTo('body');
|
||||
equals( $svg.attr('cx', 100).attr('cx'), "100", "Set attribute on svg element" );
|
||||
var $svg = jQuery("<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' baseProfile='full' width='200' height='200'>"
|
||||
+ "<circle cx='200' cy='200' r='150' />"
|
||||
+ "</svg>").appendTo("body");
|
||||
equals( $svg.attr("cx", 100).attr("cx"), "100", "Set attribute on svg element" );
|
||||
$svg.remove();
|
||||
});
|
||||
|
||||
|
@ -299,17 +299,17 @@ test("attr(jquery_method)", function(){
|
|||
elem = $elem[0];
|
||||
|
||||
// one at a time
|
||||
$elem.attr({'html': 'foo'}, true);
|
||||
equals( elem.innerHTML, 'foo', 'attr(html)');
|
||||
$elem.attr({html: "foo"}, true);
|
||||
equals( elem.innerHTML, "foo", "attr(html)");
|
||||
|
||||
$elem.attr({'text': 'bar'}, true);
|
||||
equals( elem.innerHTML, 'bar', 'attr(text)');
|
||||
$elem.attr({text: "bar"}, true);
|
||||
equals( elem.innerHTML, "bar", "attr(text)");
|
||||
|
||||
$elem.attr({'css': {color:'red'}}, true);
|
||||
ok( /^(#ff0000|red)$/i.test(elem.style.color), 'attr(css)');
|
||||
$elem.attr({css: {color: "red"}}, true);
|
||||
ok( /^(#ff0000|red)$/i.test(elem.style.color), "attr(css)");
|
||||
|
||||
$elem.attr({'height': 10}, true);
|
||||
equals( elem.style.height, '10px', 'attr(height)');
|
||||
$elem.attr({height: 10}, true);
|
||||
equals( elem.style.height, "10px", "attr(height)");
|
||||
|
||||
// Multiple attributes
|
||||
|
||||
|
@ -318,22 +318,22 @@ test("attr(jquery_method)", function(){
|
|||
css:{ paddingLeft:1, paddingRight:1 }
|
||||
}, true);
|
||||
|
||||
equals( elem.style.width, '10px', 'attr({...})');
|
||||
equals( elem.style.paddingLeft, '1px', 'attr({...})');
|
||||
equals( elem.style.paddingRight, '1px', 'attr({...})');
|
||||
equals( elem.style.width, "10px", "attr({...})");
|
||||
equals( elem.style.paddingLeft, "1px", "attr({...})");
|
||||
equals( elem.style.paddingRight, "1px", "attr({...})");
|
||||
});
|
||||
|
||||
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' );
|
||||
equals( titles[0], "Location", "attr() in XML context: Check first title" );
|
||||
equals( titles[1], "Users", "attr() in XML context: Check second title" );
|
||||
start();
|
||||
});
|
||||
});
|
||||
|
@ -343,64 +343,64 @@ test("attr('tabindex')", function() {
|
|||
expect(8);
|
||||
|
||||
// elements not natively tabbable
|
||||
equals(jQuery('#listWithTabIndex').attr('tabindex'), 5, 'not natively tabbable, with tabindex set to 0');
|
||||
equals(jQuery('#divWithNoTabIndex').attr('tabindex'), undefined, 'not natively tabbable, no tabindex set');
|
||||
equals(jQuery("#listWithTabIndex").attr("tabindex"), 5, "not natively tabbable, with tabindex set to 0");
|
||||
equals(jQuery("#divWithNoTabIndex").attr("tabindex"), undefined, "not natively tabbable, no tabindex set");
|
||||
|
||||
// anchor with href
|
||||
equals(jQuery('#linkWithNoTabIndex').attr('tabindex'), 0, 'anchor with href, no tabindex set');
|
||||
equals(jQuery('#linkWithTabIndex').attr('tabindex'), 2, 'anchor with href, tabindex set to 2');
|
||||
equals(jQuery('#linkWithNegativeTabIndex').attr('tabindex'), -1, 'anchor with href, tabindex set to -1');
|
||||
equals(jQuery("#linkWithNoTabIndex").attr("tabindex"), 0, "anchor with href, no tabindex set");
|
||||
equals(jQuery("#linkWithTabIndex").attr("tabindex"), 2, "anchor with href, tabindex set to 2");
|
||||
equals(jQuery("#linkWithNegativeTabIndex").attr("tabindex"), -1, "anchor with href, tabindex set to -1");
|
||||
|
||||
// anchor without href
|
||||
equals(jQuery('#linkWithNoHrefWithNoTabIndex').attr('tabindex'), undefined, 'anchor without href, no tabindex set');
|
||||
equals(jQuery('#linkWithNoHrefWithTabIndex').attr('tabindex'), 1, 'anchor without href, tabindex set to 2');
|
||||
equals(jQuery('#linkWithNoHrefWithNegativeTabIndex').attr('tabindex'), -1, 'anchor without href, no tabindex set');
|
||||
equals(jQuery("#linkWithNoHrefWithNoTabIndex").attr("tabindex"), undefined, "anchor without href, no tabindex set");
|
||||
equals(jQuery("#linkWithNoHrefWithTabIndex").attr("tabindex"), 1, "anchor without href, tabindex set to 2");
|
||||
equals(jQuery("#linkWithNoHrefWithNegativeTabIndex").attr("tabindex"), -1, "anchor without href, no tabindex set");
|
||||
});
|
||||
|
||||
test("attr('tabindex', value)", function() {
|
||||
expect(9);
|
||||
|
||||
var element = jQuery('#divWithNoTabIndex');
|
||||
equals(element.attr('tabindex'), undefined, 'start with no tabindex');
|
||||
var element = jQuery("#divWithNoTabIndex");
|
||||
equals(element.attr("tabindex"), undefined, "start with no tabindex");
|
||||
|
||||
// set a positive string
|
||||
element.attr('tabindex', '1');
|
||||
equals(element.attr('tabindex'), 1, 'set tabindex to 1 (string)');
|
||||
element.attr("tabindex", "1");
|
||||
equals(element.attr("tabindex"), 1, "set tabindex to 1 (string)");
|
||||
|
||||
// set a zero string
|
||||
element.attr('tabindex', '0');
|
||||
equals(element.attr('tabindex'), 0, 'set tabindex to 0 (string)');
|
||||
element.attr("tabindex", "0");
|
||||
equals(element.attr("tabindex"), 0, "set tabindex to 0 (string)");
|
||||
|
||||
// set a negative string
|
||||
element.attr('tabindex', '-1');
|
||||
equals(element.attr('tabindex'), -1, 'set tabindex to -1 (string)');
|
||||
element.attr("tabindex", "-1");
|
||||
equals(element.attr("tabindex"), -1, "set tabindex to -1 (string)");
|
||||
|
||||
// set a positive number
|
||||
element.attr('tabindex', 1);
|
||||
equals(element.attr('tabindex'), 1, 'set tabindex to 1 (number)');
|
||||
element.attr("tabindex", 1);
|
||||
equals(element.attr("tabindex"), 1, "set tabindex to 1 (number)");
|
||||
|
||||
// set a zero number
|
||||
element.attr('tabindex', 0);
|
||||
equals(element.attr('tabindex'), 0, 'set tabindex to 0 (number)');
|
||||
element.attr("tabindex", 0);
|
||||
equals(element.attr("tabindex"), 0, "set tabindex to 0 (number)");
|
||||
|
||||
// set a negative number
|
||||
element.attr('tabindex', -1);
|
||||
equals(element.attr('tabindex'), -1, 'set tabindex to -1 (number)');
|
||||
element.attr("tabindex", -1);
|
||||
equals(element.attr("tabindex"), -1, "set tabindex to -1 (number)");
|
||||
|
||||
element = jQuery('#linkWithTabIndex');
|
||||
equals(element.attr('tabindex'), 2, 'start with tabindex 2');
|
||||
element = jQuery("#linkWithTabIndex");
|
||||
equals(element.attr("tabindex"), 2, "start with tabindex 2");
|
||||
|
||||
element.attr('tabindex', -1);
|
||||
equals(element.attr('tabindex'), -1, 'set negative tabindex');
|
||||
element.attr("tabindex", -1);
|
||||
equals(element.attr("tabindex"), -1, "set negative tabindex");
|
||||
});
|
||||
|
||||
test("removeAttr(String)", function() {
|
||||
expect(5);
|
||||
equals( jQuery('#mark').removeAttr( "class" )[0].className, "", "remove class" );
|
||||
equals( jQuery('#form').removeAttr('id').attr('id'), undefined, 'Remove id' );
|
||||
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' );
|
||||
equals( jQuery("#mark").removeAttr( "class" )[0].className, "", "remove class" );
|
||||
equals( jQuery("#form").removeAttr("id").attr("id"), undefined, "Remove id" );
|
||||
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" );
|
||||
});
|
||||
|
||||
test("removeProp(String)", function() {
|
||||
|
@ -427,7 +427,7 @@ test("removeProp(String)", function() {
|
|||
test("val()", function() {
|
||||
expect(23);
|
||||
|
||||
document.getElementById('text1').value = "bla";
|
||||
document.getElementById("text1").value = "bla";
|
||||
equals( jQuery("#text1").val(), "bla", "Check for modified value of input element" );
|
||||
|
||||
QUnit.reset();
|
||||
|
@ -437,36 +437,36 @@ test("val()", function() {
|
|||
equals( jQuery("#first").val(), "", "Check a paragraph element to see if it has a value" );
|
||||
ok( jQuery([]).val() === undefined, "Check an empty jQuery object will return undefined from val" );
|
||||
|
||||
equals( jQuery('#select2').val(), '3', 'Call val() on a single="single" select' );
|
||||
equals( jQuery("#select2").val(), "3", "Call val() on a single=\"single\" select" );
|
||||
|
||||
same( jQuery('#select3').val(), ['1', '2'], 'Call val() on a multiple="multiple" select' );
|
||||
same( jQuery("#select3").val(), ["1", "2"], "Call val() on a multiple=\"multiple\" select" );
|
||||
|
||||
equals( jQuery('#option3c').val(), '2', 'Call val() on a option element with value' );
|
||||
equals( jQuery("#option3c").val(), "2", "Call val() on a option element with value" );
|
||||
|
||||
equals( jQuery('#option3a').val(), '', 'Call val() on a option element with empty value' );
|
||||
equals( jQuery("#option3a").val(), "", "Call val() on a option element with empty value" );
|
||||
|
||||
equals( jQuery('#option3e').val(), 'no value', 'Call val() on a option element with no value attribute' );
|
||||
equals( jQuery("#option3e").val(), "no value", "Call val() on a option element with no value attribute" );
|
||||
|
||||
equals( jQuery('#option3a').val(), '', 'Call val() on a option element with no value attribute' );
|
||||
equals( jQuery("#option3a").val(), "", "Call val() on a option element with no value attribute" );
|
||||
|
||||
jQuery('#select3').val("");
|
||||
same( jQuery('#select3').val(), [''], 'Call val() on a multiple="multiple" select' );
|
||||
jQuery("#select3").val("");
|
||||
same( jQuery("#select3").val(), [""], "Call val() on a multiple=\"multiple\" select" );
|
||||
|
||||
same( jQuery('#select4').val(), [], 'Call val() on multiple="multiple" select with all disabled options' );
|
||||
same( jQuery("#select4").val(), [], "Call val() on multiple=\"multiple\" select with all disabled options" );
|
||||
|
||||
jQuery('#select4 optgroup').add('#select4 > [disabled]').attr('disabled', false);
|
||||
same( jQuery('#select4').val(), ['2', '3'], 'Call val() on multiple="multiple" select with some disabled options' );
|
||||
jQuery("#select4 optgroup").add("#select4 > [disabled]").attr("disabled", false);
|
||||
same( jQuery("#select4").val(), ["2", "3"], "Call val() on multiple=\"multiple\" select with some disabled options" );
|
||||
|
||||
jQuery('#select4').attr('disabled', true);
|
||||
same( jQuery('#select4').val(), ['2', '3'], 'Call val() on disabled multiple="multiple" select' );
|
||||
jQuery("#select4").attr("disabled", true);
|
||||
same( jQuery("#select4").val(), ["2", "3"], "Call val() on disabled multiple=\"multiple\" select" );
|
||||
|
||||
equals( jQuery('#select5').val(), "3", "Check value on ambiguous select." );
|
||||
equals( jQuery("#select5").val(), "3", "Check value on ambiguous select." );
|
||||
|
||||
jQuery('#select5').val(1);
|
||||
equals( jQuery('#select5').val(), "1", "Check value on ambiguous select." );
|
||||
jQuery("#select5").val(1);
|
||||
equals( jQuery("#select5").val(), "1", "Check value on ambiguous select." );
|
||||
|
||||
jQuery('#select5').val(3);
|
||||
equals( jQuery('#select5').val(), "3", "Check value on ambiguous select." );
|
||||
jQuery("#select5").val(3);
|
||||
equals( jQuery("#select5").val(), "3", "Check value on ambiguous select." );
|
||||
|
||||
var checks = jQuery("<input type='checkbox' name='test' value='1'/><input type='checkbox' name='test' value='2'/><input type='checkbox' name='test' value=''/><input type='checkbox' name='test'/>").appendTo("#form");
|
||||
|
||||
|
@ -492,27 +492,29 @@ test("val()", function() {
|
|||
var testVal = function(valueObj) {
|
||||
expect(8);
|
||||
|
||||
jQuery("#text1").val(valueObj( 'test' ));
|
||||
equals( document.getElementById('text1').value, "test", "Check for modified (via val(String)) value of input element" );
|
||||
QUnit.reset();
|
||||
jQuery("#text1").val(valueObj( "test" ));
|
||||
equals( document.getElementById("text1").value, "test", "Check for modified (via val(String)) value of input element" );
|
||||
|
||||
jQuery("#text1").val(valueObj( undefined ));
|
||||
equals( document.getElementById('text1').value, "", "Check for modified (via val(undefined)) value of input element" );
|
||||
equals( document.getElementById("text1").value, "", "Check for modified (via val(undefined)) value of input element" );
|
||||
|
||||
jQuery("#text1").val(valueObj( 67 ));
|
||||
equals( document.getElementById('text1').value, "67", "Check for modified (via val(Number)) value of input element" );
|
||||
equals( document.getElementById("text1").value, "67", "Check for modified (via val(Number)) value of input element" );
|
||||
|
||||
jQuery("#text1").val(valueObj( null ));
|
||||
equals( document.getElementById('text1').value, "", "Check for modified (via val(null)) value of input element" );
|
||||
equals( document.getElementById("text1").value, "", "Check for modified (via val(null)) value of input element" );
|
||||
|
||||
jQuery("#select1").val(valueObj( "3" ));
|
||||
equals( jQuery("#select1").val(), "3", "Check for modified (via val(String)) value of select element" );
|
||||
var $select1 = jQuery("#select1");
|
||||
$select1.val(valueObj( "3" ));
|
||||
equals( $select1.val(), "3", "Check for modified (via val(String)) value of select element" );
|
||||
|
||||
jQuery("#select1").val(valueObj( 2 ));
|
||||
equals( jQuery("#select1").val(), "2", "Check for modified (via val(Number)) value of select element" );
|
||||
$select1.val(valueObj( 2 ));
|
||||
equals( $select1.val(), "2", "Check for modified (via val(Number)) value of select element" );
|
||||
|
||||
jQuery("#select1").append("<option value='4'>four</option>");
|
||||
jQuery("#select1").val(valueObj( 4 ));
|
||||
equals( jQuery("#select1").val(), "4", "Should be possible to set the val() to a newly created option" );
|
||||
$select1.append("<option value='4'>four</option>");
|
||||
$select1.val(valueObj( 4 ));
|
||||
equals( $select1.val(), "4", "Should be possible to set the val() to a newly created option" );
|
||||
|
||||
// using contents will get comments regular, text, and comment nodes
|
||||
var j = jQuery("#nonnodes").contents();
|
||||
|
@ -531,8 +533,8 @@ test("val(Function)", function() {
|
|||
|
||||
test( "val(Array of Numbers) (Bug #7123)", function() {
|
||||
expect(4);
|
||||
jQuery('#form').append('<input type="checkbox" name="arrayTest" value="1" /><input type="checkbox" name="arrayTest" value="2" /><input type="checkbox" name="arrayTest" value="3" checked="checked" /><input type="checkbox" name="arrayTest" value="4" />');
|
||||
var elements = jQuery('input[name=arrayTest]').val([ 1, 2 ]);
|
||||
jQuery("#form").append("<input type='checkbox' name='arrayTest' value='1' /><input type='checkbox' name='arrayTest' value='2' /><input type='checkbox' name='arrayTest' value='3' checked='checked' /><input type='checkbox' name='arrayTest' value='4' />");
|
||||
var elements = jQuery("input[name=arrayTest]").val([ 1, 2 ]);
|
||||
ok( elements[0].checked, "First element was checked" );
|
||||
ok( elements[1].checked, "Second element was checked" );
|
||||
ok( !elements[2].checked, "Third element was unchecked" );
|
||||
|
@ -551,7 +553,7 @@ test("val(Function) with incoming value", function() {
|
|||
return "test";
|
||||
});
|
||||
|
||||
equals( document.getElementById('text1').value, "test", "Check for modified (via val(String)) value of input element" );
|
||||
equals( document.getElementById("text1").value, "test", "Check for modified (via val(String)) value of input element" );
|
||||
|
||||
oldVal = jQuery("#text1").val();
|
||||
|
||||
|
@ -560,7 +562,7 @@ test("val(Function) with incoming value", function() {
|
|||
return 67;
|
||||
});
|
||||
|
||||
equals( document.getElementById('text1').value, "67", "Check for modified (via val(Number)) value of input element" );
|
||||
equals( document.getElementById("text1").value, "67", "Check for modified (via val(Number)) value of input element" );
|
||||
|
||||
oldVal = jQuery("#select1").val();
|
||||
|
||||
|
@ -596,7 +598,7 @@ test("val(Function) with incoming value", function() {
|
|||
test("val(select) after form.reset() (Bug #2551)", function() {
|
||||
expect(3);
|
||||
|
||||
jQuery('<form id="kk" name="kk"><select id="kkk"><option value="cf">cf</option><option value="gf">gf</option></select></form>').appendTo("#main");
|
||||
jQuery("<form id='kk' name='kk'><select id='kkk'><option value='cf'>cf</option><option value='gf'>gf</option></select></form>").appendTo("#main");
|
||||
|
||||
jQuery("#kkk").val( "gf" );
|
||||
|
||||
|
@ -606,7 +608,7 @@ test("val(select) after form.reset() (Bug #2551)", function() {
|
|||
equal( jQuery("#kkk").val(), "cf", "Check value of select after form reset." );
|
||||
|
||||
// re-verify the multi-select is not broken (after form.reset) by our fix for single-select
|
||||
same( jQuery('#select3').val(), ['1', '2'], 'Call val() on a multiple="multiple" select' );
|
||||
same( jQuery("#select3").val(), ["1", "2"], "Call val() on a multiple=\"multiple\" select" );
|
||||
|
||||
jQuery("#kk").remove();
|
||||
});
|
||||
|
@ -671,29 +673,29 @@ test("addClass(Function) with incoming value", function() {
|
|||
var testRemoveClass = function(valueObj) {
|
||||
expect(7);
|
||||
|
||||
var $divs = jQuery('div');
|
||||
var $divs = jQuery("div");
|
||||
|
||||
$divs.addClass("test").removeClass( valueObj("test") );
|
||||
|
||||
ok( !$divs.is('.test'), "Remove Class" );
|
||||
ok( !$divs.is(".test"), "Remove Class" );
|
||||
|
||||
QUnit.reset();
|
||||
$divs = jQuery('div');
|
||||
$divs = jQuery("div");
|
||||
|
||||
$divs.addClass("test").addClass("foo").addClass("bar");
|
||||
$divs.removeClass( valueObj("test") ).removeClass( valueObj("bar") ).removeClass( valueObj("foo") );
|
||||
|
||||
ok( !$divs.is('.test,.bar,.foo'), "Remove multiple classes" );
|
||||
ok( !$divs.is(".test,.bar,.foo"), "Remove multiple classes" );
|
||||
|
||||
QUnit.reset();
|
||||
$divs = jQuery('div');
|
||||
$divs = jQuery("div");
|
||||
|
||||
// Make sure that a null value doesn't cause problems
|
||||
$divs.eq(0).addClass("test").removeClass( valueObj(null) );
|
||||
ok( $divs.eq(0).is('.test'), "Null value passed to removeClass" );
|
||||
ok( $divs.eq(0).is(".test"), "Null value passed to removeClass" );
|
||||
|
||||
$divs.eq(0).addClass("test").removeClass( valueObj("") );
|
||||
ok( $divs.eq(0).is('.test'), "Empty string passed to removeClass" );
|
||||
ok( $divs.eq(0).is(".test"), "Empty string passed to removeClass" );
|
||||
|
||||
// using contents will get regular, text, and comment nodes
|
||||
var j = jQuery("#nonnodes").contents();
|
||||
|
@ -723,7 +725,7 @@ test("removeClass(Function) - simple", function() {
|
|||
test("removeClass(Function) with incoming value", function() {
|
||||
expect(45);
|
||||
|
||||
var $divs = jQuery('div').addClass("test"), old = $divs.map(function(){
|
||||
var $divs = jQuery("div").addClass("test"), old = $divs.map(function(){
|
||||
return jQuery(this).attr("class");
|
||||
});
|
||||
|
||||
|
@ -734,7 +736,7 @@ test("removeClass(Function) with incoming value", function() {
|
|||
}
|
||||
});
|
||||
|
||||
ok( !$divs.is('.test'), "Remove Class" );
|
||||
ok( !$divs.is(".test"), "Remove Class" );
|
||||
|
||||
QUnit.reset();
|
||||
});
|
||||
|
@ -772,7 +774,7 @@ var testToggleClass = function(valueObj) {
|
|||
ok( e.is(".testD.testE"), "Assert class present" );
|
||||
e.toggleClass();
|
||||
ok( !e.is(".testD.testE"), "Assert class not present" );
|
||||
ok( jQuery._data(e[0], '__className__') === 'testD testE', "Assert data was stored" );
|
||||
ok( jQuery._data(e[0], "__className__") === "testD testE", "Assert data was stored" );
|
||||
e.toggleClass();
|
||||
ok( e.is(".testD.testE"), "Assert class present (restored from data)" );
|
||||
e.toggleClass(false);
|
||||
|
@ -786,7 +788,7 @@ var testToggleClass = function(valueObj) {
|
|||
|
||||
// Cleanup
|
||||
e.removeClass("testD");
|
||||
jQuery.removeData(e[0], '__className__', true);
|
||||
jQuery.removeData(e[0], "__className__", true);
|
||||
};
|
||||
|
||||
test("toggleClass(String|boolean|undefined[, boolean])", function() {
|
||||
|
@ -847,7 +849,7 @@ test("toggleClass(Fucntion[, boolean]) with incoming value", function() {
|
|||
|
||||
// Cleanup
|
||||
e.removeClass("test");
|
||||
jQuery.removeData(e[0], '__className__', true);
|
||||
jQuery.removeData(e[0], "__className__", true);
|
||||
});
|
||||
|
||||
test("addClass, removeClass, hasClass", function() {
|
||||
|
|
|
@ -62,7 +62,7 @@ test("jQuery()", function() {
|
|||
|
||||
equals( jQuery([1,2,3]).get(1), 2, "Test passing an array to the factory" );
|
||||
|
||||
equals( jQuery(document.body).get(0), jQuery('body').get(0), "Test passing an html node to the factory" );
|
||||
equals( jQuery(document.body).get(0), jQuery("body").get(0), "Test passing an html node to the factory" );
|
||||
|
||||
var exec = false;
|
||||
|
||||
|
@ -75,13 +75,13 @@ test("jQuery()", function() {
|
|||
id: "test3"
|
||||
});
|
||||
|
||||
equals( elem[0].style.width, '10px', 'jQuery() quick setter width');
|
||||
equals( elem[0].style.paddingLeft, '1px', 'jQuery quick setter css');
|
||||
equals( elem[0].style.paddingRight, '1px', 'jQuery quick setter css');
|
||||
equals( elem[0].childNodes.length, 1, 'jQuery quick setter text');
|
||||
equals( elem[0].firstChild.nodeValue, "test", 'jQuery quick setter text');
|
||||
equals( elem[0].className, "test2", 'jQuery() quick setter class');
|
||||
equals( elem[0].id, "test3", 'jQuery() quick setter id');
|
||||
equals( elem[0].style.width, "10px", "jQuery() quick setter width");
|
||||
equals( elem[0].style.paddingLeft, "1px", "jQuery quick setter css");
|
||||
equals( elem[0].style.paddingRight, "1px", "jQuery quick setter css");
|
||||
equals( elem[0].childNodes.length, 1, "jQuery quick setter text");
|
||||
equals( elem[0].firstChild.nodeValue, "test", "jQuery quick setter text");
|
||||
equals( elem[0].className, "test2", "jQuery() quick setter class");
|
||||
equals( elem[0].id, "test3", "jQuery() quick setter id");
|
||||
|
||||
exec = true;
|
||||
elem.click();
|
||||
|
@ -460,7 +460,7 @@ if ( !isLocal ) {
|
|||
test("isXMLDoc - XML", function() {
|
||||
expect(3);
|
||||
stop();
|
||||
jQuery.get('data/dashboard.xml', function(xml) {
|
||||
jQuery.get("data/dashboard.xml", function(xml) {
|
||||
ok( jQuery.isXMLDoc( xml ), "XML document" );
|
||||
ok( jQuery.isXMLDoc( xml.documentElement ), "XML documentElement" );
|
||||
ok( jQuery.isXMLDoc( jQuery("tab", xml)[0] ), "XML Tab Element" );
|
||||
|
@ -524,15 +524,15 @@ test("jQuery('html')", function() {
|
|||
|
||||
// Test very large html string #7990
|
||||
var i;
|
||||
var li = '<li>very large html string</li>';
|
||||
var html = ['<ul>'];
|
||||
var li = "<li>very large html string</li>";
|
||||
var html = ["<ul>"];
|
||||
for ( i = 0; i < 50000; i += 1 ) {
|
||||
html.push(li);
|
||||
}
|
||||
html.push('</ul>');
|
||||
html = jQuery(html.join(''))[0];
|
||||
equals( html.nodeName.toUpperCase(), 'UL');
|
||||
equals( html.firstChild.nodeName.toUpperCase(), 'LI');
|
||||
html.push("</ul>");
|
||||
html = jQuery(html.join(""))[0];
|
||||
equals( html.nodeName.toUpperCase(), "UL");
|
||||
equals( html.firstChild.nodeName.toUpperCase(), "LI");
|
||||
equals( html.childNodes.length, 50000 );
|
||||
});
|
||||
|
||||
|
@ -548,7 +548,7 @@ if ( !isLocal ) {
|
|||
test("jQuery(selector, xml).text(str) - Loaded via XML document", function() {
|
||||
expect(2);
|
||||
stop();
|
||||
jQuery.get('data/dashboard.xml', function(xml) {
|
||||
jQuery.get("data/dashboard.xml", function(xml) {
|
||||
// tests for #1419 where IE was a problem
|
||||
var tab = jQuery("tab", xml).eq(0);
|
||||
equals( tab.text(), "blabla", "Verify initial text correct" );
|
||||
|
@ -561,12 +561,12 @@ test("jQuery(selector, xml).text(str) - Loaded via XML document", function() {
|
|||
|
||||
test("end()", function() {
|
||||
expect(3);
|
||||
equals( 'Yahoo', jQuery('#yahoo').parent().end().text(), 'Check for end' );
|
||||
ok( jQuery('#yahoo').end(), 'Check for end with nothing to end' );
|
||||
equals( "Yahoo", jQuery("#yahoo").parent().end().text(), "Check for end" );
|
||||
ok( jQuery("#yahoo").end(), "Check for end with nothing to end" );
|
||||
|
||||
var x = jQuery('#yahoo');
|
||||
var x = jQuery("#yahoo");
|
||||
x.parent();
|
||||
equals( 'Yahoo', jQuery('#yahoo').text(), 'Check for non-destructive behaviour' );
|
||||
equals( "Yahoo", jQuery("#yahoo").text(), "Check for non-destructive behaviour" );
|
||||
});
|
||||
|
||||
test("length", function() {
|
||||
|
@ -606,7 +606,7 @@ test("get(-Number)",function() {
|
|||
test("each(Function)", function() {
|
||||
expect(1);
|
||||
var div = jQuery("div");
|
||||
div.each(function(){this.foo = 'zoo';});
|
||||
div.each(function(){this.foo = "zoo";});
|
||||
var pass = true;
|
||||
for ( var i = 0; i < div.size(); i++ ) {
|
||||
if ( div.get(i).foo != "zoo" ) pass = false;
|
||||
|
@ -625,7 +625,7 @@ test("slice()", function() {
|
|||
same( $links.slice(-1).get(), q("mark"), "slice(-1)" );
|
||||
|
||||
same( $links.eq(1).get(), q("groups"), "eq(1)" );
|
||||
same( $links.eq('2').get(), q("anchor1"), "eq('2')" );
|
||||
same( $links.eq("2").get(), q("anchor1"), "eq('2')" );
|
||||
same( $links.eq(-1).get(), q("mark"), "eq(-1)" );
|
||||
});
|
||||
|
||||
|
@ -792,7 +792,7 @@ test("jQuery.extend(Object, Object)", function() {
|
|||
ok( typeof ret.foo != "string", "Check to make sure values equal with coersion (but not actually equal) overwrite correctly" );
|
||||
|
||||
var ret = jQuery.extend(true, { foo:"bar" }, { foo:null } );
|
||||
ok( typeof ret.foo !== 'undefined', "Make sure a null value doesn't crash with deep extend, for #1908" );
|
||||
ok( typeof ret.foo !== "undefined", "Make sure a null value doesn't crash with deep extend, for #1908" );
|
||||
|
||||
var obj = { foo:null };
|
||||
jQuery.extend(true, obj, { foo:"notnull" } );
|
||||
|
@ -818,7 +818,7 @@ test("jQuery.extend(Object, Object)", function() {
|
|||
});
|
||||
|
||||
test("jQuery.each(Object,Function)", function() {
|
||||
expect(13);
|
||||
expect(14);
|
||||
jQuery.each( [0,1,2], function(i, n){
|
||||
equals( i, n, "Check array iteration" );
|
||||
});
|
||||
|
@ -845,17 +845,24 @@ test("jQuery.each(Object,Function)", function() {
|
|||
equals( total, 3, "Looping over an object, with break" );
|
||||
|
||||
var f = function(){};
|
||||
f.foo = 'bar';
|
||||
f.foo = "bar";
|
||||
jQuery.each(f, function(i){
|
||||
f[i] = 'baz';
|
||||
f[i] = "baz";
|
||||
});
|
||||
equals( "baz", f.foo, "Loop over a function" );
|
||||
|
||||
var stylesheet_count = 0;
|
||||
jQuery.each(document.styleSheets, function(i){
|
||||
stylesheet_count++;
|
||||
});
|
||||
equals(stylesheet_count, 2, "should not throw an error in IE while looping over document.styleSheets and return proper amount");
|
||||
|
||||
});
|
||||
|
||||
test("jQuery.makeArray", function(){
|
||||
expect(17);
|
||||
|
||||
equals( jQuery.makeArray(jQuery('html>*'))[0].nodeName.toUpperCase(), "HEAD", "Pass makeArray a jQuery object" );
|
||||
equals( jQuery.makeArray(jQuery("html>*"))[0].nodeName.toUpperCase(), "HEAD", "Pass makeArray a jQuery object" );
|
||||
|
||||
equals( jQuery.makeArray(document.getElementsByName("PWD")).slice(0,1)[0].name, "PWD", "Pass makeArray a nodelist" );
|
||||
|
||||
|
@ -885,11 +892,11 @@ test("jQuery.makeArray", function(){
|
|||
|
||||
equals( jQuery.makeArray(/a/)[0].constructor, RegExp, "Pass makeArray a regex" );
|
||||
|
||||
ok( jQuery.makeArray(document.getElementById('form')).length >= 13, "Pass makeArray a form (treat as elements)" );
|
||||
ok( jQuery.makeArray(document.getElementById("form")).length >= 13, "Pass makeArray a form (treat as elements)" );
|
||||
|
||||
// For #5610
|
||||
same( jQuery.makeArray({'length': '0'}), [], "Make sure object is coerced properly.");
|
||||
same( jQuery.makeArray({'length': '5'}), [], "Make sure object is coerced properly.");
|
||||
same( jQuery.makeArray({length: "0"}), [], "Make sure object is coerced properly.");
|
||||
same( jQuery.makeArray({length: "5"}), [], "Make sure object is coerced properly.");
|
||||
});
|
||||
|
||||
test("jQuery.isEmptyObject", function(){
|
||||
|
@ -938,9 +945,9 @@ test("jQuery.parseJSON", function(){
|
|||
equals( jQuery.parseJSON( "" ), null, "Nothing in, null out." );
|
||||
|
||||
same( jQuery.parseJSON("{}"), {}, "Plain object parsing." );
|
||||
same( jQuery.parseJSON('{"test":1}'), {"test":1}, "Plain object parsing." );
|
||||
same( jQuery.parseJSON("{\"test\":1}"), {"test":1}, "Plain object parsing." );
|
||||
|
||||
same( jQuery.parseJSON('\n{"test":1}'), {"test":1}, "Make sure leading whitespaces are handled." );
|
||||
same( jQuery.parseJSON("\n{\"test\":1}"), {"test":1}, "Make sure leading whitespaces are handled." );
|
||||
|
||||
try {
|
||||
jQuery.parseJSON("{a:1}");
|
||||
|
@ -964,7 +971,7 @@ test("jQuery.sub() - Static Methods", function(){
|
|||
topLevelMethod: function() {return this.debug;},
|
||||
debug: false,
|
||||
config: {
|
||||
locale: 'en_US'
|
||||
locale: "en_US"
|
||||
},
|
||||
setup: function(config) {
|
||||
this.extend(true, this.config, config);
|
||||
|
@ -973,37 +980,37 @@ test("jQuery.sub() - Static Methods", function(){
|
|||
Subclass.fn.extend({subClassMethod: function() { return this;}});
|
||||
|
||||
//Test Simple Subclass
|
||||
ok(Subclass.topLevelMethod() === false, 'Subclass.topLevelMethod thought debug was true');
|
||||
ok(Subclass.config.locale == 'en_US', Subclass.config.locale + ' is wrong!');
|
||||
same(Subclass.config.test, undefined, 'Subclass.config.test is set incorrectly');
|
||||
equal(jQuery.ajax, Subclass.ajax, 'The subclass failed to get all top level methods');
|
||||
ok(Subclass.topLevelMethod() === false, "Subclass.topLevelMethod thought debug was true");
|
||||
ok(Subclass.config.locale == "en_US", Subclass.config.locale + " is wrong!");
|
||||
same(Subclass.config.test, undefined, "Subclass.config.test is set incorrectly");
|
||||
equal(jQuery.ajax, Subclass.ajax, "The subclass failed to get all top level methods");
|
||||
|
||||
//Create a SubSubclass
|
||||
var SubSubclass = Subclass.sub();
|
||||
|
||||
//Make Sure the SubSubclass inherited properly
|
||||
ok(SubSubclass.topLevelMethod() === false, 'SubSubclass.topLevelMethod thought debug was true');
|
||||
ok(SubSubclass.config.locale == 'en_US', SubSubclass.config.locale + ' is wrong!');
|
||||
same(SubSubclass.config.test, undefined, 'SubSubclass.config.test is set incorrectly');
|
||||
equal(jQuery.ajax, SubSubclass.ajax, 'The subsubclass failed to get all top level methods');
|
||||
ok(SubSubclass.topLevelMethod() === false, "SubSubclass.topLevelMethod thought debug was true");
|
||||
ok(SubSubclass.config.locale == "en_US", SubSubclass.config.locale + " is wrong!");
|
||||
same(SubSubclass.config.test, undefined, "SubSubclass.config.test is set incorrectly");
|
||||
equal(jQuery.ajax, SubSubclass.ajax, "The subsubclass failed to get all top level methods");
|
||||
|
||||
//Modify The Subclass and test the Modifications
|
||||
SubSubclass.fn.extend({subSubClassMethod: function() { return this;}});
|
||||
SubSubclass.setup({locale: 'es_MX', test: 'worked'});
|
||||
SubSubclass.setup({locale: "es_MX", test: "worked"});
|
||||
SubSubclass.debug = true;
|
||||
SubSubclass.ajax = function() {return false;};
|
||||
ok(SubSubclass.topLevelMethod(), 'SubSubclass.topLevelMethod thought debug was false');
|
||||
same(SubSubclass(document).subClassMethod, Subclass.fn.subClassMethod, 'Methods Differ!');
|
||||
ok(SubSubclass.config.locale == 'es_MX', SubSubclass.config.locale + ' is wrong!');
|
||||
ok(SubSubclass.config.test == 'worked', 'SubSubclass.config.test is set incorrectly');
|
||||
notEqual(jQuery.ajax, SubSubclass.ajax, 'The subsubclass failed to get all top level methods');
|
||||
ok(SubSubclass.topLevelMethod(), "SubSubclass.topLevelMethod thought debug was false");
|
||||
same(SubSubclass(document).subClassMethod, Subclass.fn.subClassMethod, "Methods Differ!");
|
||||
ok(SubSubclass.config.locale == "es_MX", SubSubclass.config.locale + " is wrong!");
|
||||
ok(SubSubclass.config.test == "worked", "SubSubclass.config.test is set incorrectly");
|
||||
notEqual(jQuery.ajax, SubSubclass.ajax, "The subsubclass failed to get all top level methods");
|
||||
|
||||
//This shows that the modifications to the SubSubClass did not bubble back up to it's superclass
|
||||
ok(Subclass.topLevelMethod() === false, 'Subclass.topLevelMethod thought debug was true');
|
||||
ok(Subclass.config.locale == 'en_US', Subclass.config.locale + ' is wrong!');
|
||||
same(Subclass.config.test, undefined, 'Subclass.config.test is set incorrectly');
|
||||
same(Subclass(document).subSubClassMethod, undefined, 'subSubClassMethod set incorrectly');
|
||||
equal(jQuery.ajax, Subclass.ajax, 'The subclass failed to get all top level methods');
|
||||
ok(Subclass.topLevelMethod() === false, "Subclass.topLevelMethod thought debug was true");
|
||||
ok(Subclass.config.locale == "en_US", Subclass.config.locale + " is wrong!");
|
||||
same(Subclass.config.test, undefined, "Subclass.config.test is set incorrectly");
|
||||
same(Subclass(document).subSubClassMethod, undefined, "subSubClassMethod set incorrectly");
|
||||
equal(jQuery.ajax, Subclass.ajax, "The subclass failed to get all top level methods");
|
||||
});
|
||||
|
||||
test("jQuery.sub() - .fn Methods", function(){
|
||||
|
@ -1014,25 +1021,25 @@ test("jQuery.sub() - .fn Methods", function(){
|
|||
jQueryDocument = jQuery(document),
|
||||
selectors, contexts, methods, method, arg, description;
|
||||
|
||||
jQueryDocument.toString = function(){ return 'jQueryDocument'; };
|
||||
jQueryDocument.toString = function(){ return "jQueryDocument"; };
|
||||
|
||||
Subclass.fn.subclassMethod = function(){};
|
||||
SubclassSubclass.fn.subclassSubclassMethod = function(){};
|
||||
|
||||
selectors = [
|
||||
'body',
|
||||
'html, body',
|
||||
'<div></div>'
|
||||
"body",
|
||||
"html, body",
|
||||
"<div></div>"
|
||||
];
|
||||
|
||||
methods = [ // all methods that return a new jQuery instance
|
||||
['eq', 1],
|
||||
['add', document],
|
||||
['end'],
|
||||
['has'],
|
||||
['closest', 'div'],
|
||||
['filter', document],
|
||||
['find', 'div']
|
||||
["eq", 1],
|
||||
["add", document],
|
||||
["end"],
|
||||
["has"],
|
||||
["closest", "div"],
|
||||
["filter", document],
|
||||
["find", "div"]
|
||||
];
|
||||
|
||||
contexts = [undefined, document, jQueryDocument];
|
||||
|
@ -1045,31 +1052,31 @@ test("jQuery.sub() - .fn Methods", function(){
|
|||
|
||||
jQuery.each(contexts, function(i, context){
|
||||
|
||||
description = '("'+selector+'", '+context+').'+method+'('+(arg||'')+')';
|
||||
description = "(\""+selector+"\", "+context+")."+method+"("+(arg||"")+")";
|
||||
|
||||
same(
|
||||
jQuery(selector, context)[method](arg).subclassMethod, undefined,
|
||||
'jQuery'+description+' doesnt have Subclass methods'
|
||||
"jQuery"+description+" doesn't have Subclass methods"
|
||||
);
|
||||
same(
|
||||
jQuery(selector, context)[method](arg).subclassSubclassMethod, undefined,
|
||||
'jQuery'+description+' doesnt have SubclassSubclass methods'
|
||||
"jQuery"+description+" doesn't have SubclassSubclass methods"
|
||||
);
|
||||
same(
|
||||
Subclass(selector, context)[method](arg).subclassMethod, Subclass.fn.subclassMethod,
|
||||
'Subclass'+description+' has Subclass methods'
|
||||
"Subclass"+description+" has Subclass methods"
|
||||
);
|
||||
same(
|
||||
Subclass(selector, context)[method](arg).subclassSubclassMethod, undefined,
|
||||
'Subclass'+description+' doesnt have SubclassSubclass methods'
|
||||
"Subclass"+description+" doesn't have SubclassSubclass methods"
|
||||
);
|
||||
same(
|
||||
SubclassSubclass(selector, context)[method](arg).subclassMethod, Subclass.fn.subclassMethod,
|
||||
'SubclassSubclass'+description+' has Subclass methods'
|
||||
"SubclassSubclass"+description+" has Subclass methods"
|
||||
);
|
||||
same(
|
||||
SubclassSubclass(selector, context)[method](arg).subclassSubclassMethod, SubclassSubclass.fn.subclassSubclassMethod,
|
||||
'SubclassSubclass'+description+' has SubclassSubclass methods'
|
||||
"SubclassSubclass"+description+" has SubclassSubclass methods"
|
||||
);
|
||||
|
||||
});
|
||||
|
|
137
test/unit/css.js
137
test/unit/css.js
|
@ -1,15 +1,15 @@
|
|||
module("css", { teardown: moduleTeardown });
|
||||
|
||||
test("css(String|Hash)", function() {
|
||||
expect(41);
|
||||
expect( 42 );
|
||||
|
||||
equals( jQuery('#main').css("display"), 'block', 'Check for css property "display"');
|
||||
equals( jQuery("#main").css("display"), "block", "Check for css property \"display\"");
|
||||
|
||||
ok( jQuery('#nothiddendiv').is(':visible'), 'Modifying CSS display: Assert element is visible');
|
||||
jQuery('#nothiddendiv').css({display: 'none'});
|
||||
ok( !jQuery('#nothiddendiv').is(':visible'), 'Modified CSS display: Assert element is hidden');
|
||||
jQuery('#nothiddendiv').css({display: 'block'});
|
||||
ok( jQuery('#nothiddendiv').is(':visible'), 'Modified CSS display: Assert element is visible');
|
||||
ok( jQuery("#nothiddendiv").is(":visible"), "Modifying CSS display: Assert element is visible");
|
||||
jQuery("#nothiddendiv").css({display: "none"});
|
||||
ok( !jQuery("#nothiddendiv").is(":visible"), "Modified CSS display: Assert element is hidden");
|
||||
jQuery("#nothiddendiv").css({display: "block"});
|
||||
ok( jQuery("#nothiddendiv").is(":visible"), "Modified CSS display: Assert element is visible");
|
||||
|
||||
var div = jQuery( "<div>" );
|
||||
|
||||
|
@ -32,34 +32,37 @@ test("css(String|Hash)", function() {
|
|||
div2.remove();
|
||||
|
||||
// handle negative numbers by ignoring #1599, #4216
|
||||
jQuery('#nothiddendiv').css({ 'width': 1, 'height': 1 });
|
||||
jQuery("#nothiddendiv").css( {width: 1, height: 1} );
|
||||
|
||||
var width = parseFloat(jQuery('#nothiddendiv').css('width')), height = parseFloat(jQuery('#nothiddendiv').css('height'));
|
||||
jQuery('#nothiddendiv').css({ width: -1, height: -1 });
|
||||
equals( parseFloat(jQuery('#nothiddendiv').css('width')), width, 'Test negative width ignored')
|
||||
equals( parseFloat(jQuery('#nothiddendiv').css('height')), height, 'Test negative height ignored')
|
||||
var width = parseFloat(jQuery("#nothiddendiv").css("width")), height = parseFloat(jQuery("#nothiddendiv").css("height"));
|
||||
jQuery("#nothiddendiv").css({ width: -1, height: -1 });
|
||||
equals( parseFloat(jQuery("#nothiddendiv").css("width")), width, "Test negative width ignored")
|
||||
equals( parseFloat(jQuery("#nothiddendiv").css("height")), height, "Test negative height ignored")
|
||||
|
||||
equals( jQuery('<div style="display: none;">').css('display'), 'none', 'Styles on disconnected nodes');
|
||||
equals( jQuery("<div style='display: none;'>").css("display"), "none", "Styles on disconnected nodes");
|
||||
|
||||
jQuery('#floatTest').css({'float': 'right'});
|
||||
equals( jQuery('#floatTest').css('float'), 'right', 'Modified CSS float using "float": Assert float is right');
|
||||
jQuery('#floatTest').css({'font-size': '30px'});
|
||||
equals( jQuery('#floatTest').css('font-size'), '30px', 'Modified CSS font-size: Assert font-size is 30px');
|
||||
jQuery("#floatTest").css({"float": "right"});
|
||||
equals( jQuery("#floatTest").css("float"), "right", "Modified CSS float using \"float\": Assert float is right");
|
||||
jQuery("#floatTest").css({"font-size": "30px"});
|
||||
equals( jQuery("#floatTest").css("font-size"), "30px", "Modified CSS font-size: Assert font-size is 30px");
|
||||
|
||||
jQuery.each("0,0.25,0.5,0.75,1".split(','), function(i, n) {
|
||||
jQuery('#foo').css({opacity: n});
|
||||
equals( jQuery('#foo').css('opacity'), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" );
|
||||
jQuery('#foo').css({opacity: parseFloat(n)});
|
||||
equals( jQuery('#foo').css('opacity'), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" );
|
||||
jQuery.each("0,0.25,0.5,0.75,1".split(","), function(i, n) {
|
||||
jQuery("#foo").css({opacity: n});
|
||||
equals( jQuery("#foo").css("opacity"), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" );
|
||||
jQuery("#foo").css({opacity: parseFloat(n)});
|
||||
equals( jQuery("#foo").css("opacity"), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" );
|
||||
});
|
||||
jQuery('#foo').css({opacity: ''});
|
||||
equals( jQuery('#foo').css('opacity'), '1', "Assert opacity is 1 when set to an empty String" );
|
||||
jQuery("#foo").css({opacity: ""});
|
||||
equals( jQuery("#foo").css("opacity"), "1", "Assert opacity is 1 when set to an empty String" );
|
||||
|
||||
equals( jQuery('#empty').css('opacity'), '0', "Assert opacity is accessible via filter property set in stylesheet in IE" );
|
||||
jQuery('#empty').css({ opacity: '1' });
|
||||
equals( jQuery('#empty').css('opacity'), '1', "Assert opacity is taken from style attribute when set vs stylesheet in IE with filters" );
|
||||
equals( jQuery("#empty").css("opacity"), "0", "Assert opacity is accessible via filter property set in stylesheet in IE" );
|
||||
jQuery("#empty").css({ opacity: "1" });
|
||||
equals( jQuery("#empty").css("opacity"), "1", "Assert opacity is taken from style attribute when set vs stylesheet in IE with filters" );
|
||||
jQuery.support.opacity ?
|
||||
ok(true, "Requires the same number of tests"):
|
||||
ok( ~jQuery("#empty")[0].currentStyle.filter.indexOf("gradient"), "Assert setting opacity doesn't overwrite other filters of the stylesheet in IE" );
|
||||
|
||||
var div = jQuery('#nothiddendiv'), child = jQuery('#nothiddendivchild');
|
||||
var div = jQuery("#nothiddendiv"), child = jQuery("#nothiddendivchild");
|
||||
|
||||
equals( parseInt(div.css("fontSize")), 16, "Verify fontSize px set." );
|
||||
equals( parseInt(div.css("font-size")), 16, "Verify fontSize px set." );
|
||||
|
@ -107,7 +110,7 @@ test("css(String|Hash)", function() {
|
|||
|
||||
test("css() explicit and relative values", function() {
|
||||
expect(9);
|
||||
var $elem = jQuery('#nothiddendiv');
|
||||
var $elem = jQuery("#nothiddendiv");
|
||||
|
||||
$elem.css({ width: 1, height: 1 });
|
||||
equals( $elem.width(), 1, "Initial css set or width/height works (hash)" );
|
||||
|
@ -140,28 +143,28 @@ test("css() explicit and relative values", function() {
|
|||
test("css(String, Object)", function() {
|
||||
expect(22);
|
||||
|
||||
ok( jQuery('#nothiddendiv').is(':visible'), 'Modifying CSS display: Assert element is visible');
|
||||
jQuery('#nothiddendiv').css("display", 'none');
|
||||
ok( !jQuery('#nothiddendiv').is(':visible'), 'Modified CSS display: Assert element is hidden');
|
||||
jQuery('#nothiddendiv').css("display", 'block');
|
||||
ok( jQuery('#nothiddendiv').is(':visible'), 'Modified CSS display: Assert element is visible');
|
||||
ok( jQuery("#nothiddendiv").is(":visible"), "Modifying CSS display: Assert element is visible");
|
||||
jQuery("#nothiddendiv").css("display", "none");
|
||||
ok( !jQuery("#nothiddendiv").is(":visible"), "Modified CSS display: Assert element is hidden");
|
||||
jQuery("#nothiddendiv").css("display", "block");
|
||||
ok( jQuery("#nothiddendiv").is(":visible"), "Modified CSS display: Assert element is visible");
|
||||
|
||||
jQuery("#nothiddendiv").css("top", "-1em");
|
||||
ok( jQuery("#nothiddendiv").css("top"), -16, "Check negative number in EMs." );
|
||||
|
||||
jQuery('#floatTest').css('float', 'left');
|
||||
equals( jQuery('#floatTest').css('float'), 'left', 'Modified CSS float using "float": Assert float is left');
|
||||
jQuery('#floatTest').css('font-size', '20px');
|
||||
equals( jQuery('#floatTest').css('font-size'), '20px', 'Modified CSS font-size: Assert font-size is 20px');
|
||||
jQuery("#floatTest").css("float", "left");
|
||||
equals( jQuery("#floatTest").css("float"), "left", "Modified CSS float using \"float\": Assert float is left");
|
||||
jQuery("#floatTest").css("font-size", "20px");
|
||||
equals( jQuery("#floatTest").css("font-size"), "20px", "Modified CSS font-size: Assert font-size is 20px");
|
||||
|
||||
jQuery.each("0,0.25,0.5,0.75,1".split(','), function(i, n) {
|
||||
jQuery('#foo').css('opacity', n);
|
||||
equals( jQuery('#foo').css('opacity'), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" );
|
||||
jQuery('#foo').css('opacity', parseFloat(n));
|
||||
equals( jQuery('#foo').css('opacity'), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" );
|
||||
jQuery.each("0,0.25,0.5,0.75,1".split(","), function(i, n) {
|
||||
jQuery("#foo").css("opacity", n);
|
||||
equals( jQuery("#foo").css("opacity"), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" );
|
||||
jQuery("#foo").css("opacity", parseFloat(n));
|
||||
equals( jQuery("#foo").css("opacity"), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" );
|
||||
});
|
||||
jQuery('#foo').css('opacity', '');
|
||||
equals( jQuery('#foo').css('opacity'), '1', "Assert opacity is 1 when set to an empty String" );
|
||||
jQuery("#foo").css("opacity", "");
|
||||
equals( jQuery("#foo").css("opacity"), "1", "Assert opacity is 1 when set to an empty String" );
|
||||
|
||||
// using contents will get comments regular, text, and comment nodes
|
||||
var j = jQuery("#nonnodes").contents();
|
||||
|
@ -181,7 +184,7 @@ test("css(String, Object)", function() {
|
|||
// Test for Bug #5509
|
||||
var success = true;
|
||||
try {
|
||||
jQuery('#foo').css("backgroundColor", "rgba(0, 0, 0, 0.1)");
|
||||
jQuery("#foo").css("backgroundColor", "rgba(0, 0, 0, 0.1)");
|
||||
}
|
||||
catch (e) {
|
||||
success = false;
|
||||
|
@ -192,19 +195,19 @@ test("css(String, Object)", function() {
|
|||
if ( !jQuery.support.opacity ) {
|
||||
test("css(String, Object) for MSIE", function() {
|
||||
// for #1438, IE throws JS error when filter exists but doesn't have opacity in it
|
||||
jQuery('#foo').css("filter", "progid:DXImageTransform.Microsoft.Chroma(color='red');");
|
||||
equals( jQuery('#foo').css('opacity'), '1', "Assert opacity is 1 when a different filter is set in IE, #1438" );
|
||||
jQuery("#foo").css("filter", "progid:DXImageTransform.Microsoft.Chroma(color='red');");
|
||||
equals( jQuery("#foo").css("opacity"), "1", "Assert opacity is 1 when a different filter is set in IE, #1438" );
|
||||
|
||||
var filterVal = "progid:DXImageTransform.Microsoft.Alpha(opacity=30) progid:DXImageTransform.Microsoft.Blur(pixelradius=5)";
|
||||
var filterVal2 = "progid:DXImageTransform.Microsoft.alpha(opacity=100) progid:DXImageTransform.Microsoft.Blur(pixelradius=5)";
|
||||
var filterVal3 = "progid:DXImageTransform.Microsoft.Blur(pixelradius=5)";
|
||||
jQuery('#foo').css("filter", filterVal);
|
||||
equals( jQuery('#foo').css("filter"), filterVal, "css('filter', val) works" );
|
||||
jQuery('#foo').css("opacity", 1);
|
||||
equals( jQuery('#foo').css("filter"), filterVal2, "Setting opacity in IE doesn't duplicate opacity filter" );
|
||||
equals( jQuery('#foo').css("opacity"), 1, "Setting opacity in IE with other filters works" );
|
||||
jQuery('#foo').css("filter", filterVal3).css("opacity", 1);
|
||||
ok( jQuery('#foo').css("filter").indexOf(filterVal3) !== -1, "Setting opacity in IE doesn't clobber other filters" );
|
||||
jQuery("#foo").css("filter", filterVal);
|
||||
equals( jQuery("#foo").css("filter"), filterVal, "css('filter', val) works" );
|
||||
jQuery("#foo").css("opacity", 1);
|
||||
equals( jQuery("#foo").css("filter"), filterVal2, "Setting opacity in IE doesn't duplicate opacity filter" );
|
||||
equals( jQuery("#foo").css("opacity"), 1, "Setting opacity in IE with other filters works" );
|
||||
jQuery("#foo").css("filter", filterVal3).css("opacity", 1);
|
||||
ok( jQuery("#foo").css("filter").indexOf(filterVal3) !== -1, "Setting opacity in IE doesn't clobber other filters" );
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -343,14 +346,14 @@ test("jQuery.css(elem, 'height') doesn't clear radio buttons (bug #1095)", funct
|
|||
test(":visible selector works properly on table elements (bug #4512)", function () {
|
||||
expect(1);
|
||||
|
||||
jQuery('#table').html('<tr><td style="display:none">cell</td><td>cell</td></tr>');
|
||||
equals(jQuery('#table td:visible').length, 1, "hidden cell is not perceived as visible");
|
||||
jQuery("#table").html("<tr><td style='display:none'>cell</td><td>cell</td></tr>");
|
||||
equals(jQuery("#table td:visible").length, 1, "hidden cell is not perceived as visible");
|
||||
});
|
||||
|
||||
test(":visible selector works properly on children with a hidden parent (bug #4512)", function () {
|
||||
expect(1);
|
||||
jQuery('#table').css('display', 'none').html('<tr><td>cell</td><td>cell</td></tr>');
|
||||
equals(jQuery('#table td:visible').length, 0, "hidden cell children not perceived as visible");
|
||||
jQuery("#table").css("display", "none").html("<tr><td>cell</td><td>cell</td></tr>");
|
||||
equals(jQuery("#table td:visible").length, 0, "hidden cell children not perceived as visible");
|
||||
});
|
||||
|
||||
test("internal ref to elem.runtimeStyle (bug #7608)", function () {
|
||||
|
@ -375,5 +378,19 @@ test("marginRight computed style (bug #3333)", function() {
|
|||
marginRight: 0
|
||||
});
|
||||
|
||||
equals($div.css("marginRight"), "0px");
|
||||
equals($div.css("marginRight"), "0px", "marginRight correctly calculated with a width and display block");
|
||||
});
|
||||
|
||||
test("jQuery.cssProps behavior, (bug #8402)", function() {
|
||||
var div = jQuery( "<div>" ).appendTo(document.body).css({
|
||||
position: "absolute",
|
||||
top: 0,
|
||||
left: 10
|
||||
});
|
||||
jQuery.cssProps.top = "left";
|
||||
equal( div.css("top"), "10px", "the fixed property is used when accessing the computed style");
|
||||
div.css("top", "100px");
|
||||
equal( div[0].style.left, "100px", "the fixed property is used when setting the style");
|
||||
// cleanup jQuery.cssProps
|
||||
jQuery.cssProps.top = undefined;
|
||||
});
|
||||
|
|
|
@ -283,11 +283,11 @@ test(".data(String) and .data(String, Object)", function() {
|
|||
|
||||
// #3748
|
||||
var $elem = jQuery({exists:true});
|
||||
equals( $elem.data('nothing'), undefined, "Non-existent data returns undefined");
|
||||
equals( $elem.data('null',null).data('null'), null, "null's are preserved");
|
||||
equals( $elem.data('emptyString','').data('emptyString'), '', "Empty strings are preserved");
|
||||
equals( $elem.data('false',false).data('false'), false, "false's are preserved");
|
||||
equals( $elem.data('exists'), undefined, "Existing data is not returned" );
|
||||
equals( $elem.data("nothing"), undefined, "Non-existent data returns undefined");
|
||||
equals( $elem.data("null", null).data("null"), null, "null's are preserved");
|
||||
equals( $elem.data("emptyString", "").data("emptyString"), "", "Empty strings are preserved");
|
||||
equals( $elem.data("false", false).data("false"), false, "false's are preserved");
|
||||
equals( $elem.data("exists"), undefined, "Existing data is not returned" );
|
||||
|
||||
// Clean up
|
||||
$elem.removeData();
|
||||
|
@ -316,7 +316,7 @@ test("data-* attributes", function() {
|
|||
|
||||
div.remove();
|
||||
|
||||
child.appendTo('#main');
|
||||
child.appendTo("#main");
|
||||
equals( child.data("myobj"), "old data", "Value accessed from data-* attribute");
|
||||
|
||||
child.data("myobj", "replaced");
|
||||
|
@ -365,19 +365,19 @@ test("data-* attributes", function() {
|
|||
.attr("data-null", "null")
|
||||
.attr("data-string", "test");
|
||||
|
||||
strictEqual( child.data('true'), true, "Primitive true read from attribute");
|
||||
strictEqual( child.data('false'), false, "Primitive false read from attribute");
|
||||
strictEqual( child.data('five'), 5, "Primitive number read from attribute");
|
||||
strictEqual( child.data('point'), 5.5, "Primitive number read from attribute");
|
||||
strictEqual( child.data('pointe'), 5500, "Primitive number read from attribute");
|
||||
strictEqual( child.data('pointbad'), "5..5", "Bad number read from attribute");
|
||||
strictEqual( child.data('pointbad2'), "-.", "Bad number read from attribute");
|
||||
strictEqual( child.data('badjson'), "{123}", "Bad number read from attribute");
|
||||
strictEqual( child.data('badjson2'), "[abc]", "Bad number read from attribute");
|
||||
strictEqual( child.data('empty'), "", "Empty string read from attribute");
|
||||
strictEqual( child.data('space'), " ", "Empty string read from attribute");
|
||||
strictEqual( child.data('null'), null, "Primitive null read from attribute");
|
||||
strictEqual( child.data('string'), "test", "Typical string read from attribute");
|
||||
strictEqual( child.data("true"), true, "Primitive true read from attribute");
|
||||
strictEqual( child.data("false"), false, "Primitive false read from attribute");
|
||||
strictEqual( child.data("five"), 5, "Primitive number read from attribute");
|
||||
strictEqual( child.data("point"), 5.5, "Primitive number read from attribute");
|
||||
strictEqual( child.data("pointe"), 5500, "Primitive number read from attribute");
|
||||
strictEqual( child.data("pointbad"), "5..5", "Bad number read from attribute");
|
||||
strictEqual( child.data("pointbad2"), "-.", "Bad number read from attribute");
|
||||
strictEqual( child.data("badjson"), "{123}", "Bad number read from attribute");
|
||||
strictEqual( child.data("badjson2"), "[abc]", "Bad number read from attribute");
|
||||
strictEqual( child.data("empty"), "", "Empty string read from attribute");
|
||||
strictEqual( child.data("space"), " ", "Empty string read from attribute");
|
||||
strictEqual( child.data("null"), null, "Primitive null read from attribute");
|
||||
strictEqual( child.data("string"), "test", "Typical string read from attribute");
|
||||
|
||||
child.remove();
|
||||
|
||||
|
@ -401,12 +401,12 @@ test("data-* attributes", function() {
|
|||
same(jQuery(elem).data("stuff"), [2,8], "Check stuff property");
|
||||
break;
|
||||
default:
|
||||
ok(false, ["Assertion failed on index ", index, ", with data ", data].join(''));
|
||||
ok(false, ["Assertion failed on index ", index, ", with data ", data].join(""));
|
||||
}
|
||||
}
|
||||
|
||||
var metadata = '<ol><li class="test test2" data-foo="bar" data-bar="baz" data-arr="[1,2]">Some stuff</li><li class="test test2" data-test="bar" data-bar="baz">Some stuff</li><li class="test test2" data-zoooo="bar" data-bar=\'{"test":"baz"}\'>Some stuff</li><li class="test test2" data-number=true data-stuff="[2,8]">Some stuff</li></ol>',
|
||||
elem = jQuery(metadata).appendTo('#main');
|
||||
var metadata = "<ol><li class='test test2' data-foo='bar' data-bar='baz' data-arr='[1,2]'>Some stuff</li><li class='test test2' data-test='bar' data-bar='baz'>Some stuff</li><li class='test test2' data-zoooo='bar' data-bar='{\"test\":\"baz\"}'>Some stuff</li><li class='test test2' data-number=true data-stuff='[2,8]'>Some stuff</li></ol>",
|
||||
elem = jQuery(metadata).appendTo("#main");
|
||||
|
||||
elem.find("li").each(testData);
|
||||
elem.remove();
|
||||
|
@ -483,7 +483,7 @@ if (window.JSON && window.JSON.stringify) {
|
|||
var obj = { foo: "bar" };
|
||||
jQuery.data(obj, "hidden", true);
|
||||
|
||||
equals( JSON.stringify(obj), '{"foo":"bar"}', "Expando is hidden from JSON.stringify" );
|
||||
equals( JSON.stringify(obj), "{\"foo\":\"bar\"}", "Expando is hidden from JSON.stringify" );
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ function testWidth( val ) {
|
|||
equals( blah.width( val(10) ), blah, "Make sure that setting a width on an empty set returns the set." );
|
||||
equals( blah.width(), null, "Make sure 'null' is returned on an empty set");
|
||||
|
||||
jQuery.removeData($div[0], 'olddisplay', true);
|
||||
jQuery.removeData($div[0], "olddisplay", true);
|
||||
}
|
||||
|
||||
test("width()", function() {
|
||||
|
@ -83,7 +83,7 @@ function testHeight( val ) {
|
|||
equals( blah.height( val(10) ), blah, "Make sure that setting a height on an empty set returns the set." );
|
||||
equals( blah.height(), null, "Make sure 'null' is returned on an empty set");
|
||||
|
||||
jQuery.removeData($div[0], 'olddisplay', true);
|
||||
jQuery.removeData($div[0], "olddisplay", true);
|
||||
}
|
||||
|
||||
test("height()", function() {
|
||||
|
@ -132,7 +132,7 @@ test("innerWidth()", function() {
|
|||
equals( div.innerWidth(), 0, "Make sure that disconnected nodes are handled." );
|
||||
|
||||
div.remove();
|
||||
jQuery.removeData($div[0], 'olddisplay', true);
|
||||
jQuery.removeData($div[0], "olddisplay", true);
|
||||
});
|
||||
|
||||
test("innerHeight()", function() {
|
||||
|
@ -161,7 +161,7 @@ test("innerHeight()", function() {
|
|||
equals( div.innerHeight(), 0, "Make sure that disconnected nodes are handled." );
|
||||
|
||||
div.remove();
|
||||
jQuery.removeData($div[0], 'olddisplay', true);
|
||||
jQuery.removeData($div[0], "olddisplay", true);
|
||||
});
|
||||
|
||||
test("outerWidth()", function() {
|
||||
|
@ -191,7 +191,7 @@ test("outerWidth()", function() {
|
|||
equals( div.outerWidth(), 0, "Make sure that disconnected nodes are handled." );
|
||||
|
||||
div.remove();
|
||||
jQuery.removeData($div[0], 'olddisplay', true);
|
||||
jQuery.removeData($div[0], "olddisplay", true);
|
||||
});
|
||||
|
||||
test("outerHeight()", function() {
|
||||
|
@ -220,5 +220,5 @@ test("outerHeight()", function() {
|
|||
equals( div.outerHeight(), 0, "Make sure that disconnected nodes are handled." );
|
||||
|
||||
div.remove();
|
||||
jQuery.removeData($div[0], 'olddisplay', true);
|
||||
jQuery.removeData($div[0], "olddisplay", true);
|
||||
});
|
||||
|
|
98
test/unit/effects.js
vendored
98
test/unit/effects.js
vendored
|
@ -62,7 +62,7 @@ test("show()", function() {
|
|||
});
|
||||
|
||||
// #show-tests * is set display: none in CSS
|
||||
jQuery("#main").append('<div id="show-tests"><div><p><a href="#"></a></p><code></code><pre></pre><span></span></div><table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody></table><ul><li></li></ul></div><table id="test-table"></table>');
|
||||
jQuery("#main").append("<div id='show-tests'><div><p><a href='#'></a></p><code></code><pre></pre><span></span></div><table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody></table><ul><li></li></ul></div><table id='test-table'></table>");
|
||||
|
||||
var old = jQuery("#test-table").show().css("display") !== "table";
|
||||
jQuery("#test-table").remove();
|
||||
|
@ -96,7 +96,7 @@ test("show(Number) - other displays", function() {
|
|||
stop();
|
||||
|
||||
// #show-tests * is set display: none in CSS
|
||||
jQuery("#main").append('<div id="show-tests"><div><p><a href="#"></a></p><code></code><pre></pre><span></span></div><table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody></table><ul><li></li></ul></div><table id="test-table"></table>');
|
||||
jQuery("#main").append("<div id='show-tests'><div><p><a href='#'></a></p><code></code><pre></pre><span></span></div><table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody></table><ul><li></li></ul></div><table id='test-table'></table>");
|
||||
|
||||
var old = jQuery("#test-table").show().css("display") !== "table",
|
||||
num = 0;
|
||||
|
@ -138,11 +138,11 @@ test("Persist correct display value", function() {
|
|||
stop();
|
||||
|
||||
// #show-tests * is set display: none in CSS
|
||||
jQuery("#main").append('<div id="show-tests"><span style="position:absolute;">foo</span></div>');
|
||||
jQuery("#main").append("<div id='show-tests'><span style='position:absolute;'>foo</span></div>");
|
||||
|
||||
var $span = jQuery("#show-tests span"),
|
||||
displayNone = $span.css("display"),
|
||||
display = '', num = 0;
|
||||
display = "", num = 0;
|
||||
|
||||
$span.show();
|
||||
|
||||
|
@ -165,10 +165,10 @@ test("Persist correct display value", function() {
|
|||
test("animate(Hash, Object, Function)", function() {
|
||||
expect(1);
|
||||
stop();
|
||||
var hash = {opacity: 'show'};
|
||||
var hash = {opacity: "show"};
|
||||
var hashCopy = jQuery.extend({}, hash);
|
||||
jQuery('#foo').animate(hash, 0, function() {
|
||||
equals( hash.opacity, hashCopy.opacity, 'Check if animate changed the hash parameter' );
|
||||
jQuery("#foo").animate(hash, 0, function() {
|
||||
equals( hash.opacity, hashCopy.opacity, "Check if animate changed the hash parameter" );
|
||||
start();
|
||||
});
|
||||
});
|
||||
|
@ -193,7 +193,7 @@ test("animate block as inline width/height", function() {
|
|||
if ( jQuery.support.inlineBlockNeedsLayout || expected === "inline-block" ) {
|
||||
stop();
|
||||
|
||||
jQuery("#foo").css({ display: "inline", width: '', height: '' }).animate({ width: 42, height: 42 }, 100, function() {
|
||||
jQuery("#foo").css({ display: "inline", width: "", height: "" }).animate({ width: 42, height: 42 }, 100, function() {
|
||||
equals( jQuery(this).css("display"), jQuery.support.inlineBlockNeedsLayout ? "inline" : "inline-block", "inline-block was set on non-floated inline element when animating width/height" );
|
||||
equals( this.offsetWidth, 42, "width was animated" );
|
||||
equals( this.offsetHeight, 42, "height was animated" );
|
||||
|
@ -218,9 +218,9 @@ test("animate native inline width/height", function() {
|
|||
|
||||
if ( jQuery.support.inlineBlockNeedsLayout || expected === "inline-block" ) {
|
||||
stop();
|
||||
jQuery("#foo").css({ display: "", width: '', height: '' })
|
||||
.append('<span>text</span>')
|
||||
.children('span')
|
||||
jQuery("#foo").css({ display: "", width: "", height: "" })
|
||||
.append("<span>text</span>")
|
||||
.children("span")
|
||||
.animate({ width: 42, height: 42 }, 100, function() {
|
||||
equals( jQuery(this).css("display"), "inline-block", "inline-block was set on non-floated inline element when animating width/height" );
|
||||
equals( this.offsetWidth, 42, "width was animated" );
|
||||
|
@ -317,13 +317,13 @@ test("animate option (queue === false)", function () {
|
|||
var order = [];
|
||||
|
||||
var $foo = jQuery("#foo");
|
||||
$foo.animate({width:'100px'}, 3000, function () {
|
||||
$foo.animate({width:"100px"}, 3000, function () {
|
||||
// should finish after unqueued animation so second
|
||||
order.push(2);
|
||||
same( order, [ 1, 2 ], "Animations finished in the correct order" );
|
||||
start();
|
||||
});
|
||||
$foo.animate({fontSize:'2em'}, {queue:false, duration:10, complete:function () {
|
||||
$foo.animate({fontSize:"2em"}, {queue:false, duration:10, complete:function () {
|
||||
// short duration and out of queue so should finish first
|
||||
order.push(1);
|
||||
}});
|
||||
|
@ -433,7 +433,7 @@ test("stop()", function() {
|
|||
var w = 0;
|
||||
$foo.hide().width(200).width();
|
||||
|
||||
$foo.animate({ width:'show' }, 1000);
|
||||
$foo.animate({ width: "show" }, 1000);
|
||||
setTimeout(function(){
|
||||
var nw = $foo.width();
|
||||
notEqual( nw, w, "An animation occurred " + nw + "px " + w + "px");
|
||||
|
@ -458,9 +458,9 @@ test("stop() - several in queue", function() {
|
|||
var w = 0;
|
||||
$foo.hide().width(200).width();
|
||||
|
||||
$foo.animate({ width:'show' }, 1000);
|
||||
$foo.animate({ width:'hide' }, 1000);
|
||||
$foo.animate({ width:'show' }, 1000);
|
||||
$foo.animate({ width: "show" }, 1000);
|
||||
$foo.animate({ width: "hide" }, 1000);
|
||||
$foo.animate({ width: "show" }, 1000);
|
||||
setTimeout(function(){
|
||||
equals( $foo.queue().length, 3, "All 3 still in the queue" );
|
||||
var nw = $foo.width();
|
||||
|
@ -483,9 +483,9 @@ test("stop(clearQueue)", function() {
|
|||
var w = 0;
|
||||
$foo.hide().width(200).width();
|
||||
|
||||
$foo.animate({ width:'show' }, 1000);
|
||||
$foo.animate({ width:'hide' }, 1000);
|
||||
$foo.animate({ width:'show' }, 1000);
|
||||
$foo.animate({ width: "show" }, 1000);
|
||||
$foo.animate({ width: "hide" }, 1000);
|
||||
$foo.animate({ width: "show" }, 1000);
|
||||
setTimeout(function(){
|
||||
var nw = $foo.width();
|
||||
ok( nw != w, "An animation occurred " + nw + "px " + w + "px");
|
||||
|
@ -510,10 +510,10 @@ test("stop(clearQueue, gotoEnd)", function() {
|
|||
var w = 0;
|
||||
$foo.hide().width(200).width();
|
||||
|
||||
$foo.animate({ width:'show' }, 1000);
|
||||
$foo.animate({ width:'hide' }, 1000);
|
||||
$foo.animate({ width:'show' }, 1000);
|
||||
$foo.animate({ width:'hide' }, 1000);
|
||||
$foo.animate({ width: "show" }, 1000);
|
||||
$foo.animate({ width: "hide" }, 1000);
|
||||
$foo.animate({ width: "show" }, 1000);
|
||||
$foo.animate({ width: "hide" }, 1000);
|
||||
setTimeout(function(){
|
||||
var nw = $foo.width();
|
||||
ok( nw != w, "An animation occurred " + nw + "px " + w + "px");
|
||||
|
@ -783,7 +783,7 @@ jQuery.each( {
|
|||
});
|
||||
|
||||
jQuery.fn.saveState = function(hiddenOverflow){
|
||||
var check = ['opacity','height','width','display','overflow'];
|
||||
var check = ["opacity", "height", "width", "display", "overflow"];
|
||||
expect(check.length);
|
||||
|
||||
stop();
|
||||
|
@ -804,64 +804,64 @@ jQuery.checkState = function(){
|
|||
});
|
||||
|
||||
// manually clean data on modified element
|
||||
jQuery.removeData(this, 'olddisplay', true);
|
||||
jQuery.removeData(this, "olddisplay", true);
|
||||
|
||||
start();
|
||||
}
|
||||
};
|
||||
|
||||
// Chaining Tests
|
||||
test("Chain fadeOut fadeIn", function() {
|
||||
jQuery('#fadein div').saveState().fadeOut('fast').fadeIn('fast',jQuery.checkState);
|
||||
jQuery("#fadein div").saveState().fadeOut("fast").fadeIn("fast",jQuery.checkState);
|
||||
});
|
||||
test("Chain fadeIn fadeOut", function() {
|
||||
jQuery('#fadeout div').saveState().fadeIn('fast').fadeOut('fast',jQuery.checkState);
|
||||
jQuery("#fadeout div").saveState().fadeIn("fast").fadeOut("fast",jQuery.checkState);
|
||||
});
|
||||
|
||||
test("Chain hide show", function() {
|
||||
jQuery('#show div').saveState(jQuery.support.shrinkWrapBlocks).hide('fast').show('fast',jQuery.checkState);
|
||||
jQuery("#show div").saveState(jQuery.support.shrinkWrapBlocks).hide("fast").show("fast",jQuery.checkState);
|
||||
});
|
||||
test("Chain show hide", function() {
|
||||
jQuery('#hide div').saveState(jQuery.support.shrinkWrapBlocks).show('fast').hide('fast',jQuery.checkState);
|
||||
jQuery("#hide div").saveState(jQuery.support.shrinkWrapBlocks).show("fast").hide("fast",jQuery.checkState);
|
||||
});
|
||||
test("Chain show hide with easing and callback", function() {
|
||||
jQuery('#hide div').saveState().show('fast').hide('fast','linear',jQuery.checkState);
|
||||
jQuery("#hide div").saveState().show("fast").hide("fast","linear",jQuery.checkState);
|
||||
});
|
||||
|
||||
test("Chain toggle in", function() {
|
||||
jQuery('#togglein div').saveState(jQuery.support.shrinkWrapBlocks).toggle('fast').toggle('fast',jQuery.checkState);
|
||||
jQuery("#togglein div").saveState(jQuery.support.shrinkWrapBlocks).toggle("fast").toggle("fast",jQuery.checkState);
|
||||
});
|
||||
test("Chain toggle out", function() {
|
||||
jQuery('#toggleout div').saveState(jQuery.support.shrinkWrapBlocks).toggle('fast').toggle('fast',jQuery.checkState);
|
||||
jQuery("#toggleout div").saveState(jQuery.support.shrinkWrapBlocks).toggle("fast").toggle("fast",jQuery.checkState);
|
||||
});
|
||||
test("Chain toggle out with easing and callback", function() {
|
||||
jQuery('#toggleout div').saveState(jQuery.support.shrinkWrapBlocks).toggle('fast').toggle('fast','linear',jQuery.checkState);
|
||||
jQuery("#toggleout div").saveState(jQuery.support.shrinkWrapBlocks).toggle("fast").toggle("fast","linear",jQuery.checkState);
|
||||
});
|
||||
test("Chain slideDown slideUp", function() {
|
||||
jQuery('#slidedown div').saveState(jQuery.support.shrinkWrapBlocks).slideDown('fast').slideUp('fast',jQuery.checkState);
|
||||
jQuery("#slidedown div").saveState(jQuery.support.shrinkWrapBlocks).slideDown("fast").slideUp("fast",jQuery.checkState);
|
||||
});
|
||||
test("Chain slideUp slideDown", function() {
|
||||
jQuery('#slideup div').saveState(jQuery.support.shrinkWrapBlocks).slideUp('fast').slideDown('fast',jQuery.checkState);
|
||||
jQuery("#slideup div").saveState(jQuery.support.shrinkWrapBlocks).slideUp("fast").slideDown("fast",jQuery.checkState);
|
||||
});
|
||||
test("Chain slideUp slideDown with easing and callback", function() {
|
||||
jQuery('#slideup div').saveState(jQuery.support.shrinkWrapBlocks).slideUp('fast').slideDown('fast','linear',jQuery.checkState);
|
||||
jQuery("#slideup div").saveState(jQuery.support.shrinkWrapBlocks).slideUp("fast").slideDown("fast","linear",jQuery.checkState);
|
||||
});
|
||||
|
||||
test("Chain slideToggle in", function() {
|
||||
jQuery('#slidetogglein div').saveState(jQuery.support.shrinkWrapBlocks).slideToggle('fast').slideToggle('fast',jQuery.checkState);
|
||||
jQuery("#slidetogglein div").saveState(jQuery.support.shrinkWrapBlocks).slideToggle("fast").slideToggle("fast",jQuery.checkState);
|
||||
});
|
||||
test("Chain slideToggle out", function() {
|
||||
jQuery('#slidetoggleout div').saveState(jQuery.support.shrinkWrapBlocks).slideToggle('fast').slideToggle('fast',jQuery.checkState);
|
||||
jQuery("#slidetoggleout div").saveState(jQuery.support.shrinkWrapBlocks).slideToggle("fast").slideToggle("fast",jQuery.checkState);
|
||||
});
|
||||
|
||||
test("Chain fadeToggle in", function() {
|
||||
jQuery('#fadetogglein div').saveState().fadeToggle('fast').fadeToggle('fast',jQuery.checkState);
|
||||
jQuery("#fadetogglein div").saveState().fadeToggle("fast").fadeToggle("fast",jQuery.checkState);
|
||||
});
|
||||
test("Chain fadeToggle out", function() {
|
||||
jQuery('#fadetoggleout div').saveState().fadeToggle('fast').fadeToggle('fast',jQuery.checkState);
|
||||
jQuery("#fadetoggleout div").saveState().fadeToggle("fast").fadeToggle("fast",jQuery.checkState);
|
||||
});
|
||||
|
||||
test("Chain fadeTo 0.5 1.0 with easing and callback)", function() {
|
||||
jQuery('#fadeto div').saveState().fadeTo('fast',0.5).fadeTo('fast',1.0,'linear',jQuery.checkState);
|
||||
jQuery("#fadeto div").saveState().fadeTo("fast",0.5).fadeTo("fast",1.0,"linear",jQuery.checkState);
|
||||
});
|
||||
|
||||
jQuery.makeTest = function( text ){
|
||||
|
@ -903,23 +903,23 @@ test("animate with per-property easing", function(){
|
|||
var _test2_called = false;
|
||||
var _default_test_called = false;
|
||||
|
||||
jQuery.easing['_test1'] = function() {
|
||||
jQuery.easing["_test1"] = function() {
|
||||
_test1_called = true;
|
||||
};
|
||||
|
||||
jQuery.easing['_test2'] = function() {
|
||||
jQuery.easing["_test2"] = function() {
|
||||
_test2_called = true;
|
||||
};
|
||||
|
||||
jQuery.easing['_default_test'] = function() {
|
||||
jQuery.easing["_default_test"] = function() {
|
||||
_default_test_called = true;
|
||||
};
|
||||
|
||||
jQuery({a:0,b:0,c:0}).animate({
|
||||
a: [100, '_test1'],
|
||||
b: [100, '_test2'],
|
||||
a: [100, "_test1"],
|
||||
b: [100, "_test2"],
|
||||
c: 100
|
||||
}, 400, '_default_test', function(){
|
||||
}, 400, "_default_test", function(){
|
||||
start();
|
||||
ok(_test1_called, "Easing function (1) called");
|
||||
ok(_test2_called, "Easing function (2) called");
|
||||
|
|
|
@ -305,7 +305,7 @@ test("bind/delegate bubbling, isDefaultPrevented", function() {
|
|||
fakeClick = function($jq) {
|
||||
// Use a native click so we don't get jQuery simulated bubbling
|
||||
if ( document.createEvent ) {
|
||||
var e = document.createEvent( 'MouseEvents' );
|
||||
var e = document.createEvent( "MouseEvents" );
|
||||
e.initEvent( "click", true, true );
|
||||
$jq[0].dispatchEvent(e);
|
||||
}
|
||||
|
@ -347,7 +347,7 @@ test("bind(), iframes", function() {
|
|||
|
||||
jQuery("div", doc).bind("click", function() {
|
||||
ok( true, "Binding to element inside iframe" );
|
||||
}).click().unbind('click');
|
||||
}).click().unbind("click");
|
||||
});
|
||||
|
||||
test("bind(), trigger change on select", function() {
|
||||
|
@ -357,8 +357,8 @@ test("bind(), trigger change on select", function() {
|
|||
equals( event.data, counter++, "Event.data is not a global event object" );
|
||||
};
|
||||
jQuery("#form select").each(function(i){
|
||||
jQuery(this).bind('change', i, selectOnChange);
|
||||
}).trigger('change');
|
||||
jQuery(this).bind("change", i, selectOnChange);
|
||||
}).trigger("change");
|
||||
});
|
||||
|
||||
test("bind(), namespaced events, cloned events", 18, function() {
|
||||
|
@ -646,23 +646,23 @@ test("unbind(type)", function() {
|
|||
}
|
||||
|
||||
message = "unbind passing function";
|
||||
$elem.bind('error1', error).unbind('error1',error).triggerHandler('error1');
|
||||
$elem.bind("error1", error).unbind("error1", error).triggerHandler("error1");
|
||||
|
||||
message = "unbind all from event";
|
||||
$elem.bind('error1', error).unbind('error1').triggerHandler('error1');
|
||||
$elem.bind("error1", error).unbind("error1").triggerHandler("error1");
|
||||
|
||||
message = "unbind all";
|
||||
$elem.bind('error1', error).unbind().triggerHandler('error1');
|
||||
$elem.bind("error1", error).unbind().triggerHandler("error1");
|
||||
|
||||
message = "unbind many with function";
|
||||
$elem.bind('error1 error2',error)
|
||||
.unbind('error1 error2', error )
|
||||
.trigger('error1').triggerHandler('error2');
|
||||
$elem.bind("error1 error2",error)
|
||||
.unbind("error1 error2", error )
|
||||
.trigger("error1").triggerHandler("error2");
|
||||
|
||||
message = "unbind many"; // #3538
|
||||
$elem.bind('error1 error2',error)
|
||||
.unbind('error1 error2')
|
||||
.trigger('error1').triggerHandler('error2');
|
||||
$elem.bind("error1 error2", error)
|
||||
.unbind("error1 error2")
|
||||
.trigger("error1").triggerHandler("error2");
|
||||
|
||||
message = "unbind without a type or handler";
|
||||
$elem.bind("error1 error2.test",error)
|
||||
|
@ -678,28 +678,28 @@ test("unbind(eventObject)", function() {
|
|||
|
||||
function assert( expected ){
|
||||
num = 0;
|
||||
$elem.trigger('foo').triggerHandler('bar');
|
||||
$elem.trigger("foo").triggerHandler("bar");
|
||||
equals( num, expected, "Check the right handlers are triggered" );
|
||||
}
|
||||
|
||||
$elem
|
||||
// This handler shouldn't be unbound
|
||||
.bind('foo', function(){
|
||||
.bind("foo", function(){
|
||||
num += 1;
|
||||
})
|
||||
.bind('foo', function(e){
|
||||
.bind("foo", function(e){
|
||||
$elem.unbind( e )
|
||||
num += 2;
|
||||
})
|
||||
// Neither this one
|
||||
.bind('bar', function(){
|
||||
.bind("bar", function(){
|
||||
num += 4;
|
||||
});
|
||||
|
||||
assert( 7 );
|
||||
assert( 5 );
|
||||
|
||||
$elem.unbind('bar');
|
||||
$elem.unbind("bar");
|
||||
assert( 1 );
|
||||
|
||||
$elem.unbind();
|
||||
|
@ -732,7 +732,7 @@ test("mouseover triggers mouseenter", function() {
|
|||
elem.mouseenter(function () {
|
||||
count++;
|
||||
});
|
||||
elem.trigger('mouseover');
|
||||
elem.trigger("mouseover");
|
||||
equals(count, 1, "make sure mouseover triggers a mouseenter" );
|
||||
|
||||
elem.remove();
|
||||
|
@ -741,9 +741,9 @@ test("mouseover triggers mouseenter", function() {
|
|||
test("trigger() shortcuts", function() {
|
||||
expect(6);
|
||||
|
||||
var elem = jQuery('<li><a href="#">Change location</a></li>').prependTo('#firstUL');
|
||||
elem.find('a').bind('click', function() {
|
||||
var close = jQuery('spanx', this); // same with jQuery(this).find('span');
|
||||
var elem = jQuery("<li><a href='#'>Change location</a></li>").prependTo("#firstUL");
|
||||
elem.find("a").bind("click", function() {
|
||||
var close = jQuery("spanx", this); // same with jQuery(this).find("span");
|
||||
equals( close.length, 0, "Context element does not exist, length must be zero" );
|
||||
ok( !close[0], "Context element does not exist, direct access to element must return undefined" );
|
||||
return false;
|
||||
|
@ -757,25 +757,30 @@ test("trigger() shortcuts", function() {
|
|||
}).click();
|
||||
|
||||
var counter = 0;
|
||||
jQuery('#firstp')[0].onclick = function(event) {
|
||||
jQuery("#firstp")[0].onclick = function(event) {
|
||||
counter++;
|
||||
};
|
||||
jQuery('#firstp').click();
|
||||
jQuery("#firstp").click();
|
||||
equals( counter, 1, "Check that click, triggers onclick event handler also" );
|
||||
|
||||
var clickCounter = 0;
|
||||
jQuery('#simon1')[0].onclick = function(event) {
|
||||
jQuery("#simon1")[0].onclick = function(event) {
|
||||
clickCounter++;
|
||||
};
|
||||
jQuery('#simon1').click();
|
||||
jQuery("#simon1").click();
|
||||
equals( clickCounter, 1, "Check that click, triggers onclick event handler on an a tag also" );
|
||||
|
||||
elem = jQuery('<img />').load(function(){
|
||||
elem = jQuery("<img />").load(function(){
|
||||
ok( true, "Trigger the load event, using the shortcut .load() (#2819)");
|
||||
}).load();
|
||||
|
||||
// manually clean up detached elements
|
||||
elem.remove();
|
||||
|
||||
// test that special handlers do not blow up with VML elements (#7071)
|
||||
jQuery('<xml:namespace ns="urn:schemas-microsoft-com:vml" prefix="v" />').appendTo('head');
|
||||
jQuery('<v:oval id="oval" style="width:100pt;height:75pt;" fillcolor="red"> </v:oval>').appendTo('#form');
|
||||
jQuery("#oval").click().keydown();
|
||||
});
|
||||
|
||||
test("trigger() bubbling", function() {
|
||||
|
@ -853,7 +858,7 @@ test("trigger(type, [data], [fn])", function() {
|
|||
|
||||
var pass = true;
|
||||
try {
|
||||
jQuery('#form input:first').hide().trigger('focus');
|
||||
jQuery("#form input:first").hide().trigger("focus");
|
||||
} catch(e) {
|
||||
pass = false;
|
||||
}
|
||||
|
@ -861,7 +866,7 @@ test("trigger(type, [data], [fn])", function() {
|
|||
|
||||
pass = true;
|
||||
try {
|
||||
jQuery('#main table:first').bind('test:test', function(){}).trigger('test:test');
|
||||
jQuery("#main table:first").bind("test:test", function(){}).trigger("test:test");
|
||||
} catch (e) {
|
||||
pass = false;
|
||||
}
|
||||
|
@ -899,8 +904,8 @@ test("jQuery.Event.currentTarget", function(){
|
|||
test("trigger(eventObject, [data], [fn])", function() {
|
||||
expect(25);
|
||||
|
||||
var $parent = jQuery('<div id="par" />').hide().appendTo('body'),
|
||||
$child = jQuery('<p id="child">foo</p>').appendTo( $parent );
|
||||
var $parent = jQuery("<div id='par' />").hide().appendTo("body"),
|
||||
$child = jQuery("<p id='child'>foo</p>").appendTo( $parent );
|
||||
|
||||
var event = jQuery.Event("noNew");
|
||||
ok( event != window, "Instantiate jQuery.Event without the 'new' keyword" );
|
||||
|
@ -920,21 +925,21 @@ test("trigger(eventObject, [data], [fn])", function() {
|
|||
equals( event.isPropagationStopped(), true, "Verify isPropagationStopped" );
|
||||
equals( event.isImmediatePropagationStopped(), true, "Verify isPropagationStopped" );
|
||||
|
||||
$parent.bind('foo',function(e){
|
||||
$parent.bind("foo",function(e){
|
||||
// Tries bubbling
|
||||
equals( e.type, 'foo', 'Verify event type when passed passing an event object' );
|
||||
equals( e.target.id, 'child', 'Verify event.target when passed passing an event object' );
|
||||
equals( e.currentTarget.id, 'par', 'Verify event.target when passed passing an event object' );
|
||||
equals( e.secret, 'boo!', 'Verify event object\'s custom attribute when passed passing an event object' );
|
||||
equals( e.type, "foo", "Verify event type when passed passing an event object" );
|
||||
equals( e.target.id, "child", "Verify event.target when passed passing an event object" );
|
||||
equals( e.currentTarget.id, "par", "Verify event.target when passed passing an event object" );
|
||||
equals( e.secret, "boo!", "Verify event object's custom attribute when passed passing an event object" );
|
||||
});
|
||||
|
||||
// test with an event object
|
||||
event = new jQuery.Event("foo");
|
||||
event.secret = 'boo!';
|
||||
event.secret = "boo!";
|
||||
$child.trigger(event);
|
||||
|
||||
// test with a literal object
|
||||
$child.trigger({type:'foo', secret:'boo!'});
|
||||
$child.trigger({type: "foo", secret: "boo!"});
|
||||
|
||||
$parent.unbind();
|
||||
|
||||
|
@ -942,9 +947,9 @@ test("trigger(eventObject, [data], [fn])", function() {
|
|||
ok( false, "This assertion shouldn't be reached");
|
||||
}
|
||||
|
||||
$parent.bind('foo', error );
|
||||
$parent.bind("foo", error );
|
||||
|
||||
$child.bind('foo',function(e, a, b, c ){
|
||||
$child.bind("foo",function(e, a, b, c ){
|
||||
equals( arguments.length, 4, "Check arguments length");
|
||||
equals( a, 1, "Check first custom argument");
|
||||
equals( b, 2, "Check second custom argument");
|
||||
|
@ -962,24 +967,24 @@ test("trigger(eventObject, [data], [fn])", function() {
|
|||
|
||||
// We should add this back in when we want to test the order
|
||||
// in which event handlers are iterated.
|
||||
//$child.bind('foo', error );
|
||||
//$child.bind("foo", error );
|
||||
|
||||
event = new jQuery.Event("foo");
|
||||
$child.trigger( event, [1,2,3] ).unbind();
|
||||
equals( event.result, "result", "Check event.result attribute");
|
||||
|
||||
// Will error if it bubbles
|
||||
$child.triggerHandler('foo');
|
||||
$child.triggerHandler("foo");
|
||||
|
||||
$child.unbind();
|
||||
$parent.unbind().remove();
|
||||
});
|
||||
|
||||
test("jQuery.Event({ /* props */ })", function() {
|
||||
test("jQuery.Event( type, props )", function() {
|
||||
|
||||
expect(4);
|
||||
|
||||
var event = jQuery.Event({ type: "keydown", keyCode: 64 }),
|
||||
var event = jQuery.Event( "keydown", { keyCode: 64 }),
|
||||
handler = function( event ) {
|
||||
ok( "keyCode" in event, "Special property 'keyCode' exists" );
|
||||
equal( event.keyCode, 64, "event.keyCode has explicit value '64'" );
|
||||
|
@ -1000,12 +1005,12 @@ test("jQuery.Event.currentTarget", function(){
|
|||
expect(1);
|
||||
|
||||
var counter = 0,
|
||||
$elem = jQuery('<button>a</button>').click(function(e){
|
||||
$elem = jQuery("<button>a</button>").click(function(e){
|
||||
equals( e.currentTarget, this, "Check currentTarget on "+(counter++?"native":"fake") +" event" );
|
||||
});
|
||||
|
||||
// Fake event
|
||||
$elem.trigger('click');
|
||||
$elem.trigger("click");
|
||||
|
||||
// Cleanup
|
||||
$elem.unbind();
|
||||
|
@ -1018,7 +1023,7 @@ test("toggle(Function, Function, ...)", function() {
|
|||
fn1 = function(e) { count++; },
|
||||
fn2 = function(e) { count--; },
|
||||
preventDefault = function(e) { e.preventDefault() },
|
||||
link = jQuery('#mark');
|
||||
link = jQuery("#mark");
|
||||
link.click(preventDefault).click().toggle(fn1, fn2).click().click().click().click().click();
|
||||
equals( count, 1, "Check for toggle(fn, fn)" );
|
||||
|
||||
|
@ -1062,8 +1067,8 @@ test("toggle(Function, Function, ...)", function() {
|
|||
$div.click();
|
||||
equals( turn, 2, "Trying toggle with 3 functions, attempt 5 yields 2");
|
||||
|
||||
$div.unbind('click',fns[0]);
|
||||
var data = jQuery._data( $div[0], 'events' );
|
||||
$div.unbind("click",fns[0]);
|
||||
var data = jQuery._data( $div[0], "events" );
|
||||
ok( !data, "Unbinding one function from toggle unbinds them all");
|
||||
|
||||
// manually clean up detached elements
|
||||
|
@ -1178,12 +1183,12 @@ test(".live()/.die()", function() {
|
|||
jQuery("div").die("submit");
|
||||
|
||||
// Test binding with a different context
|
||||
var clicked = 0, container = jQuery('#main')[0];
|
||||
var clicked = 0, container = jQuery("#main")[0];
|
||||
jQuery("#foo", container).live("click", function(e){ clicked++; });
|
||||
jQuery("div").trigger('click');
|
||||
jQuery("#foo").trigger('click');
|
||||
jQuery("#main").trigger('click');
|
||||
jQuery("body").trigger('click');
|
||||
jQuery("div").trigger("click");
|
||||
jQuery("#foo").trigger("click");
|
||||
jQuery("#main").trigger("click");
|
||||
jQuery("body").trigger("click");
|
||||
equals( clicked, 2, "live with a context" );
|
||||
|
||||
// Make sure the event is actually stored on the context
|
||||
|
@ -1191,7 +1196,7 @@ test(".live()/.die()", function() {
|
|||
|
||||
// Test unbinding with a different context
|
||||
jQuery("#foo", container).die("click");
|
||||
jQuery("#foo").trigger('click');
|
||||
jQuery("#foo").trigger("click");
|
||||
equals( clicked, 2, "die with a context");
|
||||
|
||||
// Test binding with event data
|
||||
|
@ -1273,9 +1278,9 @@ test(".live()/.die()", function() {
|
|||
|
||||
// Make sure we don't loose the target by DOM modifications
|
||||
// after the bubble already reached the liveHandler
|
||||
var livec = 0, elemDiv = jQuery("#nothiddendivchild").html('<span></span>').get(0);
|
||||
var livec = 0, elemDiv = jQuery("#nothiddendivchild").html("<span></span>").get(0);
|
||||
|
||||
jQuery("#nothiddendivchild").live("click", function(e){ jQuery("#nothiddendivchild").html(''); });
|
||||
jQuery("#nothiddendivchild").live("click", function(e){ jQuery("#nothiddendivchild").html(""); });
|
||||
jQuery("#nothiddendivchild").live("click", function(e){ if(e.target) {livec++;} });
|
||||
|
||||
jQuery("#nothiddendiv span").click();
|
||||
|
@ -1290,20 +1295,20 @@ test(".live()/.die()", function() {
|
|||
var lived = 0, livee = 0;
|
||||
|
||||
// bind one pair in one order
|
||||
jQuery('span#liveSpan1 a').live('click', function(){ lived++; return false; });
|
||||
jQuery('span#liveSpan1').live('click', function(){ livee++; });
|
||||
jQuery("span#liveSpan1 a").live("click", function(){ lived++; return false; });
|
||||
jQuery("span#liveSpan1").live("click", function(){ livee++; });
|
||||
|
||||
jQuery('span#liveSpan1 a').click();
|
||||
jQuery("span#liveSpan1 a").click();
|
||||
equals( lived, 1, "Verify that only one first handler occurred." );
|
||||
equals( livee, 0, "Verify that second handler doesn't." );
|
||||
|
||||
// and one pair in inverse
|
||||
jQuery('span#liveSpan2').live('click', function(){ livee++; });
|
||||
jQuery('span#liveSpan2 a').live('click', function(){ lived++; return false; });
|
||||
jQuery("span#liveSpan2").live("click", function(){ livee++; });
|
||||
jQuery("span#liveSpan2 a").live("click", function(){ lived++; return false; });
|
||||
|
||||
lived = 0;
|
||||
livee = 0;
|
||||
jQuery('span#liveSpan2 a').click();
|
||||
jQuery("span#liveSpan2 a").click();
|
||||
equals( lived, 1, "Verify that only one first handler occurred." );
|
||||
equals( livee, 0, "Verify that second handler doesn't." );
|
||||
|
||||
|
@ -1314,15 +1319,15 @@ test(".live()/.die()", function() {
|
|||
jQuery("span#liveSpan2").die("click");
|
||||
|
||||
// Test this, target and currentTarget are correct
|
||||
jQuery('span#liveSpan1').live('click', function(e){
|
||||
equals( this.id, 'liveSpan1', 'Check the this within a live handler' );
|
||||
equals( e.currentTarget.id, 'liveSpan1', 'Check the event.currentTarget within a live handler' );
|
||||
equals( e.target.nodeName.toUpperCase(), 'A', 'Check the event.target within a live handler' );
|
||||
jQuery("span#liveSpan1").live("click", function(e){
|
||||
equals( this.id, "liveSpan1", "Check the this within a live handler" );
|
||||
equals( e.currentTarget.id, "liveSpan1", "Check the event.currentTarget within a live handler" );
|
||||
equals( e.target.nodeName.toUpperCase(), "A", "Check the event.target within a live handler" );
|
||||
});
|
||||
|
||||
jQuery('span#liveSpan1 a').click();
|
||||
jQuery("span#liveSpan1 a").click();
|
||||
|
||||
jQuery('span#liveSpan1').die('click');
|
||||
jQuery("span#liveSpan1").die("click");
|
||||
|
||||
// Work with deep selectors
|
||||
livee = 0;
|
||||
|
@ -1705,12 +1710,12 @@ test(".delegate()/.undelegate()", function() {
|
|||
jQuery("#body").undelegate("div", "submit");
|
||||
|
||||
// Test binding with a different context
|
||||
var clicked = 0, container = jQuery('#main')[0];
|
||||
var clicked = 0, container = jQuery("#main")[0];
|
||||
jQuery("#main").delegate("#foo", "click", function(e){ clicked++; });
|
||||
jQuery("div").trigger('click');
|
||||
jQuery("#foo").trigger('click');
|
||||
jQuery("#main").trigger('click');
|
||||
jQuery("body").trigger('click');
|
||||
jQuery("div").trigger("click");
|
||||
jQuery("#foo").trigger("click");
|
||||
jQuery("#main").trigger("click");
|
||||
jQuery("body").trigger("click");
|
||||
equals( clicked, 2, "delegate with a context" );
|
||||
|
||||
// Make sure the event is actually stored on the context
|
||||
|
@ -1718,7 +1723,7 @@ test(".delegate()/.undelegate()", function() {
|
|||
|
||||
// Test unbinding with a different context
|
||||
jQuery("#main").undelegate("#foo", "click");
|
||||
jQuery("#foo").trigger('click');
|
||||
jQuery("#foo").trigger("click");
|
||||
equals( clicked, 2, "undelegate with a context");
|
||||
|
||||
// Test binding with event data
|
||||
|
@ -1804,9 +1809,9 @@ test(".delegate()/.undelegate()", function() {
|
|||
|
||||
// Make sure we don't loose the target by DOM modifications
|
||||
// after the bubble already reached the liveHandler
|
||||
var livec = 0, elemDiv = jQuery("#nothiddendivchild").html('<span></span>').get(0);
|
||||
var livec = 0, elemDiv = jQuery("#nothiddendivchild").html("<span></span>").get(0);
|
||||
|
||||
jQuery("#body").delegate("#nothiddendivchild", "click", function(e){ jQuery("#nothiddendivchild").html(''); });
|
||||
jQuery("#body").delegate("#nothiddendivchild", "click", function(e){ jQuery("#nothiddendivchild").html(""); });
|
||||
jQuery("#body").delegate("#nothiddendivchild", "click", function(e){ if(e.target) {livec++;} });
|
||||
|
||||
jQuery("#nothiddendiv span").click();
|
||||
|
@ -1821,20 +1826,20 @@ test(".delegate()/.undelegate()", function() {
|
|||
var lived = 0, livee = 0;
|
||||
|
||||
// bind one pair in one order
|
||||
jQuery("#body").delegate('span#liveSpan1 a', 'click', function(){ lived++; return false; });
|
||||
jQuery("#body").delegate('span#liveSpan1', 'click', function(){ livee++; });
|
||||
jQuery("#body").delegate("span#liveSpan1 a", "click", function(){ lived++; return false; });
|
||||
jQuery("#body").delegate("span#liveSpan1", "click", function(){ livee++; });
|
||||
|
||||
jQuery('span#liveSpan1 a').click();
|
||||
jQuery("span#liveSpan1 a").click();
|
||||
equals( lived, 1, "Verify that only one first handler occurred." );
|
||||
equals( livee, 0, "Verify that second handler doesn't." );
|
||||
|
||||
// and one pair in inverse
|
||||
jQuery("#body").delegate('span#liveSpan2', 'click', function(){ livee++; });
|
||||
jQuery("#body").delegate('span#liveSpan2 a', 'click', function(){ lived++; return false; });
|
||||
jQuery("#body").delegate("span#liveSpan2", "click", function(){ livee++; });
|
||||
jQuery("#body").delegate("span#liveSpan2 a", "click", function(){ lived++; return false; });
|
||||
|
||||
lived = 0;
|
||||
livee = 0;
|
||||
jQuery('span#liveSpan2 a').click();
|
||||
jQuery("span#liveSpan2 a").click();
|
||||
equals( lived, 1, "Verify that only one first handler occurred." );
|
||||
equals( livee, 0, "Verify that second handler doesn't." );
|
||||
|
||||
|
@ -1842,15 +1847,15 @@ test(".delegate()/.undelegate()", function() {
|
|||
jQuery("#body").undelegate("click");
|
||||
|
||||
// Test this, target and currentTarget are correct
|
||||
jQuery("#body").delegate('span#liveSpan1', 'click', function(e){
|
||||
equals( this.id, 'liveSpan1', 'Check the this within a delegate handler' );
|
||||
equals( e.currentTarget.id, 'liveSpan1', 'Check the event.currentTarget within a delegate handler' );
|
||||
equals( e.target.nodeName.toUpperCase(), 'A', 'Check the event.target within a delegate handler' );
|
||||
jQuery("#body").delegate("span#liveSpan1", "click", function(e){
|
||||
equals( this.id, "liveSpan1", "Check the this within a delegate handler" );
|
||||
equals( e.currentTarget.id, "liveSpan1", "Check the event.currentTarget within a delegate handler" );
|
||||
equals( e.target.nodeName.toUpperCase(), "A", "Check the event.target within a delegate handler" );
|
||||
});
|
||||
|
||||
jQuery('span#liveSpan1 a').click();
|
||||
jQuery("span#liveSpan1 a").click();
|
||||
|
||||
jQuery("#body").undelegate('span#liveSpan1', 'click');
|
||||
jQuery("#body").undelegate("span#liveSpan1", "click");
|
||||
|
||||
// Work with deep selectors
|
||||
livee = 0;
|
||||
|
@ -2022,16 +2027,37 @@ test("delegate with submit", function() {
|
|||
jQuery(document).undelegate();
|
||||
});
|
||||
|
||||
test("undelegate() with only namespaces", function() {
|
||||
expect(2);
|
||||
|
||||
var $delegate = jQuery("#liveHandlerOrder"),
|
||||
count = 0;
|
||||
|
||||
$delegate.delegate("a", "click.ns", function(e) {
|
||||
count++;
|
||||
});
|
||||
|
||||
jQuery("a", $delegate).eq(0).trigger("click.ns");
|
||||
|
||||
equals( count, 1, "delegated click.ns");
|
||||
|
||||
$delegate.undelegate(".ns");
|
||||
|
||||
jQuery("a", $delegate).eq(1).trigger("click.ns");
|
||||
|
||||
equals( count, 1, "no more .ns after undelegate");
|
||||
});
|
||||
|
||||
test("Non DOM element events", function() {
|
||||
expect(1);
|
||||
|
||||
var o = {};
|
||||
|
||||
jQuery(o).bind('nonelementobj', function(e) {
|
||||
jQuery(o).bind("nonelementobj", function(e) {
|
||||
ok( true, "Event on non-DOM object triggered" );
|
||||
});
|
||||
|
||||
jQuery(o).trigger('nonelementobj');
|
||||
jQuery(o).trigger("nonelementobj");
|
||||
});
|
||||
|
||||
test("window resize", function() {
|
||||
|
@ -2049,7 +2075,7 @@ test("window resize", function() {
|
|||
test("focusin bubbles", function() {
|
||||
expect(5);
|
||||
|
||||
var input = jQuery( '<input type="text" />' ).prependTo( "body" ),
|
||||
var input = jQuery( "<input type='text' />" ).prependTo( "body" ),
|
||||
order = 0;
|
||||
|
||||
jQuery( "body" ).bind( "focusin.focusinBubblesTest", function(){
|
||||
|
|
|
@ -9,7 +9,7 @@ var functionReturningObj = function(value) { return (function() { return value;
|
|||
test("text()", function() {
|
||||
expect(2);
|
||||
var expected = "This link has class=\"blog\": Simon Willison's Weblog";
|
||||
equals( jQuery('#sap').text(), expected, 'Check for merged text of more then one element.' );
|
||||
equals( jQuery("#sap").text(), expected, "Check for merged text of more then one element." );
|
||||
|
||||
// Check serialization of text values
|
||||
equals( jQuery(document.createTextNode("foo")).text(), "foo", "Text node was retreived from .text()." );
|
||||
|
@ -43,34 +43,34 @@ test("text(Function) with incoming value", function() {
|
|||
|
||||
var old = "This link has class=\"blog\": Simon Willison's Weblog";
|
||||
|
||||
jQuery('#sap').text(function(i, val) {
|
||||
jQuery("#sap").text(function(i, val) {
|
||||
equals( val, old, "Make sure the incoming value is correct." );
|
||||
return "foobar";
|
||||
});
|
||||
|
||||
equals( jQuery("#sap").text(), "foobar", 'Check for merged text of more then one element.' );
|
||||
equals( jQuery("#sap").text(), "foobar", "Check for merged text of more then one element." );
|
||||
|
||||
QUnit.reset();
|
||||
});
|
||||
|
||||
var testWrap = function(val) {
|
||||
expect(19);
|
||||
var defaultText = 'Try them out:'
|
||||
var result = jQuery('#first').wrap(val( '<div class="red"><span></span></div>' )).text();
|
||||
equals( defaultText, result, 'Check for wrapping of on-the-fly html' );
|
||||
ok( jQuery('#first').parent().parent().is('.red'), 'Check if wrapper has class "red"' );
|
||||
var defaultText = "Try them out:"
|
||||
var result = jQuery("#first").wrap(val( "<div class='red'><span></span></div>" )).text();
|
||||
equals( defaultText, result, "Check for wrapping of on-the-fly html" );
|
||||
ok( jQuery("#first").parent().parent().is(".red"), "Check if wrapper has class 'red'" );
|
||||
|
||||
QUnit.reset();
|
||||
var defaultText = 'Try them out:'
|
||||
var result = jQuery('#first').wrap(val( document.getElementById('empty') )).parent();
|
||||
ok( result.is('ol'), 'Check for element wrapping' );
|
||||
equals( result.text(), defaultText, 'Check for element wrapping' );
|
||||
var defaultText = "Try them out:"
|
||||
var result = jQuery("#first").wrap(val( document.getElementById("empty") )).parent();
|
||||
ok( result.is("ol"), "Check for element wrapping" );
|
||||
equals( result.text(), defaultText, "Check for element wrapping" );
|
||||
|
||||
QUnit.reset();
|
||||
jQuery('#check1').click(function() {
|
||||
jQuery("#check1").click(function() {
|
||||
var checkbox = this;
|
||||
ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
|
||||
jQuery(checkbox).wrap(val( '<div id="c1" style="display:none;"></div>' ));
|
||||
jQuery(checkbox).wrap(val( "<div id='c1' style='display:none;'></div>" ));
|
||||
ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
|
||||
}).click();
|
||||
|
||||
|
@ -143,17 +143,17 @@ var testWrapAll = function(val) {
|
|||
var prev = jQuery("#firstp")[0].previousSibling;
|
||||
var p = jQuery("#firstp,#first")[0].parentNode;
|
||||
|
||||
var result = jQuery('#firstp,#first').wrapAll(val( '<div class="red"><div class="tmp"></div></div>' ));
|
||||
equals( result.parent().length, 1, 'Check for wrapping of on-the-fly html' );
|
||||
ok( jQuery('#first').parent().parent().is('.red'), 'Check if wrapper has class "red"' );
|
||||
ok( jQuery('#firstp').parent().parent().is('.red'), 'Check if wrapper has class "red"' );
|
||||
var result = jQuery("#firstp,#first").wrapAll(val( "<div class='red'><div class='tmp'></div></div>" ));
|
||||
equals( result.parent().length, 1, "Check for wrapping of on-the-fly html" );
|
||||
ok( jQuery("#first").parent().parent().is(".red"), "Check if wrapper has class 'red'" );
|
||||
ok( jQuery("#firstp").parent().parent().is(".red"), "Check if wrapper has class 'red'" );
|
||||
equals( jQuery("#first").parent().parent()[0].previousSibling, prev, "Correct Previous Sibling" );
|
||||
equals( jQuery("#first").parent().parent()[0].parentNode, p, "Correct Parent" );
|
||||
|
||||
QUnit.reset();
|
||||
var prev = jQuery("#firstp")[0].previousSibling;
|
||||
var p = jQuery("#first")[0].parentNode;
|
||||
var result = jQuery('#firstp,#first').wrapAll(val( document.getElementById('empty') ));
|
||||
var result = jQuery("#firstp,#first").wrapAll(val( document.getElementById("empty") ));
|
||||
equals( jQuery("#first").parent()[0], jQuery("#firstp").parent()[0], "Same Parent" );
|
||||
equals( jQuery("#first").parent()[0].previousSibling, prev, "Correct Previous Sibling" );
|
||||
equals( jQuery("#first").parent()[0].parentNode, p, "Correct Parent" );
|
||||
|
@ -166,21 +166,21 @@ test("wrapAll(String|Element)", function() {
|
|||
var testWrapInner = function(val) {
|
||||
expect(11);
|
||||
var num = jQuery("#first").children().length;
|
||||
var result = jQuery('#first').wrapInner(val('<div class="red"><div id="tmp"></div></div>'));
|
||||
var result = jQuery("#first").wrapInner(val("<div class='red'><div id='tmp'></div></div>"));
|
||||
equals( jQuery("#first").children().length, 1, "Only one child" );
|
||||
ok( jQuery("#first").children().is(".red"), "Verify Right Element" );
|
||||
equals( jQuery("#first").children().children().children().length, num, "Verify Elements Intact" );
|
||||
|
||||
QUnit.reset();
|
||||
var num = jQuery("#first").html("foo<div>test</div><div>test2</div>").children().length;
|
||||
var result = jQuery('#first').wrapInner(val('<div class="red"><div id="tmp"></div></div>'));
|
||||
var result = jQuery("#first").wrapInner(val("<div class='red'><div id='tmp'></div></div>"));
|
||||
equals( jQuery("#first").children().length, 1, "Only one child" );
|
||||
ok( jQuery("#first").children().is(".red"), "Verify Right Element" );
|
||||
equals( jQuery("#first").children().children().children().length, num, "Verify Elements Intact" );
|
||||
|
||||
QUnit.reset();
|
||||
var num = jQuery("#first").children().length;
|
||||
var result = jQuery('#first').wrapInner(val(document.getElementById('empty')));
|
||||
var result = jQuery("#first").wrapInner(val(document.getElementById("empty")));
|
||||
equals( jQuery("#first").children().length, 1, "Only one child" );
|
||||
ok( jQuery("#first").children().is("#empty"), "Verify Right Element" );
|
||||
equals( jQuery("#first").children().children().length, num, "Verify Elements Intact" );
|
||||
|
@ -202,51 +202,51 @@ test("wrapInner(Function)", function() {
|
|||
test("unwrap()", function() {
|
||||
expect(9);
|
||||
|
||||
jQuery("body").append(' <div id="unwrap" style="display: none;"> <div id="unwrap1"> <span class="unwrap">a</span> <span class="unwrap">b</span> </div> <div id="unwrap2"> <span class="unwrap">c</span> <span class="unwrap">d</span> </div> <div id="unwrap3"> <b><span class="unwrap unwrap3">e</span></b> <b><span class="unwrap unwrap3">f</span></b> </div> </div>');
|
||||
jQuery("body").append(" <div id='unwrap' style='display: none;'> <div id='unwrap1'> <span class='unwrap'>a</span> <span class='unwrap'>b</span> </div> <div id='unwrap2'> <span class='unwrap'>c</span> <span class='unwrap'>d</span> </div> <div id='unwrap3'> <b><span class='unwrap unwrap3'>e</span></b> <b><span class='unwrap unwrap3'>f</span></b> </div> </div>");
|
||||
|
||||
var abcd = jQuery('#unwrap1 > span, #unwrap2 > span').get(),
|
||||
abcdef = jQuery('#unwrap span').get();
|
||||
var abcd = jQuery("#unwrap1 > span, #unwrap2 > span").get(),
|
||||
abcdef = jQuery("#unwrap span").get();
|
||||
|
||||
equals( jQuery('#unwrap1 span').add('#unwrap2 span:first').unwrap().length, 3, 'make #unwrap1 and #unwrap2 go away' );
|
||||
same( jQuery('#unwrap > span').get(), abcd, 'all four spans should still exist' );
|
||||
equals( jQuery("#unwrap1 span").add("#unwrap2 span:first").unwrap().length, 3, "make #unwrap1 and #unwrap2 go away" );
|
||||
same( jQuery("#unwrap > span").get(), abcd, "all four spans should still exist" );
|
||||
|
||||
same( jQuery('#unwrap3 span').unwrap().get(), jQuery('#unwrap3 > span').get(), 'make all b in #unwrap3 go away' );
|
||||
same( jQuery("#unwrap3 span").unwrap().get(), jQuery("#unwrap3 > span").get(), "make all b in #unwrap3 go away" );
|
||||
|
||||
same( jQuery('#unwrap3 span').unwrap().get(), jQuery('#unwrap > span.unwrap3').get(), 'make #unwrap3 go away' );
|
||||
same( jQuery("#unwrap3 span").unwrap().get(), jQuery("#unwrap > span.unwrap3").get(), "make #unwrap3 go away" );
|
||||
|
||||
same( jQuery('#unwrap').children().get(), abcdef, '#unwrap only contains 6 child spans' );
|
||||
same( jQuery("#unwrap").children().get(), abcdef, "#unwrap only contains 6 child spans" );
|
||||
|
||||
same( jQuery('#unwrap > span').unwrap().get(), jQuery('body > span.unwrap').get(), 'make the 6 spans become children of body' );
|
||||
same( jQuery("#unwrap > span").unwrap().get(), jQuery("body > span.unwrap").get(), "make the 6 spans become children of body" );
|
||||
|
||||
same( jQuery('body > span.unwrap').unwrap().get(), jQuery('body > span.unwrap').get(), 'can\'t unwrap children of body' );
|
||||
same( jQuery('body > span.unwrap').unwrap().get(), abcdef, 'can\'t unwrap children of body' );
|
||||
same( jQuery("body > span.unwrap").unwrap().get(), jQuery("body > span.unwrap").get(), "can't unwrap children of body" );
|
||||
same( jQuery("body > span.unwrap").unwrap().get(), abcdef, "can't unwrap children of body" );
|
||||
|
||||
same( jQuery('body > span.unwrap').get(), abcdef, 'body contains 6 .unwrap child spans' );
|
||||
same( jQuery("body > span.unwrap").get(), abcdef, "body contains 6 .unwrap child spans" );
|
||||
|
||||
jQuery('body > span.unwrap').remove();
|
||||
jQuery("body > span.unwrap").remove();
|
||||
});
|
||||
|
||||
var testAppend = function(valueObj) {
|
||||
expect(37);
|
||||
var defaultText = 'Try them out:'
|
||||
var result = jQuery('#first').append(valueObj('<b>buga</b>'));
|
||||
equals( result.text(), defaultText + 'buga', 'Check if text appending works' );
|
||||
equals( jQuery('#select3').append(valueObj('<option value="appendTest">Append Test</option>')).find('option:last-child').attr('value'), 'appendTest', 'Appending html options to select element');
|
||||
var defaultText = "Try them out:"
|
||||
var result = jQuery("#first").append(valueObj("<b>buga</b>"));
|
||||
equals( result.text(), defaultText + "buga", "Check if text appending works" );
|
||||
equals( jQuery("#select3").append(valueObj("<option value='appendTest'>Append Test</option>")).find("option:last-child").attr("value"), "appendTest", "Appending html options to select element");
|
||||
|
||||
QUnit.reset();
|
||||
var expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:";
|
||||
jQuery('#sap').append(valueObj(document.getElementById('first')));
|
||||
equals( jQuery('#sap').text(), expected, "Check for appending of element" );
|
||||
jQuery("#sap").append(valueObj(document.getElementById("first")));
|
||||
equals( jQuery("#sap").text(), expected, "Check for appending of element" );
|
||||
|
||||
QUnit.reset();
|
||||
expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
|
||||
jQuery('#sap').append(valueObj([document.getElementById('first'), document.getElementById('yahoo')]));
|
||||
equals( jQuery('#sap').text(), expected, "Check for appending of array of elements" );
|
||||
jQuery("#sap").append(valueObj([document.getElementById("first"), document.getElementById("yahoo")]));
|
||||
equals( jQuery("#sap").text(), expected, "Check for appending of array of elements" );
|
||||
|
||||
QUnit.reset();
|
||||
expected = "This link has class=\"blog\": Simon Willison's WeblogYahooTry them out:";
|
||||
jQuery('#sap').append(valueObj(jQuery("#yahoo, #first")));
|
||||
equals( jQuery('#sap').text(), expected, "Check for appending of jQuery object" );
|
||||
jQuery("#sap").append(valueObj(jQuery("#yahoo, #first")));
|
||||
equals( jQuery("#sap").text(), expected, "Check for appending of jQuery object" );
|
||||
|
||||
QUnit.reset();
|
||||
jQuery("#sap").append(valueObj( 5 ));
|
||||
|
@ -262,25 +262,25 @@ var testAppend = function(valueObj) {
|
|||
ok( jQuery("#sap").append(valueObj( document.getElementsByTagName("foo") )), "Check for appending an empty nodelist." );
|
||||
|
||||
QUnit.reset();
|
||||
jQuery("form").append(valueObj('<input name="radiotest" type="radio" checked="checked" />'));
|
||||
jQuery("form").append(valueObj("<input name='radiotest' type='radio' checked='checked' />"));
|
||||
jQuery("form input[name=radiotest]").each(function(){
|
||||
ok( jQuery(this).is(':checked'), "Append checked radio");
|
||||
ok( jQuery(this).is(":checked"), "Append checked radio");
|
||||
}).remove();
|
||||
|
||||
QUnit.reset();
|
||||
jQuery("form").append(valueObj('<input name="radiotest" type="radio" checked = \'checked\' />'));
|
||||
jQuery("form").append(valueObj("<input name='radiotest' type='radio' checked = 'checked' />"));
|
||||
jQuery("form input[name=radiotest]").each(function(){
|
||||
ok( jQuery(this).is(':checked'), "Append alternately formated checked radio");
|
||||
ok( jQuery(this).is(":checked"), "Append alternately formated checked radio");
|
||||
}).remove();
|
||||
|
||||
QUnit.reset();
|
||||
jQuery("form").append(valueObj('<input name="radiotest" type="radio" checked />'));
|
||||
jQuery("form").append(valueObj("<input name='radiotest' type='radio' checked />"));
|
||||
jQuery("form input[name=radiotest]").each(function(){
|
||||
ok( jQuery(this).is(':checked'), "Append HTML5-formated checked radio");
|
||||
ok( jQuery(this).is(":checked"), "Append HTML5-formated checked radio");
|
||||
}).remove();
|
||||
|
||||
QUnit.reset();
|
||||
jQuery("#sap").append(valueObj( document.getElementById('form') ));
|
||||
jQuery("#sap").append(valueObj( document.getElementById("form") ));
|
||||
equals( jQuery("#sap>form").size(), 1, "Check for appending a form" ); // Bug #910
|
||||
|
||||
QUnit.reset();
|
||||
|
@ -296,31 +296,31 @@ var testAppend = function(valueObj) {
|
|||
ok( pass, "Test for appending a DOM node to the contents of an IFrame" );
|
||||
|
||||
QUnit.reset();
|
||||
jQuery('<fieldset/>').appendTo('#form').append(valueObj( '<legend id="legend">test</legend>' ));
|
||||
t( 'Append legend', '#legend', ['legend'] );
|
||||
jQuery("<fieldset/>").appendTo("#form").append(valueObj( "<legend id='legend'>test</legend>" ));
|
||||
t( "Append legend", "#legend", ["legend"] );
|
||||
|
||||
QUnit.reset();
|
||||
jQuery('#select1').append(valueObj( '<OPTION>Test</OPTION>' ));
|
||||
equals( jQuery('#select1 option:last').text(), "Test", "Appending <OPTION> (all caps)" );
|
||||
jQuery("#select1").append(valueObj( "<OPTION>Test</OPTION>" ));
|
||||
equals( jQuery("#select1 option:last").text(), "Test", "Appending <OPTION> (all caps)" );
|
||||
|
||||
jQuery('#table').append(valueObj( '<colgroup></colgroup>' ));
|
||||
ok( jQuery('#table colgroup').length, "Append colgroup" );
|
||||
jQuery("#table").append(valueObj( "<colgroup></colgroup>" ));
|
||||
ok( jQuery("#table colgroup").length, "Append colgroup" );
|
||||
|
||||
jQuery('#table colgroup').append(valueObj( '<col/>' ));
|
||||
ok( jQuery('#table colgroup col').length, "Append col" );
|
||||
jQuery("#table colgroup").append(valueObj( "<col/>" ));
|
||||
ok( jQuery("#table colgroup col").length, "Append col" );
|
||||
|
||||
QUnit.reset();
|
||||
jQuery('#table').append(valueObj( '<caption></caption>' ));
|
||||
ok( jQuery('#table caption').length, "Append caption" );
|
||||
jQuery("#table").append(valueObj( "<caption></caption>" ));
|
||||
ok( jQuery("#table caption").length, "Append caption" );
|
||||
|
||||
QUnit.reset();
|
||||
jQuery('form:last')
|
||||
.append(valueObj( '<select id="appendSelect1"></select>' ))
|
||||
.append(valueObj( '<select id="appendSelect2"><option>Test</option></select>' ));
|
||||
jQuery("form:last")
|
||||
.append(valueObj( "<select id='appendSelect1'></select>" ))
|
||||
.append(valueObj( "<select id='appendSelect2'><option>Test</option></select>" ));
|
||||
|
||||
t( "Append Select", "#appendSelect1, #appendSelect2", ["appendSelect1", "appendSelect2"] );
|
||||
|
||||
equals( "Two nodes", jQuery('<div />').append("Two", " nodes").text(), "Appending two text nodes (#4011)" );
|
||||
equals( "Two nodes", jQuery("<div />").append("Two", " nodes").text(), "Appending two text nodes (#4011)" );
|
||||
|
||||
// using contents will get comments regular, text, and comment nodes
|
||||
var j = jQuery("#nonnodes").contents();
|
||||
|
@ -343,51 +343,51 @@ test("append(Function)", function() {
|
|||
test("append(Function) with incoming value", function() {
|
||||
expect(12);
|
||||
|
||||
var defaultText = 'Try them out:', old = jQuery("#first").html();
|
||||
var defaultText = "Try them out:", old = jQuery("#first").html();
|
||||
|
||||
var result = jQuery('#first').append(function(i, val){
|
||||
var result = jQuery("#first").append(function(i, val){
|
||||
equals( val, old, "Make sure the incoming value is correct." );
|
||||
return '<b>buga</b>';
|
||||
return "<b>buga</b>";
|
||||
});
|
||||
equals( result.text(), defaultText + 'buga', 'Check if text appending works' );
|
||||
equals( result.text(), defaultText + "buga", "Check if text appending works" );
|
||||
|
||||
var select = jQuery('#select3');
|
||||
var select = jQuery("#select3");
|
||||
old = select.html();
|
||||
|
||||
equals( select.append(function(i, val){
|
||||
equals( val, old, "Make sure the incoming value is correct." );
|
||||
return '<option value="appendTest">Append Test</option>';
|
||||
}).find('option:last-child').attr('value'), 'appendTest', 'Appending html options to select element');
|
||||
return "<option value='appendTest'>Append Test</option>";
|
||||
}).find("option:last-child").attr("value"), "appendTest", "Appending html options to select element");
|
||||
|
||||
QUnit.reset();
|
||||
var expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:";
|
||||
old = jQuery("#sap").html();
|
||||
|
||||
jQuery('#sap').append(function(i, val){
|
||||
jQuery("#sap").append(function(i, val){
|
||||
equals( val, old, "Make sure the incoming value is correct." );
|
||||
return document.getElementById('first');
|
||||
return document.getElementById("first");
|
||||
});
|
||||
equals( jQuery('#sap').text(), expected, "Check for appending of element" );
|
||||
equals( jQuery("#sap").text(), expected, "Check for appending of element" );
|
||||
|
||||
QUnit.reset();
|
||||
expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
|
||||
old = jQuery("#sap").html();
|
||||
|
||||
jQuery('#sap').append(function(i, val){
|
||||
jQuery("#sap").append(function(i, val){
|
||||
equals( val, old, "Make sure the incoming value is correct." );
|
||||
return [document.getElementById('first'), document.getElementById('yahoo')];
|
||||
return [document.getElementById("first"), document.getElementById("yahoo")];
|
||||
});
|
||||
equals( jQuery('#sap').text(), expected, "Check for appending of array of elements" );
|
||||
equals( jQuery("#sap").text(), expected, "Check for appending of array of elements" );
|
||||
|
||||
QUnit.reset();
|
||||
expected = "This link has class=\"blog\": Simon Willison's WeblogYahooTry them out:";
|
||||
old = jQuery("#sap").html();
|
||||
|
||||
jQuery('#sap').append(function(i, val){
|
||||
jQuery("#sap").append(function(i, val){
|
||||
equals( val, old, "Make sure the incoming value is correct." );
|
||||
return jQuery("#yahoo, #first");
|
||||
});
|
||||
equals( jQuery('#sap').text(), expected, "Check for appending of jQuery object" );
|
||||
equals( jQuery("#sap").text(), expected, "Check for appending of jQuery object" );
|
||||
|
||||
QUnit.reset();
|
||||
old = jQuery("#sap").html();
|
||||
|
@ -414,11 +414,11 @@ test("append the same fragment with events (Bug #6997, 5566)", function () {
|
|||
if ( doExtra ) {
|
||||
element = jQuery("div:first").click(function () {
|
||||
ok(true, "Event exists on original after being unbound on clone");
|
||||
jQuery(this).unbind('click');
|
||||
jQuery(this).unbind("click");
|
||||
});
|
||||
var clone = element.clone(true).unbind('click');
|
||||
clone[0].fireEvent('onclick');
|
||||
element[0].fireEvent('onclick');
|
||||
var clone = element.clone(true).unbind("click");
|
||||
clone[0].fireEvent("onclick");
|
||||
element[0].fireEvent("onclick");
|
||||
|
||||
// manually clean up detached elements
|
||||
clone.remove();
|
||||
|
@ -429,7 +429,7 @@ test("append the same fragment with events (Bug #6997, 5566)", function () {
|
|||
});
|
||||
|
||||
jQuery("#listWithTabIndex li").append(element)
|
||||
.find('a.test6997').eq(1).click();
|
||||
.find("a.test6997").eq(1).click();
|
||||
|
||||
element = jQuery("<li class='test6997'></li>").click(function () {
|
||||
ok(true, "Before second element events work");
|
||||
|
@ -443,10 +443,10 @@ test("append the same fragment with events (Bug #6997, 5566)", function () {
|
|||
test("appendTo(String|Element|Array<Element>|jQuery)", function() {
|
||||
expect(16);
|
||||
|
||||
var defaultText = 'Try them out:'
|
||||
jQuery('<b>buga</b>').appendTo('#first');
|
||||
equals( jQuery("#first").text(), defaultText + 'buga', 'Check if text appending works' );
|
||||
equals( jQuery('<option value="appendTest">Append Test</option>').appendTo('#select3').parent().find('option:last-child').attr('value'), 'appendTest', 'Appending html options to select element');
|
||||
var defaultText = "Try them out:"
|
||||
jQuery("<b>buga</b>").appendTo("#first");
|
||||
equals( jQuery("#first").text(), defaultText + "buga", "Check if text appending works" );
|
||||
equals( jQuery("<option value='appendTest'>Append Test</option>").appendTo("#select3").parent().find("option:last-child").attr("value"), "appendTest", "Appending html options to select element");
|
||||
|
||||
QUnit.reset();
|
||||
var l = jQuery("#first").children().length + 2;
|
||||
|
@ -459,25 +459,25 @@ test("appendTo(String|Element|Array<Element>|jQuery)", function() {
|
|||
|
||||
QUnit.reset();
|
||||
var expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:";
|
||||
jQuery(document.getElementById('first')).appendTo('#sap');
|
||||
equals( jQuery('#sap').text(), expected, "Check for appending of element" );
|
||||
jQuery(document.getElementById("first")).appendTo("#sap");
|
||||
equals( jQuery("#sap").text(), expected, "Check for appending of element" );
|
||||
|
||||
QUnit.reset();
|
||||
expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
|
||||
jQuery([document.getElementById('first'), document.getElementById('yahoo')]).appendTo('#sap');
|
||||
equals( jQuery('#sap').text(), expected, "Check for appending of array of elements" );
|
||||
jQuery([document.getElementById("first"), document.getElementById("yahoo")]).appendTo("#sap");
|
||||
equals( jQuery("#sap").text(), expected, "Check for appending of array of elements" );
|
||||
|
||||
QUnit.reset();
|
||||
ok( jQuery(document.createElement("script")).appendTo("body").length, "Make sure a disconnected script can be appended." );
|
||||
|
||||
QUnit.reset();
|
||||
expected = "This link has class=\"blog\": Simon Willison's WeblogYahooTry them out:";
|
||||
jQuery("#yahoo, #first").appendTo('#sap');
|
||||
equals( jQuery('#sap').text(), expected, "Check for appending of jQuery object" );
|
||||
jQuery("#yahoo, #first").appendTo("#sap");
|
||||
equals( jQuery("#sap").text(), expected, "Check for appending of jQuery object" );
|
||||
|
||||
QUnit.reset();
|
||||
jQuery('#select1').appendTo('#foo');
|
||||
t( 'Append select', '#foo select', ['select1'] );
|
||||
jQuery("#select1").appendTo("#foo");
|
||||
t( "Append select", "#foo select", ["select1"] );
|
||||
|
||||
QUnit.reset();
|
||||
var div = jQuery("<div/>").click(function(){
|
||||
|
@ -517,25 +517,25 @@ test("appendTo(String|Element|Array<Element>|jQuery)", function() {
|
|||
|
||||
var testPrepend = function(val) {
|
||||
expect(5);
|
||||
var defaultText = 'Try them out:'
|
||||
var result = jQuery('#first').prepend(val( '<b>buga</b>' ));
|
||||
equals( result.text(), 'buga' + defaultText, 'Check if text prepending works' );
|
||||
equals( jQuery('#select3').prepend(val( '<option value="prependTest">Prepend Test</option>' )).find('option:first-child').attr('value'), 'prependTest', 'Prepending html options to select element');
|
||||
var defaultText = "Try them out:"
|
||||
var result = jQuery("#first").prepend(val( "<b>buga</b>" ));
|
||||
equals( result.text(), "buga" + defaultText, "Check if text prepending works" );
|
||||
equals( jQuery("#select3").prepend(val( "<option value='prependTest'>Prepend Test</option>" )).find("option:first-child").attr("value"), "prependTest", "Prepending html options to select element");
|
||||
|
||||
QUnit.reset();
|
||||
var expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";
|
||||
jQuery('#sap').prepend(val( document.getElementById('first') ));
|
||||
equals( jQuery('#sap').text(), expected, "Check for prepending of element" );
|
||||
jQuery("#sap").prepend(val( document.getElementById("first") ));
|
||||
equals( jQuery("#sap").text(), expected, "Check for prepending of element" );
|
||||
|
||||
QUnit.reset();
|
||||
expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
|
||||
jQuery('#sap').prepend(val( [document.getElementById('first'), document.getElementById('yahoo')] ));
|
||||
equals( jQuery('#sap').text(), expected, "Check for prepending of array of elements" );
|
||||
jQuery("#sap").prepend(val( [document.getElementById("first"), document.getElementById("yahoo")] ));
|
||||
equals( jQuery("#sap").text(), expected, "Check for prepending of array of elements" );
|
||||
|
||||
QUnit.reset();
|
||||
expected = "YahooTry them out:This link has class=\"blog\": Simon Willison's Weblog";
|
||||
jQuery('#sap').prepend(val( jQuery("#yahoo, #first") ));
|
||||
equals( jQuery('#sap').text(), expected, "Check for prepending of jQuery object" );
|
||||
jQuery("#sap").prepend(val( jQuery("#yahoo, #first") ));
|
||||
equals( jQuery("#sap").text(), expected, "Check for prepending of jQuery object" );
|
||||
};
|
||||
|
||||
test("prepend(String|Element|Array<Element>|jQuery)", function() {
|
||||
|
@ -549,103 +549,103 @@ test("prepend(Function)", function() {
|
|||
test("prepend(Function) with incoming value", function() {
|
||||
expect(10);
|
||||
|
||||
var defaultText = 'Try them out:', old = jQuery('#first').html();
|
||||
var result = jQuery('#first').prepend(function(i, val) {
|
||||
var defaultText = "Try them out:", old = jQuery("#first").html();
|
||||
var result = jQuery("#first").prepend(function(i, val) {
|
||||
equals( val, old, "Make sure the incoming value is correct." );
|
||||
return '<b>buga</b>';
|
||||
return "<b>buga</b>";
|
||||
});
|
||||
equals( result.text(), 'buga' + defaultText, 'Check if text prepending works' );
|
||||
equals( result.text(), "buga" + defaultText, "Check if text prepending works" );
|
||||
|
||||
old = jQuery("#select3").html();
|
||||
|
||||
equals( jQuery('#select3').prepend(function(i, val) {
|
||||
equals( jQuery("#select3").prepend(function(i, val) {
|
||||
equals( val, old, "Make sure the incoming value is correct." );
|
||||
return '<option value="prependTest">Prepend Test</option>';
|
||||
}).find('option:first-child').attr('value'), 'prependTest', 'Prepending html options to select element');
|
||||
return "<option value='prependTest'>Prepend Test</option>";
|
||||
}).find("option:first-child").attr("value"), "prependTest", "Prepending html options to select element");
|
||||
|
||||
QUnit.reset();
|
||||
var expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";
|
||||
old = jQuery('#sap').html();
|
||||
old = jQuery("#sap").html();
|
||||
|
||||
jQuery('#sap').prepend(function(i, val) {
|
||||
jQuery("#sap").prepend(function(i, val) {
|
||||
equals( val, old, "Make sure the incoming value is correct." );
|
||||
return document.getElementById('first');
|
||||
return document.getElementById("first");
|
||||
});
|
||||
|
||||
equals( jQuery('#sap').text(), expected, "Check for prepending of element" );
|
||||
equals( jQuery("#sap").text(), expected, "Check for prepending of element" );
|
||||
|
||||
QUnit.reset();
|
||||
expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
|
||||
old = jQuery('#sap').html();
|
||||
old = jQuery("#sap").html();
|
||||
|
||||
jQuery('#sap').prepend(function(i, val) {
|
||||
jQuery("#sap").prepend(function(i, val) {
|
||||
equals( val, old, "Make sure the incoming value is correct." );
|
||||
return [document.getElementById('first'), document.getElementById('yahoo')];
|
||||
return [document.getElementById("first"), document.getElementById("yahoo")];
|
||||
});
|
||||
|
||||
equals( jQuery('#sap').text(), expected, "Check for prepending of array of elements" );
|
||||
equals( jQuery("#sap").text(), expected, "Check for prepending of array of elements" );
|
||||
|
||||
QUnit.reset();
|
||||
expected = "YahooTry them out:This link has class=\"blog\": Simon Willison's Weblog";
|
||||
old = jQuery('#sap').html();
|
||||
old = jQuery("#sap").html();
|
||||
|
||||
jQuery('#sap').prepend(function(i, val) {
|
||||
jQuery("#sap").prepend(function(i, val) {
|
||||
equals( val, old, "Make sure the incoming value is correct." );
|
||||
return jQuery("#yahoo, #first");
|
||||
});
|
||||
|
||||
equals( jQuery('#sap').text(), expected, "Check for prepending of jQuery object" );
|
||||
equals( jQuery("#sap").text(), expected, "Check for prepending of jQuery object" );
|
||||
});
|
||||
|
||||
test("prependTo(String|Element|Array<Element>|jQuery)", function() {
|
||||
expect(6);
|
||||
var defaultText = 'Try them out:'
|
||||
jQuery('<b>buga</b>').prependTo('#first');
|
||||
equals( jQuery('#first').text(), 'buga' + defaultText, 'Check if text prepending works' );
|
||||
equals( jQuery('<option value="prependTest">Prepend Test</option>').prependTo('#select3').parent().find('option:first-child').attr('value'), 'prependTest', 'Prepending html options to select element');
|
||||
var defaultText = "Try them out:"
|
||||
jQuery("<b>buga</b>").prependTo("#first");
|
||||
equals( jQuery("#first").text(), "buga" + defaultText, "Check if text prepending works" );
|
||||
equals( jQuery("<option value='prependTest'>Prepend Test</option>").prependTo("#select3").parent().find("option:first-child").attr("value"), "prependTest", "Prepending html options to select element");
|
||||
|
||||
QUnit.reset();
|
||||
var expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";
|
||||
jQuery(document.getElementById('first')).prependTo('#sap');
|
||||
equals( jQuery('#sap').text(), expected, "Check for prepending of element" );
|
||||
jQuery(document.getElementById("first")).prependTo("#sap");
|
||||
equals( jQuery("#sap").text(), expected, "Check for prepending of element" );
|
||||
|
||||
QUnit.reset();
|
||||
expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
|
||||
jQuery([document.getElementById('first'), document.getElementById('yahoo')]).prependTo('#sap');
|
||||
equals( jQuery('#sap').text(), expected, "Check for prepending of array of elements" );
|
||||
jQuery([document.getElementById("first"), document.getElementById("yahoo")]).prependTo("#sap");
|
||||
equals( jQuery("#sap").text(), expected, "Check for prepending of array of elements" );
|
||||
|
||||
QUnit.reset();
|
||||
expected = "YahooTry them out:This link has class=\"blog\": Simon Willison's Weblog";
|
||||
jQuery("#yahoo, #first").prependTo('#sap');
|
||||
equals( jQuery('#sap').text(), expected, "Check for prepending of jQuery object" );
|
||||
jQuery("#yahoo, #first").prependTo("#sap");
|
||||
equals( jQuery("#sap").text(), expected, "Check for prepending of jQuery object" );
|
||||
|
||||
QUnit.reset();
|
||||
jQuery('<select id="prependSelect1"></select>').prependTo('form:last');
|
||||
jQuery('<select id="prependSelect2"><option>Test</option></select>').prependTo('form:last');
|
||||
jQuery("<select id='prependSelect1'></select>").prependTo("form:last");
|
||||
jQuery("<select id='prependSelect2'><option>Test</option></select>").prependTo("form:last");
|
||||
|
||||
t( "Prepend Select", "#prependSelect2, #prependSelect1", ["prependSelect2", "prependSelect1"] );
|
||||
});
|
||||
|
||||
var testBefore = function(val) {
|
||||
expect(6);
|
||||
var expected = 'This is a normal link: bugaYahoo';
|
||||
jQuery('#yahoo').before(val( '<b>buga</b>' ));
|
||||
equals( jQuery('#en').text(), expected, 'Insert String before' );
|
||||
var expected = "This is a normal link: bugaYahoo";
|
||||
jQuery("#yahoo").before(val( "<b>buga</b>" ));
|
||||
equals( jQuery("#en").text(), expected, "Insert String before" );
|
||||
|
||||
QUnit.reset();
|
||||
expected = "This is a normal link: Try them out:Yahoo";
|
||||
jQuery('#yahoo').before(val( document.getElementById('first') ));
|
||||
equals( jQuery('#en').text(), expected, "Insert element before" );
|
||||
jQuery("#yahoo").before(val( document.getElementById("first") ));
|
||||
equals( jQuery("#en").text(), expected, "Insert element before" );
|
||||
|
||||
QUnit.reset();
|
||||
expected = "This is a normal link: Try them out:diveintomarkYahoo";
|
||||
jQuery('#yahoo').before(val( [document.getElementById('first'), document.getElementById('mark')] ));
|
||||
equals( jQuery('#en').text(), expected, "Insert array of elements before" );
|
||||
jQuery("#yahoo").before(val( [document.getElementById("first"), document.getElementById("mark")] ));
|
||||
equals( jQuery("#en").text(), expected, "Insert array of elements before" );
|
||||
|
||||
QUnit.reset();
|
||||
expected = "This is a normal link: diveintomarkTry them out:Yahoo";
|
||||
jQuery('#yahoo').before(val( jQuery("#mark, #first") ));
|
||||
equals( jQuery('#en').text(), expected, "Insert jQuery before" );
|
||||
jQuery("#yahoo").before(val( jQuery("#mark, #first") ));
|
||||
equals( jQuery("#en").text(), expected, "Insert jQuery before" );
|
||||
|
||||
var set = jQuery("<div/>").before("<span>test</span>");
|
||||
equals( set[0].nodeName.toLowerCase(), "span", "Insert the element before the disconnected node." );
|
||||
|
@ -662,46 +662,46 @@ test("before(Function)", function() {
|
|||
|
||||
test("insertBefore(String|Element|Array<Element>|jQuery)", function() {
|
||||
expect(4);
|
||||
var expected = 'This is a normal link: bugaYahoo';
|
||||
jQuery('<b>buga</b>').insertBefore('#yahoo');
|
||||
equals( jQuery('#en').text(), expected, 'Insert String before' );
|
||||
var expected = "This is a normal link: bugaYahoo";
|
||||
jQuery("<b>buga</b>").insertBefore("#yahoo");
|
||||
equals( jQuery("#en").text(), expected, "Insert String before" );
|
||||
|
||||
QUnit.reset();
|
||||
expected = "This is a normal link: Try them out:Yahoo";
|
||||
jQuery(document.getElementById('first')).insertBefore('#yahoo');
|
||||
equals( jQuery('#en').text(), expected, "Insert element before" );
|
||||
jQuery(document.getElementById("first")).insertBefore("#yahoo");
|
||||
equals( jQuery("#en").text(), expected, "Insert element before" );
|
||||
|
||||
QUnit.reset();
|
||||
expected = "This is a normal link: Try them out:diveintomarkYahoo";
|
||||
jQuery([document.getElementById('first'), document.getElementById('mark')]).insertBefore('#yahoo');
|
||||
equals( jQuery('#en').text(), expected, "Insert array of elements before" );
|
||||
jQuery([document.getElementById("first"), document.getElementById("mark")]).insertBefore("#yahoo");
|
||||
equals( jQuery("#en").text(), expected, "Insert array of elements before" );
|
||||
|
||||
QUnit.reset();
|
||||
expected = "This is a normal link: diveintomarkTry them out:Yahoo";
|
||||
jQuery("#mark, #first").insertBefore('#yahoo');
|
||||
equals( jQuery('#en').text(), expected, "Insert jQuery before" );
|
||||
jQuery("#mark, #first").insertBefore("#yahoo");
|
||||
equals( jQuery("#en").text(), expected, "Insert jQuery before" );
|
||||
});
|
||||
|
||||
var testAfter = function(val) {
|
||||
expect(6);
|
||||
var expected = 'This is a normal link: Yahoobuga';
|
||||
jQuery('#yahoo').after(val( '<b>buga</b>' ));
|
||||
equals( jQuery('#en').text(), expected, 'Insert String after' );
|
||||
var expected = "This is a normal link: Yahoobuga";
|
||||
jQuery("#yahoo").after(val( "<b>buga</b>" ));
|
||||
equals( jQuery("#en").text(), expected, "Insert String after" );
|
||||
|
||||
QUnit.reset();
|
||||
expected = "This is a normal link: YahooTry them out:";
|
||||
jQuery('#yahoo').after(val( document.getElementById('first') ));
|
||||
equals( jQuery('#en').text(), expected, "Insert element after" );
|
||||
jQuery("#yahoo").after(val( document.getElementById("first") ));
|
||||
equals( jQuery("#en").text(), expected, "Insert element after" );
|
||||
|
||||
QUnit.reset();
|
||||
expected = "This is a normal link: YahooTry them out:diveintomark";
|
||||
jQuery('#yahoo').after(val( [document.getElementById('first'), document.getElementById('mark')] ));
|
||||
equals( jQuery('#en').text(), expected, "Insert array of elements after" );
|
||||
jQuery("#yahoo").after(val( [document.getElementById("first"), document.getElementById("mark")] ));
|
||||
equals( jQuery("#en").text(), expected, "Insert array of elements after" );
|
||||
|
||||
QUnit.reset();
|
||||
expected = "This is a normal link: YahoodiveintomarkTry them out:";
|
||||
jQuery('#yahoo').after(val( jQuery("#mark, #first") ));
|
||||
equals( jQuery('#en').text(), expected, "Insert jQuery after" );
|
||||
jQuery("#yahoo").after(val( jQuery("#mark, #first") ));
|
||||
equals( jQuery("#en").text(), expected, "Insert jQuery after" );
|
||||
|
||||
var set = jQuery("<div/>").after("<span>test</span>");
|
||||
equals( set[1].nodeName.toLowerCase(), "span", "Insert the element after the disconnected node." );
|
||||
|
@ -718,58 +718,58 @@ test("after(Function)", function() {
|
|||
|
||||
test("insertAfter(String|Element|Array<Element>|jQuery)", function() {
|
||||
expect(4);
|
||||
var expected = 'This is a normal link: Yahoobuga';
|
||||
jQuery('<b>buga</b>').insertAfter('#yahoo');
|
||||
equals( jQuery('#en').text(), expected, 'Insert String after' );
|
||||
var expected = "This is a normal link: Yahoobuga";
|
||||
jQuery("<b>buga</b>").insertAfter("#yahoo");
|
||||
equals( jQuery("#en").text(), expected, "Insert String after" );
|
||||
|
||||
QUnit.reset();
|
||||
expected = "This is a normal link: YahooTry them out:";
|
||||
jQuery(document.getElementById('first')).insertAfter('#yahoo');
|
||||
equals( jQuery('#en').text(), expected, "Insert element after" );
|
||||
jQuery(document.getElementById("first")).insertAfter("#yahoo");
|
||||
equals( jQuery("#en").text(), expected, "Insert element after" );
|
||||
|
||||
QUnit.reset();
|
||||
expected = "This is a normal link: YahooTry them out:diveintomark";
|
||||
jQuery([document.getElementById('first'), document.getElementById('mark')]).insertAfter('#yahoo');
|
||||
equals( jQuery('#en').text(), expected, "Insert array of elements after" );
|
||||
jQuery([document.getElementById("first"), document.getElementById("mark")]).insertAfter("#yahoo");
|
||||
equals( jQuery("#en").text(), expected, "Insert array of elements after" );
|
||||
|
||||
QUnit.reset();
|
||||
expected = "This is a normal link: YahoodiveintomarkTry them out:";
|
||||
jQuery("#mark, #first").insertAfter('#yahoo');
|
||||
equals( jQuery('#en').text(), expected, "Insert jQuery after" );
|
||||
jQuery("#mark, #first").insertAfter("#yahoo");
|
||||
equals( jQuery("#en").text(), expected, "Insert jQuery after" );
|
||||
});
|
||||
|
||||
var testReplaceWith = function(val) {
|
||||
expect(21);
|
||||
jQuery('#yahoo').replaceWith(val( '<b id="replace">buga</b>' ));
|
||||
ok( jQuery("#replace")[0], 'Replace element with string' );
|
||||
ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after string' );
|
||||
jQuery("#yahoo").replaceWith(val( "<b id='replace'>buga</b>" ));
|
||||
ok( jQuery("#replace")[0], "Replace element with string" );
|
||||
ok( !jQuery("#yahoo")[0], "Verify that original element is gone, after string" );
|
||||
|
||||
QUnit.reset();
|
||||
jQuery('#yahoo').replaceWith(val( document.getElementById('first') ));
|
||||
ok( jQuery("#first")[0], 'Replace element with element' );
|
||||
ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after element' );
|
||||
jQuery("#yahoo").replaceWith(val( document.getElementById("first") ));
|
||||
ok( jQuery("#first")[0], "Replace element with element" );
|
||||
ok( !jQuery("#yahoo")[0], "Verify that original element is gone, after element" );
|
||||
|
||||
QUnit.reset();
|
||||
jQuery("#main").append('<div id="bar"><div id="baz">Foo</div></div>');
|
||||
jQuery('#baz').replaceWith("Baz");
|
||||
equals( jQuery("#bar").text(),"Baz", 'Replace element with text' );
|
||||
ok( !jQuery("#baz")[0], 'Verify that original element is gone, after element' );
|
||||
jQuery("#main").append("<div id='bar'><div id='baz'</div></div>");
|
||||
jQuery("#baz").replaceWith("Baz");
|
||||
equals( jQuery("#bar").text(),"Baz", "Replace element with text" );
|
||||
ok( !jQuery("#baz")[0], "Verify that original element is gone, after element" );
|
||||
|
||||
QUnit.reset();
|
||||
jQuery('#yahoo').replaceWith(val( [document.getElementById('first'), document.getElementById('mark')] ));
|
||||
ok( jQuery("#first")[0], 'Replace element with array of elements' );
|
||||
ok( jQuery("#mark")[0], 'Replace element with array of elements' );
|
||||
ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after array of elements' );
|
||||
jQuery("#yahoo").replaceWith(val( [document.getElementById("first"), document.getElementById("mark")] ));
|
||||
ok( jQuery("#first")[0], "Replace element with array of elements" );
|
||||
ok( jQuery("#mark")[0], "Replace element with array of elements" );
|
||||
ok( !jQuery("#yahoo")[0], "Verify that original element is gone, after array of elements" );
|
||||
|
||||
QUnit.reset();
|
||||
jQuery('#yahoo').replaceWith(val( jQuery("#mark, #first") ));
|
||||
ok( jQuery("#first")[0], 'Replace element with set of elements' );
|
||||
ok( jQuery("#mark")[0], 'Replace element with set of elements' );
|
||||
ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after set of elements' );
|
||||
jQuery("#yahoo").replaceWith(val( jQuery("#mark, #first") ));
|
||||
ok( jQuery("#first")[0], "Replace element with set of elements" );
|
||||
ok( jQuery("#mark")[0], "Replace element with set of elements" );
|
||||
ok( !jQuery("#yahoo")[0], "Verify that original element is gone, after set of elements" );
|
||||
|
||||
QUnit.reset();
|
||||
var tmp = jQuery("<div/>").appendTo("body").click(function(){ ok(true, "Newly bound click run." ); });
|
||||
var y = jQuery('<div/>').appendTo("body").click(function(){ ok(true, "Previously bound click run." ); });
|
||||
var y = jQuery("<div/>").appendTo("body").click(function(){ ok(true, "Previously bound click run." ); });
|
||||
var child = y.append("<b>test</b>").find("b").click(function(){ ok(true, "Child bound click run." ); return false; });
|
||||
|
||||
y.replaceWith( tmp );
|
||||
|
@ -784,7 +784,7 @@ var testReplaceWith = function(val) {
|
|||
|
||||
QUnit.reset();
|
||||
|
||||
y = jQuery('<div/>').appendTo("body").click(function(){ ok(true, "Previously bound click run." ); });
|
||||
y = jQuery("<div/>").appendTo("body").click(function(){ ok(true, "Previously bound click run." ); });
|
||||
var child2 = y.append("<u>test</u>").find("u").click(function(){ ok(true, "Child 2 bound click run." ); return false; });
|
||||
|
||||
y.replaceWith( child2 );
|
||||
|
@ -800,7 +800,7 @@ var testReplaceWith = function(val) {
|
|||
equals( set[0].nodeName.toLowerCase(), "span", "Replace the disconnected node." );
|
||||
equals( set.length, 1, "Replace the disconnected node." );
|
||||
|
||||
var non_existant = jQuery('#does-not-exist').replaceWith( val("<b>should not throw an error</b>") );
|
||||
var non_existant = jQuery("#does-not-exist").replaceWith( val("<b>should not throw an error</b>") );
|
||||
equals( non_existant.length, 0, "Length of non existant element." );
|
||||
|
||||
var $div = jQuery("<div class='replacewith'></div>").appendTo("body");
|
||||
|
@ -808,8 +808,8 @@ var testReplaceWith = function(val) {
|
|||
//$div.replaceWith("<div class='replacewith'></div><script>" +
|
||||
//"equals(jQuery('.replacewith').length, 1, 'Check number of elements in page.');" +
|
||||
//"</script>");
|
||||
equals(jQuery('.replacewith').length, 1, 'Check number of elements in page.');
|
||||
jQuery('.replacewith').remove();
|
||||
equals(jQuery(".replacewith").length, 1, "Check number of elements in page.");
|
||||
jQuery(".replacewith").remove();
|
||||
|
||||
QUnit.reset();
|
||||
|
||||
|
@ -844,35 +844,35 @@ test("replaceWith(Function)", function() {
|
|||
test("replaceWith(string) for more than one element", function(){
|
||||
expect(3);
|
||||
|
||||
equals(jQuery('#foo p').length, 3, 'ensuring that test data has not changed');
|
||||
equals(jQuery("#foo p").length, 3, "ensuring that test data has not changed");
|
||||
|
||||
jQuery('#foo p').replaceWith('<span>bar</span>');
|
||||
equals(jQuery('#foo span').length, 3, 'verify that all the three original element have been replaced');
|
||||
equals(jQuery('#foo p').length, 0, 'verify that all the three original element have been replaced');
|
||||
jQuery("#foo p").replaceWith("<span>bar</span>");
|
||||
equals(jQuery("#foo span").length, 3, "verify that all the three original element have been replaced");
|
||||
equals(jQuery("#foo p").length, 0, "verify that all the three original element have been replaced");
|
||||
});
|
||||
|
||||
test("replaceAll(String|Element|Array<Element>|jQuery)", function() {
|
||||
expect(10);
|
||||
jQuery('<b id="replace">buga</b>').replaceAll("#yahoo");
|
||||
ok( jQuery("#replace")[0], 'Replace element with string' );
|
||||
ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after string' );
|
||||
jQuery("<b id='replace'>buga</b>").replaceAll("#yahoo");
|
||||
ok( jQuery("#replace")[0], "Replace element with string" );
|
||||
ok( !jQuery("#yahoo")[0], "Verify that original element is gone, after string" );
|
||||
|
||||
QUnit.reset();
|
||||
jQuery(document.getElementById('first')).replaceAll("#yahoo");
|
||||
ok( jQuery("#first")[0], 'Replace element with element' );
|
||||
ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after element' );
|
||||
jQuery(document.getElementById("first")).replaceAll("#yahoo");
|
||||
ok( jQuery("#first")[0], "Replace element with element" );
|
||||
ok( !jQuery("#yahoo")[0], "Verify that original element is gone, after element" );
|
||||
|
||||
QUnit.reset();
|
||||
jQuery([document.getElementById('first'), document.getElementById('mark')]).replaceAll("#yahoo");
|
||||
ok( jQuery("#first")[0], 'Replace element with array of elements' );
|
||||
ok( jQuery("#mark")[0], 'Replace element with array of elements' );
|
||||
ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after array of elements' );
|
||||
jQuery([document.getElementById("first"), document.getElementById("mark")]).replaceAll("#yahoo");
|
||||
ok( jQuery("#first")[0], "Replace element with array of elements" );
|
||||
ok( jQuery("#mark")[0], "Replace element with array of elements" );
|
||||
ok( !jQuery("#yahoo")[0], "Verify that original element is gone, after array of elements" );
|
||||
|
||||
QUnit.reset();
|
||||
jQuery("#mark, #first").replaceAll("#yahoo");
|
||||
ok( jQuery("#first")[0], 'Replace element with set of elements' );
|
||||
ok( jQuery("#mark")[0], 'Replace element with set of elements' );
|
||||
ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after set of elements' );
|
||||
ok( jQuery("#first")[0], "Replace element with set of elements" );
|
||||
ok( jQuery("#mark")[0], "Replace element with set of elements" );
|
||||
ok( !jQuery("#yahoo")[0], "Verify that original element is gone, after set of elements" );
|
||||
});
|
||||
|
||||
test("jQuery.clone() (#8017)", function() {
|
||||
|
@ -890,9 +890,9 @@ test("jQuery.clone() (#8017)", function() {
|
|||
test("clone() (#8070)", function () {
|
||||
expect(2);
|
||||
|
||||
jQuery('<select class="test8070"></select><select class="test8070"></select>').appendTo('#main');
|
||||
var selects = jQuery('.test8070');
|
||||
selects.append('<OPTION>1</OPTION><OPTION>2</OPTION>');
|
||||
jQuery("<select class='test8070'></select><select class='test8070'></select>").appendTo("#main");
|
||||
var selects = jQuery(".test8070");
|
||||
selects.append("<OPTION>1</OPTION><OPTION>2</OPTION>");
|
||||
|
||||
equals( selects[0].childNodes.length, 2, "First select got two nodes" );
|
||||
equals( selects[1].childNodes.length, 2, "Second select got two nodes" );
|
||||
|
@ -902,10 +902,10 @@ test("clone() (#8070)", function () {
|
|||
|
||||
test("clone()", function() {
|
||||
expect(37);
|
||||
equals( 'This is a normal link: Yahoo', jQuery('#en').text(), 'Assert text for #en' );
|
||||
var clone = jQuery('#yahoo').clone();
|
||||
equals( 'Try them out:Yahoo', jQuery('#first').append(clone).text(), 'Check for clone' );
|
||||
equals( 'This is a normal link: Yahoo', jQuery('#en').text(), 'Reassert text for #en' );
|
||||
equals( "This is a normal link: Yahoo", jQuery("#en").text(), "Assert text for #en" );
|
||||
var clone = jQuery("#yahoo").clone();
|
||||
equals( "Try them out:Yahoo", jQuery("#first").append(clone).text(), "Check for clone" );
|
||||
equals( "This is a normal link: Yahoo", jQuery("#en").text(), "Reassert text for #en" );
|
||||
|
||||
var cloneTags = [
|
||||
"<table/>", "<tr/>", "<td/>", "<div/>",
|
||||
|
@ -915,7 +915,7 @@ test("clone()", function() {
|
|||
];
|
||||
for (var i = 0; i < cloneTags.length; i++) {
|
||||
var j = jQuery(cloneTags[i]);
|
||||
equals( j[0].tagName, j.clone()[0].tagName, 'Clone a ' + cloneTags[i]);
|
||||
equals( j[0].tagName, j.clone()[0].tagName, "Clone a " + cloneTags[i]);
|
||||
}
|
||||
|
||||
// using contents will get comments regular, text, and comment nodes
|
||||
|
@ -971,7 +971,7 @@ test("clone()", function() {
|
|||
// this is technically an invalid object, but because of the special
|
||||
// classid instantiation it is the only kind that IE has trouble with,
|
||||
// so let's test with it too.
|
||||
div = jQuery("<div/>").html('<object height="355" width="425" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"> <param name="movie" value="http://www.youtube.com/v/3KANI2dpXLw&hl=en"> <param name="wmode" value="transparent"> </object>');
|
||||
div = jQuery("<div/>").html("<object height='355' width='425' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'> <param name='movie' value='http://www.youtube.com/v/3KANI2dpXLw&hl=en'> <param name='wmode' value='transparent'> </object>");
|
||||
|
||||
clone = div.clone(true);
|
||||
equals( clone.length, 1, "One element cloned" );
|
||||
|
@ -979,7 +979,7 @@ test("clone()", function() {
|
|||
equals( clone[0].nodeName.toUpperCase(), "DIV", "DIV element cloned" );
|
||||
|
||||
// and here's a valid one.
|
||||
div = jQuery("<div/>").html('<object height="355" width="425" type="application/x-shockwave-flash" data="http://www.youtube.com/v/3KANI2dpXLw&hl=en"> <param name="movie" value="http://www.youtube.com/v/3KANI2dpXLw&hl=en"> <param name="wmode" value="transparent"> </object>');
|
||||
div = jQuery("<div/>").html("<object height='355' width='425' type='application/x-shockwave-flash' data='http://www.youtube.com/v/3KANI2dpXLw&hl=en'> <param name='movie' value='http://www.youtube.com/v/3KANI2dpXLw&hl=en'> <param name='wmode' value='transparent'> </object>");
|
||||
|
||||
clone = div.clone(true);
|
||||
equals( clone.length, 1, "One element cloned" );
|
||||
|
@ -1014,7 +1014,7 @@ test("clone(form element) (Bug #3879, #6655)", function() {
|
|||
|
||||
equals( element.clone().find("option:selected").val(), element.find("option:selected").val(), "Selected option cloned correctly" );
|
||||
|
||||
element = jQuery("<input type='checkbox' value='foo'>").attr('checked', 'checked');
|
||||
element = jQuery("<input type='checkbox' value='foo'>").attr("checked", "checked");
|
||||
clone = element.clone();
|
||||
|
||||
equals( clone.is(":checked"), element.is(":checked"), "Checked input cloned correctly" );
|
||||
|
@ -1058,7 +1058,7 @@ test("clone() on XML nodes", function() {
|
|||
}
|
||||
|
||||
var testHtml = function(valueObj) {
|
||||
expect(31);
|
||||
expect(34);
|
||||
|
||||
jQuery.scriptorder = 0;
|
||||
|
||||
|
@ -1070,7 +1070,7 @@ var testHtml = function(valueObj) {
|
|||
}
|
||||
ok( pass, "Set HTML" );
|
||||
|
||||
div = jQuery("<div/>").html( valueObj('<div id="parent_1"><div id="child_1"/></div><div id="parent_2"/>') );
|
||||
div = jQuery("<div/>").html( valueObj("<div id='parent_1'><div id='child_1'/></div><div id='parent_2'/>") );
|
||||
|
||||
equals( div.children().length, 2, "Make sure two child nodes exist." );
|
||||
equals( div.children().children().length, 1, "Make sure that a grandchild exists." );
|
||||
|
@ -1090,18 +1090,18 @@ var testHtml = function(valueObj) {
|
|||
j.html(valueObj("<b>bold</b>"));
|
||||
|
||||
// this is needed, or the expando added by jQuery unique will yield a different html
|
||||
j.find('b').removeData();
|
||||
j.find("b").removeData();
|
||||
equals( j.html().replace(/ xmlns="[^"]+"/g, "").toLowerCase(), "<b>bold</b>", "Check node,textnode,comment with html()" );
|
||||
|
||||
jQuery("#main").html(valueObj("<select/>"));
|
||||
jQuery("#main select").html(valueObj("<option>O1</option><option selected='selected'>O2</option><option>O3</option>"));
|
||||
equals( jQuery("#main select").val(), "O2", "Selected option correct" );
|
||||
|
||||
var $div = jQuery('<div />');
|
||||
equals( $div.html(valueObj( 5 )).html(), '5', 'Setting a number as html' );
|
||||
equals( $div.html(valueObj( 0 )).html(), '0', 'Setting a zero as html' );
|
||||
var $div = jQuery("<div />");
|
||||
equals( $div.html(valueObj( 5 )).html(), "5", "Setting a number as html" );
|
||||
equals( $div.html(valueObj( 0 )).html(), "0", "Setting a zero as html" );
|
||||
|
||||
var $div2 = jQuery('<div/>'), insert = "<div>hello1</div>";
|
||||
var $div2 = jQuery("<div/>"), insert = "<div>hello1</div>";
|
||||
equals( $div2.html(insert).html().replace(/>/g, ">"), insert, "Verify escaped insertion." );
|
||||
equals( $div2.html("x" + insert).html().replace(/>/g, ">"), "x" + insert, "Verify escaped insertion." );
|
||||
equals( $div2.html(" " + insert).html().replace(/>/g, ">"), " " + insert, "Verify escaped insertion." );
|
||||
|
@ -1113,15 +1113,21 @@ var testHtml = function(valueObj) {
|
|||
|
||||
QUnit.reset();
|
||||
|
||||
jQuery("#main").html(valueObj('<script type="something/else">ok( false, "Non-script evaluated." );</script><script type="text/javascript">ok( true, "text/javascript is evaluated." );</script><script>ok( true, "No type is evaluated." );</script><div><script type="text/javascript">ok( true, "Inner text/javascript is evaluated." );</script><script>ok( true, "Inner No type is evaluated." );</script><script type="something/else">ok( false, "Non-script evaluated." );</script></div>'));
|
||||
jQuery("#main").html(valueObj("<script type='something/else'>ok( false, 'Non-script evaluated.' );</script><script type='text/javascript'>ok( true, 'text/javascript is evaluated.' );</script><script>ok( true, 'No type is evaluated.' );</script><div><script type='text/javascript'>ok( true, 'Inner text/javascript is evaluated.' );</script><script>ok( true, 'Inner No type is evaluated.' );</script><script type='something/else'>ok( false, 'Non-script evaluated.' );</script></div>"));
|
||||
|
||||
var child = jQuery("#main").find("script");
|
||||
|
||||
equals( child.length, 2, "Make sure that two non-JavaScript script tags are left." );
|
||||
equals( child[0].type, "something/else", "Verify type of script tag." );
|
||||
equals( child[1].type, "something/else", "Verify type of script tag." );
|
||||
|
||||
jQuery("#main").html(valueObj("<script>ok( true, 'Test repeated injection of script.' );</script>"));
|
||||
jQuery("#main").html(valueObj("<script>ok( true, 'Test repeated injection of script.' );</script>"));
|
||||
jQuery("#main").html(valueObj("<script>ok( true, 'Test repeated injection of script.' );</script>"));
|
||||
|
||||
jQuery("#main").html(valueObj('<script type="text/javascript">ok( true, "jQuery().html().evalScripts() Evals Scripts Twice in Firefox, see #975 (1)" );</script>'));
|
||||
jQuery("#main").html(valueObj("<script type='text/javascript'>ok( true, 'jQuery().html().evalScripts() Evals Scripts Twice in Firefox, see #975 (1)' );</script>"));
|
||||
|
||||
jQuery("#main").html(valueObj('foo <form><script type="text/javascript">ok( true, "jQuery().html().evalScripts() Evals Scripts Twice in Firefox, see #975 (2)" );</script></form>'));
|
||||
jQuery("#main").html(valueObj("foo <form><script type='text/javascript'>ok( true, 'jQuery().html().evalScripts() Evals Scripts Twice in Firefox, see #975 (2)' );</script></form>"));
|
||||
|
||||
jQuery("#main").html(valueObj("<script>equals(jQuery.scriptorder++, 0, 'Script is executed in order');equals(jQuery('#scriptorder').length, 1,'Execute after html (even though appears before)')<\/script><span id='scriptorder'><script>equals(jQuery.scriptorder++, 1, 'Script (nested) is executed in order');equals(jQuery('#scriptorder').length, 1,'Execute after html')<\/script></span><script>equals(jQuery.scriptorder++, 2, 'Script (unnested) is executed in order');equals(jQuery('#scriptorder').length, 1,'Execute after html')<\/script>"));
|
||||
}
|
||||
|
@ -1133,7 +1139,7 @@ test("html(String)", function() {
|
|||
test("html(Function)", function() {
|
||||
testHtml(functionReturningObj);
|
||||
|
||||
expect(33);
|
||||
expect(36);
|
||||
|
||||
QUnit.reset();
|
||||
|
||||
|
@ -1178,22 +1184,22 @@ test("html(Function) with incoming value", function() {
|
|||
equals( null, null, "Make sure the incoming value is correct." );
|
||||
}
|
||||
|
||||
j.find('b').removeData();
|
||||
j.find("b").removeData();
|
||||
equals( j.html().replace(/ xmlns="[^"]+"/g, "").toLowerCase(), "<b>bold</b>", "Check node,textnode,comment with html()" );
|
||||
|
||||
var $div = jQuery('<div />');
|
||||
var $div = jQuery("<div />");
|
||||
|
||||
equals( $div.html(function(i, val) {
|
||||
equals( val, "", "Make sure the incoming value is correct." );
|
||||
return 5;
|
||||
}).html(), '5', 'Setting a number as html' );
|
||||
}).html(), "5", "Setting a number as html" );
|
||||
|
||||
equals( $div.html(function(i, val) {
|
||||
equals( val, "5", "Make sure the incoming value is correct." );
|
||||
return 0;
|
||||
}).html(), '0', 'Setting a zero as html' );
|
||||
}).html(), "0", "Setting a zero as html" );
|
||||
|
||||
var $div2 = jQuery('<div/>'), insert = "<div>hello1</div>";
|
||||
var $div2 = jQuery("<div/>"), insert = "<div>hello1</div>";
|
||||
equals( $div2.html(function(i, val) {
|
||||
equals( val, "", "Make sure the incoming value is correct." );
|
||||
return insert;
|
||||
|
@ -1362,6 +1368,6 @@ 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();
|
||||
});
|
||||
|
|
|
@ -20,7 +20,7 @@ testoffset("absolute"/* in iframe */, function($, iframe) {
|
|||
// this insures that the results will be wrong
|
||||
// if the offset method is using the scroll offset
|
||||
// of the parent window
|
||||
var forceScroll = jQuery('<div>', { width: 2000, height: 2000 }).appendTo('body');
|
||||
var forceScroll = jQuery("<div>", { width: 2000, height: 2000 }).appendTo("body");
|
||||
window.scrollTo(200, 200);
|
||||
|
||||
if ( document.documentElement.scrollTop || document.body.scrollTop ) {
|
||||
|
@ -31,7 +31,7 @@ testoffset("absolute"/* in iframe */, function($, iframe) {
|
|||
|
||||
// get offset
|
||||
tests = [
|
||||
{ id: '#absolute-1', top: 1, left: 1 }
|
||||
{ id: "#absolute-1", top: 1, left: 1 }
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
equals( jQuery( this.id, doc ).offset().top, this.top, "jQuery('" + this.id + "').offset().top" );
|
||||
|
@ -41,7 +41,7 @@ testoffset("absolute"/* in iframe */, function($, iframe) {
|
|||
|
||||
// get position
|
||||
tests = [
|
||||
{ id: '#absolute-1', top: 0, left: 0 }
|
||||
{ id: "#absolute-1", top: 0, left: 0 }
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
equals( jQuery( this.id, doc ).position().top, this.top, "jQuery('" + this.id + "').position().top" );
|
||||
|
@ -56,10 +56,10 @@ testoffset("absolute", function( jQuery ) {
|
|||
|
||||
// get offset tests
|
||||
var tests = [
|
||||
{ id: '#absolute-1', top: 1, left: 1 },
|
||||
{ id: '#absolute-1-1', top: 5, left: 5 },
|
||||
{ id: '#absolute-1-1-1', top: 9, left: 9 },
|
||||
{ id: '#absolute-2', top: 20, left: 20 }
|
||||
{ id: "#absolute-1", top: 1, left: 1 },
|
||||
{ id: "#absolute-1-1", top: 5, left: 5 },
|
||||
{ id: "#absolute-1-1-1", top: 9, left: 9 },
|
||||
{ id: "#absolute-2", top: 20, left: 20 }
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
equals( jQuery( this.id ).offset().top, this.top, "jQuery('" + this.id + "').offset().top" );
|
||||
|
@ -69,10 +69,10 @@ testoffset("absolute", function( jQuery ) {
|
|||
|
||||
// get position
|
||||
tests = [
|
||||
{ id: '#absolute-1', top: 0, left: 0 },
|
||||
{ id: '#absolute-1-1', top: 1, left: 1 },
|
||||
{ id: '#absolute-1-1-1', top: 1, left: 1 },
|
||||
{ id: '#absolute-2', top: 19, left: 19 }
|
||||
{ id: "#absolute-1", top: 0, left: 0 },
|
||||
{ id: "#absolute-1-1", top: 1, left: 1 },
|
||||
{ id: "#absolute-1-1-1", top: 1, left: 1 },
|
||||
{ id: "#absolute-2", top: 19, left: 19 }
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
equals( jQuery( this.id ).position().top, this.top, "jQuery('" + this.id + "').position().top" );
|
||||
|
@ -80,29 +80,29 @@ testoffset("absolute", function( jQuery ) {
|
|||
});
|
||||
|
||||
// test #5781
|
||||
var offset = jQuery( '#positionTest' ).offset({ top: 10, left: 10 }).offset();
|
||||
var offset = jQuery( "#positionTest" ).offset({ top: 10, left: 10 }).offset();
|
||||
equals( offset.top, 10, "Setting offset on element with position absolute but 'auto' values." )
|
||||
equals( offset.left, 10, "Setting offset on element with position absolute but 'auto' values." )
|
||||
|
||||
|
||||
// set offset
|
||||
tests = [
|
||||
{ id: '#absolute-2', top: 30, left: 30 },
|
||||
{ id: '#absolute-2', top: 10, left: 10 },
|
||||
{ id: '#absolute-2', top: -1, left: -1 },
|
||||
{ id: '#absolute-2', top: 19, left: 19 },
|
||||
{ id: '#absolute-1-1-1', top: 15, left: 15 },
|
||||
{ id: '#absolute-1-1-1', top: 5, left: 5 },
|
||||
{ id: '#absolute-1-1-1', top: -1, left: -1 },
|
||||
{ id: '#absolute-1-1-1', top: 9, left: 9 },
|
||||
{ id: '#absolute-1-1', top: 10, left: 10 },
|
||||
{ id: '#absolute-1-1', top: 0, left: 0 },
|
||||
{ id: '#absolute-1-1', top: -1, left: -1 },
|
||||
{ id: '#absolute-1-1', top: 5, left: 5 },
|
||||
{ id: '#absolute-1', top: 2, left: 2 },
|
||||
{ id: '#absolute-1', top: 0, left: 0 },
|
||||
{ id: '#absolute-1', top: -1, left: -1 },
|
||||
{ id: '#absolute-1', top: 1, left: 1 }
|
||||
{ id: "#absolute-2", top: 30, left: 30 },
|
||||
{ id: "#absolute-2", top: 10, left: 10 },
|
||||
{ id: "#absolute-2", top: -1, left: -1 },
|
||||
{ id: "#absolute-2", top: 19, left: 19 },
|
||||
{ id: "#absolute-1-1-1", top: 15, left: 15 },
|
||||
{ id: "#absolute-1-1-1", top: 5, left: 5 },
|
||||
{ id: "#absolute-1-1-1", top: -1, left: -1 },
|
||||
{ id: "#absolute-1-1-1", top: 9, left: 9 },
|
||||
{ id: "#absolute-1-1", top: 10, left: 10 },
|
||||
{ id: "#absolute-1-1", top: 0, left: 0 },
|
||||
{ id: "#absolute-1-1", top: -1, left: -1 },
|
||||
{ id: "#absolute-1-1", top: 5, left: 5 },
|
||||
{ id: "#absolute-1", top: 2, left: 2 },
|
||||
{ id: "#absolute-1", top: 0, left: 0 },
|
||||
{ id: "#absolute-1", top: -1, left: -1 },
|
||||
{ id: "#absolute-1", top: 1, left: 1 }
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
jQuery( this.id ).offset({ top: this.top, left: this.left });
|
||||
|
@ -144,9 +144,9 @@ testoffset("relative", function( jQuery ) {
|
|||
|
||||
// get offset
|
||||
var tests = [
|
||||
{ id: '#relative-1', top: ie ? 6 : 7, left: 7 },
|
||||
{ id: '#relative-1-1', top: ie ? 13 : 15, left: 15 },
|
||||
{ id: '#relative-2', top: ie ? 141 : 142, left: 27 }
|
||||
{ id: "#relative-1", top: ie ? 6 : 7, left: 7 },
|
||||
{ id: "#relative-1-1", top: ie ? 13 : 15, left: 15 },
|
||||
{ id: "#relative-2", top: ie ? 141 : 142, left: 27 }
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
equals( jQuery( this.id ).offset().top, this.top, "jQuery('" + this.id + "').offset().top" );
|
||||
|
@ -156,9 +156,9 @@ testoffset("relative", function( jQuery ) {
|
|||
|
||||
// get position
|
||||
tests = [
|
||||
{ id: '#relative-1', top: ie ? 5 : 6, left: 6 },
|
||||
{ id: '#relative-1-1', top: ie ? 4 : 5, left: 5 },
|
||||
{ id: '#relative-2', top: ie ? 140 : 141, left: 26 }
|
||||
{ id: "#relative-1", top: ie ? 5 : 6, left: 6 },
|
||||
{ id: "#relative-1-1", top: ie ? 4 : 5, left: 5 },
|
||||
{ id: "#relative-2", top: ie ? 140 : 141, left: 26 }
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
equals( jQuery( this.id ).position().top, this.top, "jQuery('" + this.id + "').position().top" );
|
||||
|
@ -168,18 +168,18 @@ testoffset("relative", function( jQuery ) {
|
|||
|
||||
// set offset
|
||||
tests = [
|
||||
{ id: '#relative-2', top: 200, left: 50 },
|
||||
{ id: '#relative-2', top: 100, left: 10 },
|
||||
{ id: '#relative-2', top: -5, left: -5 },
|
||||
{ id: '#relative-2', top: 142, left: 27 },
|
||||
{ id: '#relative-1-1', top: 100, left: 100 },
|
||||
{ id: '#relative-1-1', top: 5, left: 5 },
|
||||
{ id: '#relative-1-1', top: -1, left: -1 },
|
||||
{ id: '#relative-1-1', top: 15, left: 15 },
|
||||
{ id: '#relative-1', top: 100, left: 100 },
|
||||
{ id: '#relative-1', top: 0, left: 0 },
|
||||
{ id: '#relative-1', top: -1, left: -1 },
|
||||
{ id: '#relative-1', top: 7, left: 7 }
|
||||
{ id: "#relative-2", top: 200, left: 50 },
|
||||
{ id: "#relative-2", top: 100, left: 10 },
|
||||
{ id: "#relative-2", top: -5, left: -5 },
|
||||
{ id: "#relative-2", top: 142, left: 27 },
|
||||
{ id: "#relative-1-1", top: 100, left: 100 },
|
||||
{ id: "#relative-1-1", top: 5, left: 5 },
|
||||
{ id: "#relative-1-1", top: -1, left: -1 },
|
||||
{ id: "#relative-1-1", top: 15, left: 15 },
|
||||
{ id: "#relative-1", top: 100, left: 100 },
|
||||
{ id: "#relative-1", top: 0, left: 0 },
|
||||
{ id: "#relative-1", top: -1, left: -1 },
|
||||
{ id: "#relative-1", top: 7, left: 7 }
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
jQuery( this.id ).offset({ top: this.top, left: this.left });
|
||||
|
@ -205,10 +205,10 @@ testoffset("static", function( jQuery ) {
|
|||
|
||||
// get offset
|
||||
var tests = [
|
||||
{ id: '#static-1', top: ie ? 6 : 7, left: 7 },
|
||||
{ id: '#static-1-1', top: ie ? 13 : 15, left: 15 },
|
||||
{ id: '#static-1-1-1', top: ie ? 20 : 23, left: 23 },
|
||||
{ id: '#static-2', top: ie ? 121 : 122, left: 7 }
|
||||
{ id: "#static-1", top: ie ? 6 : 7, left: 7 },
|
||||
{ id: "#static-1-1", top: ie ? 13 : 15, left: 15 },
|
||||
{ id: "#static-1-1-1", top: ie ? 20 : 23, left: 23 },
|
||||
{ id: "#static-2", top: ie ? 121 : 122, left: 7 }
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
equals( jQuery( this.id ).offset().top, this.top, "jQuery('" + this.id + "').offset().top" );
|
||||
|
@ -218,10 +218,10 @@ testoffset("static", function( jQuery ) {
|
|||
|
||||
// get position
|
||||
tests = [
|
||||
{ id: '#static-1', top: ie ? 5 : 6, left: 6 },
|
||||
{ id: '#static-1-1', top: ie ? 12 : 14, left: 14 },
|
||||
{ id: '#static-1-1-1', top: ie ? 19 : 22, left: 22 },
|
||||
{ id: '#static-2', top: ie ? 120 : 121, left: 6 }
|
||||
{ id: "#static-1", top: ie ? 5 : 6, left: 6 },
|
||||
{ id: "#static-1-1", top: ie ? 12 : 14, left: 14 },
|
||||
{ id: "#static-1-1-1", top: ie ? 19 : 22, left: 22 },
|
||||
{ id: "#static-2", top: ie ? 120 : 121, left: 6 }
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
equals( jQuery( this.id ).position().top, this.top, "jQuery('" + this.top + "').position().top" );
|
||||
|
@ -231,22 +231,22 @@ testoffset("static", function( jQuery ) {
|
|||
|
||||
// set offset
|
||||
tests = [
|
||||
{ id: '#static-2', top: 200, left: 200 },
|
||||
{ id: '#static-2', top: 100, left: 100 },
|
||||
{ id: '#static-2', top: -2, left: -2 },
|
||||
{ id: '#static-2', top: 121, left: 6 },
|
||||
{ id: '#static-1-1-1', top: 50, left: 50 },
|
||||
{ id: '#static-1-1-1', top: 10, left: 10 },
|
||||
{ id: '#static-1-1-1', top: -1, left: -1 },
|
||||
{ id: '#static-1-1-1', top: 22, left: 22 },
|
||||
{ id: '#static-1-1', top: 25, left: 25 },
|
||||
{ id: '#static-1-1', top: 10, left: 10 },
|
||||
{ id: '#static-1-1', top: -3, left: -3 },
|
||||
{ id: '#static-1-1', top: 14, left: 14 },
|
||||
{ id: '#static-1', top: 30, left: 30 },
|
||||
{ id: '#static-1', top: 2, left: 2 },
|
||||
{ id: '#static-1', top: -2, left: -2 },
|
||||
{ id: '#static-1', top: 7, left: 7 }
|
||||
{ id: "#static-2", top: 200, left: 200 },
|
||||
{ id: "#static-2", top: 100, left: 100 },
|
||||
{ id: "#static-2", top: -2, left: -2 },
|
||||
{ id: "#static-2", top: 121, left: 6 },
|
||||
{ id: "#static-1-1-1", top: 50, left: 50 },
|
||||
{ id: "#static-1-1-1", top: 10, left: 10 },
|
||||
{ id: "#static-1-1-1", top: -1, left: -1 },
|
||||
{ id: "#static-1-1-1", top: 22, left: 22 },
|
||||
{ id: "#static-1-1", top: 25, left: 25 },
|
||||
{ id: "#static-1-1", top: 10, left: 10 },
|
||||
{ id: "#static-1-1", top: -3, left: -3 },
|
||||
{ id: "#static-1-1", top: 14, left: 14 },
|
||||
{ id: "#static-1", top: 30, left: 30 },
|
||||
{ id: "#static-1", top: 2, left: 2 },
|
||||
{ id: "#static-1", top: -2, left: -2 },
|
||||
{ id: "#static-1", top: 7, left: 7 }
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
jQuery( this.id ).offset({ top: this.top, left: this.left });
|
||||
|
@ -270,8 +270,8 @@ testoffset("fixed", function( jQuery ) {
|
|||
jQuery.offset.initialize();
|
||||
|
||||
var tests = [
|
||||
{ id: '#fixed-1', top: 1001, left: 1001 },
|
||||
{ id: '#fixed-2', top: 1021, left: 1021 }
|
||||
{ id: "#fixed-1", top: 1001, left: 1001 },
|
||||
{ id: "#fixed-2", top: 1021, left: 1021 }
|
||||
];
|
||||
|
||||
jQuery.each( tests, function() {
|
||||
|
@ -284,18 +284,18 @@ testoffset("fixed", function( jQuery ) {
|
|||
equals( jQuery( this.id ).offset().left, this.left, "jQuery('" + this.id + "').offset().left" );
|
||||
} else {
|
||||
// need to have same number of assertions
|
||||
ok( true, 'Fixed position is not supported' );
|
||||
ok( true, 'Fixed position is not supported' );
|
||||
ok( true, "Fixed position is not supported" );
|
||||
ok( true, "Fixed position is not supported" );
|
||||
}
|
||||
});
|
||||
|
||||
tests = [
|
||||
{ id: '#fixed-1', top: 100, left: 100 },
|
||||
{ id: '#fixed-1', top: 0, left: 0 },
|
||||
{ id: '#fixed-1', top: -4, left: -4 },
|
||||
{ id: '#fixed-2', top: 200, left: 200 },
|
||||
{ id: '#fixed-2', top: 0, left: 0 },
|
||||
{ id: '#fixed-2', top: -5, left: -5 }
|
||||
{ id: "#fixed-1", top: 100, left: 100 },
|
||||
{ id: "#fixed-1", top: 0, left: 0 },
|
||||
{ id: "#fixed-1", top: -4, left: -4 },
|
||||
{ id: "#fixed-2", top: 200, left: 200 },
|
||||
{ id: "#fixed-2", top: 0, left: 0 },
|
||||
{ id: "#fixed-2", top: -5, left: -5 }
|
||||
];
|
||||
|
||||
jQuery.each( tests, function() {
|
||||
|
@ -314,58 +314,58 @@ testoffset("fixed", function( jQuery ) {
|
|||
equals( jQuery( this.id ).offset().left, this.left + 1, "jQuery('" + this.id + "').offset({ left: " + (this.left + 1) + ", using: fn })" );
|
||||
} else {
|
||||
// need to have same number of assertions
|
||||
ok( true, 'Fixed position is not supported' );
|
||||
ok( true, 'Fixed position is not supported' );
|
||||
ok( true, 'Fixed position is not supported' );
|
||||
ok( true, 'Fixed position is not supported' );
|
||||
ok( true, "Fixed position is not supported" );
|
||||
ok( true, "Fixed position is not supported" );
|
||||
ok( true, "Fixed position is not supported" );
|
||||
ok( true, "Fixed position is not supported" );
|
||||
}
|
||||
});
|
||||
|
||||
// Bug 8316
|
||||
var $noTopLeft = jQuery('#fixed-no-top-left');
|
||||
var $noTopLeft = jQuery("#fixed-no-top-left");
|
||||
if ( jQuery.offset.supportsFixedPosition ) {
|
||||
equals( $noTopLeft.offset().top, 1007, "Check offset top for fixed element with no top set" );
|
||||
equals( $noTopLeft.offset().left, 1007, "Check offset left for fixed element with no left set" );
|
||||
} else {
|
||||
// need to have same number of assertions
|
||||
ok( true, 'Fixed position is not supported' );
|
||||
ok( true, 'Fixed position is not supported' );
|
||||
ok( true, "Fixed position is not supported" );
|
||||
ok( true, "Fixed position is not supported" );
|
||||
}
|
||||
});
|
||||
|
||||
testoffset("table", function( jQuery ) {
|
||||
expect(4);
|
||||
|
||||
equals( jQuery('#table-1').offset().top, 6, "jQuery('#table-1').offset().top" );
|
||||
equals( jQuery('#table-1').offset().left, 6, "jQuery('#table-1').offset().left" );
|
||||
equals( jQuery("#table-1").offset().top, 6, "jQuery('#table-1').offset().top" );
|
||||
equals( jQuery("#table-1").offset().left, 6, "jQuery('#table-1').offset().left" );
|
||||
|
||||
equals( jQuery('#th-1').offset().top, 10, "jQuery('#th-1').offset().top" );
|
||||
equals( jQuery('#th-1').offset().left, 10, "jQuery('#th-1').offset().left" );
|
||||
equals( jQuery("#th-1").offset().top, 10, "jQuery('#th-1').offset().top" );
|
||||
equals( jQuery("#th-1").offset().left, 10, "jQuery('#th-1').offset().left" );
|
||||
});
|
||||
|
||||
testoffset("scroll", function( jQuery, win ) {
|
||||
expect(16);
|
||||
expect(22);
|
||||
|
||||
var ie = jQuery.browser.msie && parseInt( jQuery.browser.version, 10 ) < 8;
|
||||
|
||||
// IE is collapsing the top margin of 1px
|
||||
equals( jQuery('#scroll-1').offset().top, ie ? 6 : 7, "jQuery('#scroll-1').offset().top" );
|
||||
equals( jQuery('#scroll-1').offset().left, 7, "jQuery('#scroll-1').offset().left" );
|
||||
equals( jQuery("#scroll-1").offset().top, ie ? 6 : 7, "jQuery('#scroll-1').offset().top" );
|
||||
equals( jQuery("#scroll-1").offset().left, 7, "jQuery('#scroll-1').offset().left" );
|
||||
|
||||
// IE is collapsing the top margin of 1px
|
||||
equals( jQuery('#scroll-1-1').offset().top, ie ? 9 : 11, "jQuery('#scroll-1-1').offset().top" );
|
||||
equals( jQuery('#scroll-1-1').offset().left, 11, "jQuery('#scroll-1-1').offset().left" );
|
||||
equals( jQuery("#scroll-1-1").offset().top, ie ? 9 : 11, "jQuery('#scroll-1-1').offset().top" );
|
||||
equals( jQuery("#scroll-1-1").offset().left, 11, "jQuery('#scroll-1-1').offset().left" );
|
||||
|
||||
|
||||
// scroll offset tests .scrollTop/Left
|
||||
equals( jQuery('#scroll-1').scrollTop(), 5, "jQuery('#scroll-1').scrollTop()" );
|
||||
equals( jQuery('#scroll-1').scrollLeft(), 5, "jQuery('#scroll-1').scrollLeft()" );
|
||||
equals( jQuery("#scroll-1").scrollTop(), 5, "jQuery('#scroll-1').scrollTop()" );
|
||||
equals( jQuery("#scroll-1").scrollLeft(), 5, "jQuery('#scroll-1').scrollLeft()" );
|
||||
|
||||
equals( jQuery('#scroll-1-1').scrollTop(), 0, "jQuery('#scroll-1-1').scrollTop()" );
|
||||
equals( jQuery('#scroll-1-1').scrollLeft(), 0, "jQuery('#scroll-1-1').scrollLeft()" );
|
||||
equals( jQuery("#scroll-1-1").scrollTop(), 0, "jQuery('#scroll-1-1').scrollTop()" );
|
||||
equals( jQuery("#scroll-1-1").scrollLeft(), 0, "jQuery('#scroll-1-1').scrollLeft()" );
|
||||
|
||||
// equals( jQuery('body').scrollTop(), 0, "jQuery('body').scrollTop()" );
|
||||
// equals( jQuery('body').scrollLeft(), 0, "jQuery('body').scrollTop()" );
|
||||
// equals( jQuery("body").scrollTop(), 0, "jQuery("body").scrollTop()" );
|
||||
// equals( jQuery("body").scrollLeft(), 0, "jQuery("body").scrollTop()" );
|
||||
|
||||
win.name = "test";
|
||||
|
||||
|
@ -390,13 +390,21 @@ testoffset("scroll", function( jQuery, win ) {
|
|||
equals( jQuery(window).scrollLeft(), 0, "jQuery(window).scrollLeft() other window" );
|
||||
equals( jQuery(document).scrollTop(), 0, "jQuery(window).scrollTop() other document" );
|
||||
equals( jQuery(document).scrollLeft(), 0, "jQuery(window).scrollLeft() other document" );
|
||||
|
||||
// Tests scrollTop/Left with empty jquery objects
|
||||
notEqual( jQuery().scrollTop(100), null, "jQuery().scrollTop(100) testing setter on empty jquery object" );
|
||||
notEqual( jQuery().scrollLeft(100), null, "jQuery().scrollLeft(100) testing setter on empty jquery object" );
|
||||
notEqual( jQuery().scrollTop(null), null, "jQuery().scrollTop(null) testing setter on empty jquery object" );
|
||||
notEqual( jQuery().scrollLeft(null), null, "jQuery().scrollLeft(null) testing setter on empty jquery object" );
|
||||
strictEqual( jQuery().scrollTop(), null, "jQuery().scrollTop(100) testing setter on empty jquery object" );
|
||||
strictEqual( jQuery().scrollLeft(), null, "jQuery().scrollLeft(100) testing setter on empty jquery object" );
|
||||
});
|
||||
|
||||
testoffset("body", function( jQuery ) {
|
||||
expect(2);
|
||||
|
||||
equals( jQuery('body').offset().top, 1, "jQuery('#body').offset().top" );
|
||||
equals( jQuery('body').offset().left, 1, "jQuery('#body').offset().left" );
|
||||
equals( jQuery("body").offset().top, 1, "jQuery('#body').offset().top" );
|
||||
equals( jQuery("body").offset().left, 1, "jQuery('#body').offset().left" );
|
||||
});
|
||||
|
||||
test("Chaining offset(coords) returns jQuery object", function() {
|
||||
|
@ -433,7 +441,33 @@ test("offsetParent", function(){
|
|||
equals( div[1], jQuery("#nothiddendiv")[0], "The div is the offsetParent." );
|
||||
});
|
||||
|
||||
function testoffset( name, fn ) {
|
||||
test("fractions (see #7730 and #7885)", function() {
|
||||
expect(2);
|
||||
|
||||
jQuery('body').append('<div id="fractions"/>');
|
||||
|
||||
var expected = { top: 1000, left: 1000 };
|
||||
var div = jQuery('#fractions');
|
||||
|
||||
div.css({
|
||||
position: 'absolute',
|
||||
left: '1000.7432222px',
|
||||
top: '1000.532325px',
|
||||
width: 100,
|
||||
height: 100
|
||||
});
|
||||
|
||||
div.offset(expected);
|
||||
|
||||
var result = div.offset();
|
||||
|
||||
equals( result.top, expected.top, "Check top" );
|
||||
equals( result.left, expected.left, "Check left" );
|
||||
|
||||
div.remove();
|
||||
});
|
||||
|
||||
function testoffset(name, fn) {
|
||||
|
||||
test(name, function() {
|
||||
// pause execution for now
|
||||
|
@ -456,10 +490,10 @@ function testoffset( name, fn ) {
|
|||
});
|
||||
|
||||
function loadFixture() {
|
||||
var src = './data/offset/' + name + '.html?' + parseInt( Math.random()*1000, 10 ),
|
||||
iframe = jQuery('<iframe />').css({
|
||||
width: 500, height: 500, position: 'absolute', top: -600, left: -600, visibility: 'hidden'
|
||||
}).appendTo('body')[0];
|
||||
var src = "./data/offset/" + name + ".html?" + parseInt( Math.random()*1000, 10 ),
|
||||
iframe = jQuery("<iframe />").css({
|
||||
width: 500, height: 500, position: "absolute", top: -600, left: -600, visibility: "hidden"
|
||||
}).appendTo("body")[0];
|
||||
iframe.contentWindow.location = src;
|
||||
return iframe;
|
||||
}
|
||||
|
|
|
@ -1,38 +1,50 @@
|
|||
module("queue", { teardown: moduleTeardown });
|
||||
|
||||
test("queue() with other types",function() {
|
||||
expect(9);
|
||||
expect(11);
|
||||
var counter = 0;
|
||||
|
||||
var $div = jQuery({});
|
||||
stop();
|
||||
|
||||
var $div = jQuery({}),
|
||||
defer;
|
||||
|
||||
$div.promise("foo").done(function() {
|
||||
equals( counter, 0, "Deferred for collection with no queue is automatically resolved" );
|
||||
});
|
||||
|
||||
$div
|
||||
.queue('foo',function(){
|
||||
.queue("foo",function(){
|
||||
equals( ++counter, 1, "Dequeuing" );
|
||||
jQuery.dequeue(this,'foo');
|
||||
jQuery.dequeue(this,"foo");
|
||||
})
|
||||
.queue('foo',function(){
|
||||
.queue("foo",function(){
|
||||
equals( ++counter, 2, "Dequeuing" );
|
||||
jQuery(this).dequeue('foo');
|
||||
jQuery(this).dequeue("foo");
|
||||
})
|
||||
.queue('foo',function(){
|
||||
.queue("foo",function(){
|
||||
equals( ++counter, 3, "Dequeuing" );
|
||||
})
|
||||
.queue('foo',function(){
|
||||
.queue("foo",function(){
|
||||
equals( ++counter, 4, "Dequeuing" );
|
||||
});
|
||||
|
||||
equals( $div.queue('foo').length, 4, "Testing queue length" );
|
||||
defer = $div.promise("foo").done(function() {
|
||||
equals( counter, 4, "Testing previous call to dequeue in deferred" );
|
||||
start();
|
||||
});
|
||||
|
||||
$div.dequeue('foo');
|
||||
equals( $div.queue("foo").length, 4, "Testing queue length" );
|
||||
|
||||
$div.dequeue("foo");
|
||||
|
||||
equals( counter, 3, "Testing previous call to dequeue" );
|
||||
equals( $div.queue('foo').length, 1, "Testing queue length" );
|
||||
equals( $div.queue("foo").length, 1, "Testing queue length" );
|
||||
|
||||
$div.dequeue('foo');
|
||||
$div.dequeue("foo");
|
||||
|
||||
equals( counter, 4, "Testing previous call to dequeue" );
|
||||
equals( $div.queue('foo').length, 0, "Testing queue length" );
|
||||
equals( $div.queue("foo").length, 0, "Testing queue length" );
|
||||
});
|
||||
|
||||
test("queue(name) passes in the next item in the queue as a parameter", function() {
|
||||
|
@ -74,7 +86,7 @@ test("queue(name) passes in the next item in the queue as a parameter", function
|
|||
});
|
||||
|
||||
test("queue() passes in the next item in the queue as a parameter to fx queues", function() {
|
||||
expect(2);
|
||||
expect(3);
|
||||
stop();
|
||||
|
||||
var div = jQuery({});
|
||||
|
@ -87,11 +99,15 @@ test("queue() passes in the next item in the queue as a parameter to fx queues",
|
|||
}).queue(function(next) {
|
||||
equals(++counter, 2, "Next was called");
|
||||
next();
|
||||
start();
|
||||
}).queue("bar", function() {
|
||||
equals(++counter, 3, "Other queues are not triggered by next()")
|
||||
});
|
||||
|
||||
jQuery.when( div.promise("fx"), div ).done(function() {
|
||||
equals(counter, 2, "Deferreds resolved");
|
||||
start();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
test("delay()", function() {
|
||||
|
@ -110,7 +126,9 @@ test("delay()", function() {
|
|||
});
|
||||
|
||||
test("clearQueue(name) clears the queue", function() {
|
||||
expect(1);
|
||||
expect(2);
|
||||
|
||||
stop()
|
||||
|
||||
var div = jQuery({});
|
||||
var counter = 0;
|
||||
|
@ -123,6 +141,11 @@ test("clearQueue(name) clears the queue", function() {
|
|||
counter++;
|
||||
});
|
||||
|
||||
div.promise("foo").done(function() {
|
||||
ok( true, "dequeue resolves the deferred" );
|
||||
start();
|
||||
});
|
||||
|
||||
div.dequeue("foo");
|
||||
|
||||
equals(counter, 1, "the queue was cleared");
|
||||
|
@ -146,3 +169,81 @@ test("clearQueue() clears the fx queue", function() {
|
|||
|
||||
div.removeData();
|
||||
});
|
||||
|
||||
test("_mark() and _unmark()", function() {
|
||||
expect(1);
|
||||
|
||||
var div = {},
|
||||
$div = jQuery( div );
|
||||
|
||||
stop();
|
||||
|
||||
jQuery._mark( div, "foo" );
|
||||
jQuery._mark( div, "foo" );
|
||||
jQuery._unmark( div, "foo" );
|
||||
jQuery._unmark( div, "foo" );
|
||||
|
||||
$div.promise( "foo" ).done(function() {
|
||||
ok( true, "No more marks" );
|
||||
start();
|
||||
});
|
||||
});
|
||||
|
||||
test("_mark() and _unmark() default to 'fx'", function() {
|
||||
expect(1);
|
||||
|
||||
var div = {},
|
||||
$div = jQuery( div );
|
||||
|
||||
stop();
|
||||
|
||||
jQuery._mark( div );
|
||||
jQuery._mark( div );
|
||||
jQuery._unmark( div, "fx" );
|
||||
jQuery._unmark( div );
|
||||
|
||||
$div.promise().done(function() {
|
||||
ok( true, "No more marks" );
|
||||
start();
|
||||
});
|
||||
});
|
||||
|
||||
test("promise()", function() {
|
||||
expect(1);
|
||||
|
||||
stop();
|
||||
|
||||
var objects = [];
|
||||
|
||||
jQuery.each( [{}, {}], function( i, div ) {
|
||||
var $div = jQuery( div );
|
||||
$div.queue(function( next ) {
|
||||
setTimeout( function() {
|
||||
if ( i ) {
|
||||
next();
|
||||
setTimeout( function() {
|
||||
jQuery._unmark( div );
|
||||
}, 20 );
|
||||
} else {
|
||||
jQuery._unmark( div );
|
||||
setTimeout( function() {
|
||||
next();
|
||||
}, 20 );
|
||||
}
|
||||
}, 50 );
|
||||
}).queue(function( next ) {
|
||||
next();
|
||||
});
|
||||
jQuery._mark( div );
|
||||
objects.push( $div );
|
||||
});
|
||||
|
||||
jQuery.when.apply( jQuery, objects ).done(function() {
|
||||
ok( true, "Deferred resolved" );
|
||||
start();
|
||||
});
|
||||
|
||||
jQuery.each( objects, function() {
|
||||
this.dequeue();
|
||||
});
|
||||
});
|
|
@ -2,7 +2,7 @@ module("traversing", { teardown: moduleTeardown });
|
|||
|
||||
test("find(String)", function() {
|
||||
expect(5);
|
||||
equals( 'Yahoo', jQuery('#foo').find('.blogTest').text(), 'Check for find' );
|
||||
equals( "Yahoo", jQuery("#foo").find(".blogTest").text(), "Check for find" );
|
||||
|
||||
// using contents will get comments regular, text, and comment nodes
|
||||
var j = jQuery("#nonnodes").contents();
|
||||
|
@ -16,89 +16,86 @@ test("find(String)", function() {
|
|||
test("find(node|jQuery object)", function() {
|
||||
expect( 11 );
|
||||
|
||||
var $foo = jQuery('#foo'),
|
||||
$blog = jQuery('.blogTest'),
|
||||
$first = jQuery('#first'),
|
||||
var $foo = jQuery("#foo"),
|
||||
$blog = jQuery(".blogTest"),
|
||||
$first = jQuery("#first"),
|
||||
$two = $blog.add( $first ),
|
||||
$fooTwo = $foo.add( $blog );
|
||||
|
||||
equals( $foo.find( $blog ).text(), 'Yahoo', 'Find with blog jQuery object' );
|
||||
equals( $foo.find( $blog[0] ).text(), 'Yahoo', 'Find with blog node' );
|
||||
equals( $foo.find( $first ).length, 0, '#first is not in #foo' );
|
||||
equals( $foo.find( $first[0]).length, 0, '#first not in #foo (node)' );
|
||||
ok( $foo.find( $two ).is('.blogTest'), 'Find returns only nodes within #foo' );
|
||||
ok( $fooTwo.find( $blog ).is('.blogTest'), 'Blog is part of the collection, but also within foo' );
|
||||
ok( $fooTwo.find( $blog[0] ).is('.blogTest'), 'Blog is part of the collection, but also within foo(node)' );
|
||||
equals( $foo.find( $blog ).text(), "Yahoo", "Find with blog jQuery object" );
|
||||
equals( $foo.find( $blog[0] ).text(), "Yahoo", "Find with blog node" );
|
||||
equals( $foo.find( $first ).length, 0, "#first is not in #foo" );
|
||||
equals( $foo.find( $first[0]).length, 0, "#first not in #foo (node)" );
|
||||
ok( $foo.find( $two ).is(".blogTest"), "Find returns only nodes within #foo" );
|
||||
ok( $fooTwo.find( $blog ).is(".blogTest"), "Blog is part of the collection, but also within foo" );
|
||||
ok( $fooTwo.find( $blog[0] ).is(".blogTest"), "Blog is part of the collection, but also within foo(node)" );
|
||||
|
||||
equals( $two.find( $foo ).length, 0, 'Foo is not in two elements' );
|
||||
equals( $two.find( $foo[0] ).length, 0, 'Foo is not in two elements(node)' );
|
||||
equals( $two.find( $first ).length, 0, 'first is in the collection and not within two' );
|
||||
equals( $two.find( $first ).length, 0, 'first is in the collection and not within two(node)' );
|
||||
equals( $two.find( $foo ).length, 0, "Foo is not in two elements" );
|
||||
equals( $two.find( $foo[0] ).length, 0, "Foo is not in two elements(node)" );
|
||||
equals( $two.find( $first ).length, 0, "first is in the collection and not within two" );
|
||||
equals( $two.find( $first ).length, 0, "first is in the collection and not within two(node)" );
|
||||
|
||||
});
|
||||
|
||||
test("is(String|undefined)", function() {
|
||||
expect(27);
|
||||
ok( jQuery('#form').is('form'), 'Check for element: A form must be a form' );
|
||||
ok( !jQuery('#form').is('div'), 'Check for element: A form is not a div' );
|
||||
ok( jQuery('#mark').is('.blog'), 'Check for class: Expected class "blog"' );
|
||||
ok( !jQuery('#mark').is('.link'), 'Check for class: Did not expect class "link"' );
|
||||
ok( jQuery('#simon').is('.blog.link'), 'Check for multiple classes: Expected classes "blog" and "link"' );
|
||||
ok( !jQuery('#simon').is('.blogTest'), 'Check for multiple classes: Expected classes "blog" and "link", but not "blogTest"' );
|
||||
ok( jQuery('#en').is('[lang="en"]'), 'Check for attribute: Expected attribute lang to be "en"' );
|
||||
ok( !jQuery('#en').is('[lang="de"]'), 'Check for attribute: Expected attribute lang to be "en", not "de"' );
|
||||
ok( jQuery('#text1').is('[type="text"]'), 'Check for attribute: Expected attribute type to be "text"' );
|
||||
ok( !jQuery('#text1').is('[type="radio"]'), 'Check for attribute: Expected attribute type to be "text", not "radio"' );
|
||||
ok( jQuery('#text2').is(':disabled'), 'Check for pseudoclass: Expected to be disabled' );
|
||||
ok( !jQuery('#text1').is(':disabled'), 'Check for pseudoclass: Expected not disabled' );
|
||||
ok( jQuery('#radio2').is(':checked'), 'Check for pseudoclass: Expected to be checked' );
|
||||
ok( !jQuery('#radio1').is(':checked'), 'Check for pseudoclass: Expected not checked' );
|
||||
ok( jQuery('#foo').is(':has(p)'), 'Check for child: Expected a child "p" element' );
|
||||
ok( !jQuery('#foo').is(':has(ul)'), 'Check for child: Did not expect "ul" element' );
|
||||
ok( jQuery('#foo').is(':has(p):has(a):has(code)'), 'Check for childs: Expected "p", "a" and "code" child elements' );
|
||||
ok( !jQuery('#foo').is(':has(p):has(a):has(code):has(ol)'), 'Check for childs: Expected "p", "a" and "code" child elements, but no "ol"' );
|
||||
ok( jQuery("#form").is("form"), "Check for element: A form must be a form" );
|
||||
ok( !jQuery("#form").is("div"), "Check for element: A form is not a div" );
|
||||
ok( jQuery("#mark").is(".blog"), "Check for class: Expected class 'blog'" );
|
||||
ok( !jQuery("#mark").is(".link"), "Check for class: Did not expect class 'link'" );
|
||||
ok( jQuery("#simon").is(".blog.link"), "Check for multiple classes: Expected classes 'blog' and 'link'" );
|
||||
ok( !jQuery("#simon").is(".blogTest"), "Check for multiple classes: Expected classes 'blog' and 'link', but not 'blogTest'" );
|
||||
ok( jQuery("#en").is("[lang=\"en\"]"), "Check for attribute: Expected attribute lang to be 'en'" );
|
||||
ok( !jQuery("#en").is("[lang=\"de\"]"), "Check for attribute: Expected attribute lang to be 'en', not 'de'" );
|
||||
ok( jQuery("#text1").is("[type=\"text\"]"), "Check for attribute: Expected attribute type to be 'text'" );
|
||||
ok( !jQuery("#text1").is("[type=\"radio\"]"), "Check for attribute: Expected attribute type to be 'text', not 'radio'" );
|
||||
ok( jQuery("#text2").is(":disabled"), "Check for pseudoclass: Expected to be disabled" );
|
||||
ok( !jQuery("#text1").is(":disabled"), "Check for pseudoclass: Expected not disabled" );
|
||||
ok( jQuery("#radio2").is(":checked"), "Check for pseudoclass: Expected to be checked" );
|
||||
ok( !jQuery("#radio1").is(":checked"), "Check for pseudoclass: Expected not checked" );
|
||||
ok( jQuery("#foo").is(":has(p)"), "Check for child: Expected a child 'p' element" );
|
||||
ok( !jQuery("#foo").is(":has(ul)"), "Check for child: Did not expect 'ul' element" );
|
||||
ok( jQuery("#foo").is(":has(p):has(a):has(code)"), "Check for childs: Expected 'p', 'a' and 'code' child elements" );
|
||||
ok( !jQuery("#foo").is(":has(p):has(a):has(code):has(ol)"), "Check for childs: Expected 'p', 'a' and 'code' child elements, but no 'ol'" );
|
||||
|
||||
ok( !jQuery('#foo').is(0), 'Expected false for an invalid expression - 0' );
|
||||
ok( !jQuery('#foo').is(null), 'Expected false for an invalid expression - null' );
|
||||
ok( !jQuery('#foo').is(''), 'Expected false for an invalid expression - ""' );
|
||||
ok( !jQuery('#foo').is(undefined), 'Expected false for an invalid expression - undefined' );
|
||||
ok( !jQuery('#foo').is({ plain: "object" }), 'Check passing invalid object' );
|
||||
ok( !jQuery("#foo").is(0), "Expected false for an invalid expression - 0" );
|
||||
ok( !jQuery("#foo").is(null), "Expected false for an invalid expression - null" );
|
||||
ok( !jQuery("#foo").is(""), "Expected false for an invalid expression - \"\"" );
|
||||
ok( !jQuery("#foo").is(undefined), "Expected false for an invalid expression - undefined" );
|
||||
ok( !jQuery("#foo").is({ plain: "object" }), "Check passing invalid object" );
|
||||
|
||||
// test is() with comma-seperated expressions
|
||||
ok( jQuery('#en').is('[lang="en"],[lang="de"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' );
|
||||
ok( jQuery('#en').is('[lang="de"],[lang="en"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' );
|
||||
ok( jQuery('#en').is('[lang="en"] , [lang="de"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' );
|
||||
ok( jQuery('#en').is('[lang="de"] , [lang="en"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' );
|
||||
ok( jQuery("#en").is("[lang=\"en\"],[lang=\"de\"]"), "Comma-seperated; Check for lang attribute: Expect en or de" );
|
||||
ok( jQuery("#en").is("[lang=\"de\"],[lang=\"en\"]"), "Comma-seperated; Check for lang attribute: Expect en or de" );
|
||||
ok( jQuery("#en").is("[lang=\"en\"] , [lang=\"de\"]"), "Comma-seperated; Check for lang attribute: Expect en or de" );
|
||||
ok( jQuery("#en").is("[lang=\"de\"] , [lang=\"en\"]"), "Comma-seperated; Check for lang attribute: Expect en or de" );
|
||||
});
|
||||
|
||||
test("is(jQuery)", function() {
|
||||
expect(24);
|
||||
ok( jQuery('#form').is( jQuery('form') ), 'Check for element: A form is a form' );
|
||||
ok( !jQuery('#form').is( jQuery('div') ), 'Check for element: A form is not a div' );
|
||||
ok( jQuery('#mark').is( jQuery('.blog') ), 'Check for class: Expected class "blog"' );
|
||||
ok( !jQuery('#mark').is( jQuery('.link') ), 'Check for class: Did not expect class "link"' );
|
||||
ok( jQuery('#simon').is( jQuery('.blog.link') ), 'Check for multiple classes: Expected classes "blog" and "link"' );
|
||||
ok( !jQuery('#simon').is( jQuery('.blogTest') ), 'Check for multiple classes: Expected classes "blog" and "link", but not "blogTest"' );
|
||||
ok( jQuery('#en').is( jQuery('[lang="en"]') ), 'Check for attribute: Expected attribute lang to be "en"' );
|
||||
ok( !jQuery('#en').is( jQuery('[lang="de"]') ), 'Check for attribute: Expected attribute lang to be "en", not "de"' );
|
||||
ok( jQuery('#text1').is( jQuery('[type="text"]') ), 'Check for attribute: Expected attribute type to be "text"' );
|
||||
ok( !jQuery('#text1').is( jQuery('[type="radio"]') ), 'Check for attribute: Expected attribute type to be "text", not "radio"' );
|
||||
ok( jQuery('#text2').is( jQuery(':disabled') ), 'Check for pseudoclass: Expected to be disabled' );
|
||||
ok( !jQuery('#text1').is( jQuery(':disabled') ), 'Check for pseudoclass: Expected not disabled' );
|
||||
ok( jQuery('#radio2').is( jQuery(':checked') ), 'Check for pseudoclass: Expected to be checked' );
|
||||
ok( !jQuery('#radio1').is( jQuery(':checked') ), 'Check for pseudoclass: Expected not checked' );
|
||||
ok( jQuery('#foo').is( jQuery(':has(p)') ), 'Check for child: Expected a child "p" element' );
|
||||
ok( !jQuery('#foo').is( jQuery(':has(ul)') ), 'Check for child: Did not expect "ul" element' );
|
||||
ok( jQuery('#foo').is( jQuery(':has(p):has(a):has(code)') ), 'Check for childs: Expected "p", "a" and "code" child elements' );
|
||||
ok( !jQuery('#foo').is( jQuery(':has(p):has(a):has(code):has(ol)') ), 'Check for childs: Expected "p", "a" and "code" child elements, but no "ol"' );
|
||||
expect(21);
|
||||
ok( jQuery("#form").is( jQuery("form") ), "Check for element: A form is a form" );
|
||||
ok( !jQuery("#form").is( jQuery("div") ), "Check for element: A form is not a div" );
|
||||
ok( jQuery("#mark").is( jQuery(".blog") ), "Check for class: Expected class 'blog'" );
|
||||
ok( !jQuery("#mark").is( jQuery(".link") ), "Check for class: Did not expect class 'link'" );
|
||||
ok( jQuery("#simon").is( jQuery(".blog.link") ), "Check for multiple classes: Expected classes 'blog' and 'link'" );
|
||||
ok( !jQuery("#simon").is( jQuery(".blogTest") ), "Check for multiple classes: Expected classes 'blog' and 'link', but not 'blogTest'" );
|
||||
ok( jQuery("#en").is( jQuery("[lang=\"en\"]") ), "Check for attribute: Expected attribute lang to be 'en'" );
|
||||
ok( !jQuery("#en").is( jQuery("[lang=\"de\"]") ), "Check for attribute: Expected attribute lang to be 'en', not 'de'" );
|
||||
ok( jQuery("#text1").is( jQuery("[type=\"text\"]") ), "Check for attribute: Expected attribute type to be 'text'" );
|
||||
ok( !jQuery("#text1").is( jQuery("[type=\"radio\"]") ), "Check for attribute: Expected attribute type to be 'text', not 'radio'" );
|
||||
ok( !jQuery("#text1").is( jQuery("input:disabled") ), "Check for pseudoclass: Expected not disabled" );
|
||||
ok( jQuery("#radio2").is( jQuery("input:checked") ), "Check for pseudoclass: Expected to be checked" );
|
||||
ok( !jQuery("#radio1").is( jQuery("input:checked") ), "Check for pseudoclass: Expected not checked" );
|
||||
ok( jQuery("#foo").is( jQuery("div:has(p)") ), "Check for child: Expected a child 'p' element" );
|
||||
ok( !jQuery("#foo").is( jQuery("div:has(ul)") ), "Check for child: Did not expect 'ul' element" );
|
||||
|
||||
// Some raw elements
|
||||
ok( jQuery('#form').is( jQuery('form')[0] ), 'Check for element: A form is a form' );
|
||||
ok( !jQuery('#form').is( jQuery('div')[0] ), 'Check for element: A form is not a div' );
|
||||
ok( jQuery('#mark').is( jQuery('.blog')[0] ), 'Check for class: Expected class "blog"' );
|
||||
ok( !jQuery('#mark').is( jQuery('.link')[0] ), 'Check for class: Did not expect class "link"' );
|
||||
ok( jQuery('#simon').is( jQuery('.blog.link')[0] ), 'Check for multiple classes: Expected classes "blog" and "link"' );
|
||||
ok( !jQuery('#simon').is( jQuery('.blogTest')[0] ), 'Check for multiple classes: Expected classes "blog" and "link", but not "blogTest"' );
|
||||
ok( jQuery("#form").is( jQuery("form")[0] ), "Check for element: A form is a form" );
|
||||
ok( !jQuery("#form").is( jQuery("div")[0] ), "Check for element: A form is not a div" );
|
||||
ok( jQuery("#mark").is( jQuery(".blog")[0] ), "Check for class: Expected class 'blog'" );
|
||||
ok( !jQuery("#mark").is( jQuery(".link")[0] ), "Check for class: Did not expect class 'link'" );
|
||||
ok( jQuery("#simon").is( jQuery(".blog.link")[0] ), "Check for multiple classes: Expected classes 'blog' and 'link'" );
|
||||
ok( !jQuery("#simon").is( jQuery(".blogTest")[0] ), "Check for multiple classes: Expected classes 'blog' and 'link', but not 'blogTest'" );
|
||||
});
|
||||
|
||||
test("index()", function() {
|
||||
|
@ -111,15 +108,15 @@ test("index(Object|String|undefined)", function() {
|
|||
expect(16);
|
||||
|
||||
var elements = jQuery([window, document]),
|
||||
inputElements = jQuery('#radio1,#radio2,#check1,#check2');
|
||||
inputElements = jQuery("#radio1,#radio2,#check1,#check2");
|
||||
|
||||
// Passing a node
|
||||
equals( elements.index(window), 0, "Check for index of elements" );
|
||||
equals( elements.index(document), 1, "Check for index of elements" );
|
||||
equals( inputElements.index(document.getElementById('radio1')), 0, "Check for index of elements" );
|
||||
equals( inputElements.index(document.getElementById('radio2')), 1, "Check for index of elements" );
|
||||
equals( inputElements.index(document.getElementById('check1')), 2, "Check for index of elements" );
|
||||
equals( inputElements.index(document.getElementById('check2')), 3, "Check for index of elements" );
|
||||
equals( inputElements.index(document.getElementById("radio1")), 0, "Check for index of elements" );
|
||||
equals( inputElements.index(document.getElementById("radio2")), 1, "Check for index of elements" );
|
||||
equals( inputElements.index(document.getElementById("check1")), 2, "Check for index of elements" );
|
||||
equals( inputElements.index(document.getElementById("check2")), 3, "Check for index of elements" );
|
||||
equals( inputElements.index(window), -1, "Check for not found index" );
|
||||
equals( inputElements.index(document), -1, "Check for not found index" );
|
||||
|
||||
|
@ -131,11 +128,11 @@ test("index(Object|String|undefined)", function() {
|
|||
|
||||
// Passing a selector or nothing
|
||||
// enabled since [6330]
|
||||
equals( jQuery('#text2').index(), 2, "Check for index amongst siblings" );
|
||||
equals( jQuery('#form').children().eq(4).index(), 4, "Check for index amongst siblings" );
|
||||
equals( jQuery('#radio2').index('#form :radio') , 1, "Check for index within a selector" );
|
||||
equals( jQuery('#form :radio').index( jQuery('#radio2') ), 1, "Check for index within a selector" );
|
||||
equals( jQuery('#radio2').index('#form :text') , -1, "Check for index not found within a selector" );
|
||||
equals( jQuery("#text2").index(), 2, "Check for index amongst siblings" );
|
||||
equals( jQuery("#form").children().eq(4).index(), 4, "Check for index amongst siblings" );
|
||||
equals( jQuery("#radio2").index("#form :radio") , 1, "Check for index within a selector" );
|
||||
equals( jQuery("#form :radio").index( jQuery("#radio2") ), 1, "Check for index within a selector" );
|
||||
equals( jQuery("#radio2").index("#form :text") , -1, "Check for index not found within a selector" );
|
||||
});
|
||||
|
||||
test("filter(Selector|undefined)", function() {
|
||||
|
@ -144,10 +141,10 @@ test("filter(Selector|undefined)", function() {
|
|||
same( jQuery("p").filter("#ap, #sndp").get(), q("ap", "sndp"), "filter('String, String')" );
|
||||
same( jQuery("p").filter("#ap,#sndp").get(), q("ap", "sndp"), "filter('String,String')" );
|
||||
|
||||
same( jQuery('p').filter(null).get(), [], "filter(null) should return an empty jQuery object");
|
||||
same( jQuery('p').filter(undefined).get(), [], "filter(undefined) should return an empty jQuery object");
|
||||
same( jQuery('p').filter(0).get(), [], "filter(0) should return an empty jQuery object");
|
||||
same( jQuery('p').filter('').get(), [], "filter('') should return an empty jQuery object");
|
||||
same( jQuery("p").filter(null).get(), [], "filter(null) should return an empty jQuery object");
|
||||
same( jQuery("p").filter(undefined).get(), [], "filter(undefined) should return an empty jQuery object");
|
||||
same( jQuery("p").filter(0).get(), [], "filter(0) should return an empty jQuery object");
|
||||
same( jQuery("p").filter("").get(), [], "filter('') should return an empty jQuery object");
|
||||
|
||||
// using contents will get comments regular, text, and comment nodes
|
||||
var j = jQuery("#nonnodes").contents();
|
||||
|
@ -201,14 +198,14 @@ test("closest()", function() {
|
|||
same( jq.closest("#nothiddendiv", document.body).get(), q("nothiddendiv"), "Context not reached." );
|
||||
|
||||
//Test that .closest() returns unique'd set
|
||||
equals( jQuery('#main p').closest('#main').length, 1, "Closest should return a unique set" );
|
||||
equals( jQuery("#main p").closest("#main").length, 1, "Closest should return a unique set" );
|
||||
|
||||
// Test on disconnected node
|
||||
equals( jQuery("<div><p></p></div>").find("p").closest("table").length, 0, "Make sure disconnected closest work." );
|
||||
|
||||
// Bug #7369
|
||||
equals( jQuery('<div foo="bar"></div>').closest('[foo]').length, 1, "Disconnected nodes with attribute selector" );
|
||||
equals( jQuery('<div>text</div>').closest('[lang]').length, 0, "Disconnected nodes with text and non-existent attribute selector" );
|
||||
equals( jQuery("<div foo='bar'></div>").closest("[foo]").length, 1, "Disconnected nodes with attribute selector" );
|
||||
equals( jQuery("<div>text</div>").closest("[lang]").length, 0, "Disconnected nodes with text and non-existent attribute selector" );
|
||||
});
|
||||
|
||||
test("closest(Array)", function() {
|
||||
|
@ -223,43 +220,38 @@ test("closest(Array)", function() {
|
|||
same( jQuery("body").closest(["span","html"]), [{selector:"html", elem:document.documentElement, level:2}], "closest([body, html])" );
|
||||
});
|
||||
|
||||
<<<<<<< HEAD
|
||||
test("not(Selector|undefined)", function() {
|
||||
expect(11);
|
||||
=======
|
||||
test("closest(jQuery)", function() {
|
||||
expect(8);
|
||||
var $child = jQuery("#nothiddendivchild"),
|
||||
$parent = jQuery("#nothiddendiv"),
|
||||
$main = jQuery("#main"),
|
||||
$body = jQuery("body");
|
||||
ok( $child.closest( $parent ).is('#nothiddendiv'), "closest( jQuery('#nothiddendiv') )" );
|
||||
ok( $child.closest( $parent[0] ).is('#nothiddendiv'), "closest( jQuery('#nothiddendiv') ) :: node" );
|
||||
ok( $child.closest( $child ).is('#nothiddendivchild'), "child is included" );
|
||||
ok( $child.closest( $child[0] ).is('#nothiddendivchild'), "child is included :: node" );
|
||||
equals( $child.closest( document.createElement('div') ).length, 0, "created element is not related" );
|
||||
ok( $child.closest( $parent ).is("#nothiddendiv"), "closest( jQuery('#nothiddendiv') )" );
|
||||
ok( $child.closest( $parent[0] ).is("#nothiddendiv"), "closest( jQuery('#nothiddendiv') ) :: node" );
|
||||
ok( $child.closest( $child ).is("#nothiddendivchild"), "child is included" );
|
||||
ok( $child.closest( $child[0] ).is("#nothiddendivchild"), "child is included :: node" );
|
||||
equals( $child.closest( document.createElement("div") ).length, 0, "created element is not related" );
|
||||
equals( $child.closest( $main ).length, 0, "Main not a parent of child" );
|
||||
equals( $child.closest( $main[0] ).length, 0, "Main not a parent of child :: node" );
|
||||
ok( $child.closest( $body.add($parent) ).is('#nothiddendiv'), "Closest ancestor retrieved." );
|
||||
ok( $child.closest( $body.add($parent) ).is("#nothiddendiv"), "Closest ancestor retrieved." );
|
||||
});
|
||||
|
||||
test("not(Selector)", function() {
|
||||
expect(7);
|
||||
>>>>>>> 1a167767305202797cf4c839eb64bd7adfb00182
|
||||
test("not(Selector|undefined)", function() {
|
||||
expect(11);
|
||||
equals( jQuery("#main > p#ap > a").not("#google").length, 2, "not('selector')" );
|
||||
same( jQuery("p").not(".result").get(), q("firstp", "ap", "sndp", "en", "sap", "first"), "not('.class')" );
|
||||
same( jQuery("p").not("#ap, #sndp, .result").get(), q("firstp", "en", "sap", "first"), "not('selector, selector')" );
|
||||
same( jQuery("#form option").not("option.emptyopt:contains('Nothing'),[selected],[value='1']").get(), q("option1c", "option1d", "option2c", "option3d", "option3e", "option4e","option5b"), "not('complex selector')");
|
||||
|
||||
same( jQuery('#ap *').not('code').get(), q("google", "groups", "anchor1", "mark"), "not('tag selector')" );
|
||||
same( jQuery('#ap *').not('code, #mark').get(), q("google", "groups", "anchor1"), "not('tag, ID selector')" );
|
||||
same( jQuery('#ap *').not('#mark, code').get(), q("google", "groups", "anchor1"), "not('ID, tag selector')");
|
||||
|
||||
var all = jQuery('p').get();
|
||||
same( jQuery('p').not(null).get(), all, "not(null) should have no effect");
|
||||
same( jQuery('p').not(undefined).get(), all, "not(undefined) should have no effect");
|
||||
same( jQuery('p').not(0).get(), all, "not(0) should have no effect");
|
||||
same( jQuery('p').not('').get(), all, "not('') should have no effect");
|
||||
same( jQuery("#ap *").not("code").get(), q("google", "groups", "anchor1", "mark"), "not('tag selector')" );
|
||||
same( jQuery("#ap *").not("code, #mark").get(), q("google", "groups", "anchor1"), "not('tag, ID selector')" );
|
||||
same( jQuery("#ap *").not("#mark, code").get(), q("google", "groups", "anchor1"), "not('ID, tag selector')");
|
||||
|
||||
var all = jQuery("p").get();
|
||||
same( jQuery("p").not(null).get(), all, "not(null) should have no effect");
|
||||
same( jQuery("p").not(undefined).get(), all, "not(undefined) should have no effect");
|
||||
same( jQuery("p").not(0).get(), all, "not(0) should have no effect");
|
||||
same( jQuery("p").not("").get(), all, "not('') should have no effect");
|
||||
});
|
||||
|
||||
test("not(Element)", function() {
|
||||
|
@ -372,7 +364,7 @@ test("parentsUntil([String])", function() {
|
|||
|
||||
same( jQuery("#groups").parentsUntil().get(), parents.get(), "parentsUntil with no selector (nextAll)" );
|
||||
same( jQuery("#groups").parentsUntil(".foo").get(), parents.get(), "parentsUntil with invalid selector (nextAll)" );
|
||||
same( jQuery("#groups").parentsUntil("#html").get(), parents.not(':last').get(), "Simple parentsUntil check" );
|
||||
same( jQuery("#groups").parentsUntil("#html").get(), parents.not(":last").get(), "Simple parentsUntil check" );
|
||||
equals( jQuery("#groups").parentsUntil("#ap").length, 0, "Simple parentsUntil check" );
|
||||
same( jQuery("#groups").parentsUntil("#html, #body").get(), parents.slice( 0, 3 ).get(), "Less simple parentsUntil check" );
|
||||
same( jQuery("#groups").parentsUntil("#html", "div").get(), jQuery("#main").get(), "Filtered parentsUntil check" );
|
||||
|
@ -400,29 +392,29 @@ test("prev([String])", function() {
|
|||
test("nextAll([String])", function() {
|
||||
expect(4);
|
||||
|
||||
var elems = jQuery('#form').children();
|
||||
var elems = jQuery("#form").children();
|
||||
|
||||
same( jQuery("#label-for").nextAll().get(), elems.not(':first').get(), "Simple nextAll check" );
|
||||
same( jQuery("#label-for").nextAll('input').get(), elems.not(':first').filter('input').get(), "Filtered nextAll check" );
|
||||
same( jQuery("#label-for").nextAll('input,select').get(), elems.not(':first').filter('input,select').get(), "Multiple-filtered nextAll check" );
|
||||
same( jQuery("#label-for, #hidden1").nextAll('input,select').get(), elems.not(':first').filter('input,select').get(), "Multi-source, multiple-filtered nextAll check" );
|
||||
same( jQuery("#label-for").nextAll().get(), elems.not(":first").get(), "Simple nextAll check" );
|
||||
same( jQuery("#label-for").nextAll("input").get(), elems.not(":first").filter("input").get(), "Filtered nextAll check" );
|
||||
same( jQuery("#label-for").nextAll("input,select").get(), elems.not(":first").filter("input,select").get(), "Multiple-filtered nextAll check" );
|
||||
same( jQuery("#label-for, #hidden1").nextAll("input,select").get(), elems.not(":first").filter("input,select").get(), "Multi-source, multiple-filtered nextAll check" );
|
||||
});
|
||||
|
||||
test("prevAll([String])", function() {
|
||||
expect(4);
|
||||
|
||||
var elems = jQuery( jQuery('#form').children().slice(0, 12).get().reverse() );
|
||||
var elems = jQuery( jQuery("#form").children().slice(0, 12).get().reverse() );
|
||||
|
||||
same( jQuery("#area1").prevAll().get(), elems.get(), "Simple prevAll check" );
|
||||
same( jQuery("#area1").prevAll('input').get(), elems.filter('input').get(), "Filtered prevAll check" );
|
||||
same( jQuery("#area1").prevAll('input,select').get(), elems.filter('input,select').get(), "Multiple-filtered prevAll check" );
|
||||
same( jQuery("#area1, #hidden1").prevAll('input,select').get(), elems.filter('input,select').get(), "Multi-source, multiple-filtered prevAll check" );
|
||||
same( jQuery("#area1").prevAll("input").get(), elems.filter("input").get(), "Filtered prevAll check" );
|
||||
same( jQuery("#area1").prevAll("input,select").get(), elems.filter("input,select").get(), "Multiple-filtered prevAll check" );
|
||||
same( jQuery("#area1, #hidden1").prevAll("input,select").get(), elems.filter("input,select").get(), "Multi-source, multiple-filtered prevAll check" );
|
||||
});
|
||||
|
||||
test("nextUntil([String])", function() {
|
||||
expect(11);
|
||||
|
||||
var elems = jQuery('#form').children().slice( 2, 12 );
|
||||
var elems = jQuery("#form").children().slice( 2, 12 );
|
||||
|
||||
same( jQuery("#text1").nextUntil().get(), jQuery("#text1").nextAll().get(), "nextUntil with no selector (nextAll)" );
|
||||
same( jQuery("#text1").nextUntil(".foo").get(), jQuery("#text1").nextAll().get(), "nextUntil with invalid selector (nextAll)" );
|
||||
|
@ -445,14 +437,14 @@ test("prevUntil([String])", function() {
|
|||
|
||||
same( jQuery("#area1").prevUntil().get(), elems.get(), "prevUntil with no selector (prevAll)" );
|
||||
same( jQuery("#area1").prevUntil(".foo").get(), elems.get(), "prevUntil with invalid selector (prevAll)" );
|
||||
same( jQuery("#area1").prevUntil("label").get(), elems.not(':last').get(), "Simple prevUntil check" );
|
||||
same( jQuery("#area1").prevUntil("label").get(), elems.not(":last").get(), "Simple prevUntil check" );
|
||||
equals( jQuery("#area1").prevUntil("#button").length, 0, "Simple prevUntil check" );
|
||||
same( jQuery("#area1").prevUntil("label, #search").get(), jQuery("#area1").prev().get(), "Less simple prevUntil check" );
|
||||
same( jQuery("#area1").prevUntil("label", "input").get(), elems.not(':last').not("button").get(), "Filtered prevUntil check" );
|
||||
same( jQuery("#area1").prevUntil("label", "button").get(), elems.not(':last').not("input").get(), "Filtered prevUntil check" );
|
||||
same( jQuery("#area1").prevUntil("label", "button,input").get(), elems.not(':last').get(), "Multiple-filtered prevUntil check" );
|
||||
same( jQuery("#area1").prevUntil("label", "input").get(), elems.not(":last").not("button").get(), "Filtered prevUntil check" );
|
||||
same( jQuery("#area1").prevUntil("label", "button").get(), elems.not(":last").not("input").get(), "Filtered prevUntil check" );
|
||||
same( jQuery("#area1").prevUntil("label", "button,input").get(), elems.not(":last").get(), "Multiple-filtered prevUntil check" );
|
||||
equals( jQuery("#area1").prevUntil("label", "div").length, 0, "Filtered prevUntil check, no match" );
|
||||
same( jQuery("#area1, #hidden1").prevUntil("label", "button,input").get(), elems.not(':last').get(), "Multi-source, multiple-filtered prevUntil check" );
|
||||
same( jQuery("#area1, #hidden1").prevUntil("label", "button,input").get(), elems.not(":last").get(), "Multi-source, multiple-filtered prevUntil check" );
|
||||
});
|
||||
|
||||
test("contents()", function() {
|
||||
|
@ -527,7 +519,7 @@ test("add(String|Element|Array|undefined)", function() {
|
|||
var notDefined;
|
||||
equals( jQuery([]).add(notDefined).length, 0, "Check that undefined adds nothing" );
|
||||
|
||||
ok( jQuery([]).add( document.getElementById('form') ).length >= 13, "Add a form (adds the elements)" );
|
||||
ok( jQuery([]).add( document.getElementById("form") ).length >= 13, "Add a form (adds the elements)" );
|
||||
});
|
||||
|
||||
test("add(String, Context)", function() {
|
||||
|
|
Loading…
Reference in a new issue