*/
wrap: function() {
// The elements to wrap the target around
- var a = jQuery.clean(arguments);
+ var a, args = arguments;
// Wrap each of the matched elements individually
return this.each(function(){
+ if ( !a )
+ a = jQuery.clean(args, this.ownerDocument);
+
// Clone the structure that we're using to wrap
var b = a[0].cloneNode(true);
* @cat DOM/Traversing
*/
find: function(t) {
- return this.pushStack( jQuery.map( this, function(a){
+ return this.pushStack( jQuery.unique( jQuery.map( this, function(a){
return jQuery.find(t,a);
- }), t );
+ }) ), t );
},
/**
* @cat DOM/Traversing
*/
is: function(expr) {
- return expr ? jQuery.filter(expr,this).r.length > 0 : false;
+ return expr ? jQuery.multiFilter(expr,this).length > 0 : false;
},
/**
* @cat Core
*/
domManip: function(args, table, dir, fn){
- var clone = this.length > 1;
- var a = jQuery.clean(args);
- if ( dir < 0 )
- a.reverse();
+ var clone = this.length > 1, a;
return this.each(function(){
+ if ( !a ) {
+ a = jQuery.clean(args, this.ownerDocument);
+ if ( dir < 0 )
+ a.reverse();
+ }
+
var obj = this;
if ( table && jQuery.nodeName(this, "table") && jQuery.nodeName(a[0], "tr") )
// internal only, use is(".class")
has: function( t, c ) {
- t = t.className || t;
- // escape regex characters
- c = c.replace(/([\.\\\+\*\?\[\^\]\$\(\)\{\}\=\!\<\>\|\:])/g, "\\$1");
- return t && new RegExp("(^|\\s)" + c + "(\\s|$)").test( t );
+ return jQuery.inArray( c, (t.className || t).toString().split(/\s+/) ) > -1;
}
},
});
jQuery.swap( e, old, function() {
- if (jQuery.css(e,"display") != "none") {
+ if ( jQuery(e).is(':visible') ) {
oHeight = e.offsetHeight;
oWidth = e.offsetWidth;
} else {
visibility: "hidden", position: "absolute", display: "block", right: "0", left: "0"
}).appendTo(e.parentNode)[0];
- var parPos = jQuery.css(e.parentNode,"position");
- if ( parPos == "" || parPos == "static" )
+ var parPos = jQuery.css(e.parentNode,"position") || "static";
+ if ( parPos == "static" )
e.parentNode.style.position = "relative";
oHeight = e.clientHeight;
oWidth = e.clientWidth;
- if ( parPos == "" || parPos == "static" )
+ if ( parPos == "static" )
e.parentNode.style.position = "static";
e.parentNode.removeChild(e);
curCSS: function(elem, prop, force) {
var ret;
- if (prop == "opacity" && jQuery.browser.msie)
- return jQuery.attr(elem.style, "opacity");
+ if (prop == "opacity" && jQuery.browser.msie) {
+ ret = jQuery.attr(elem.style, "opacity");
+ return ret == "" ? "1" : ret;
+ }
if (prop == "float" || prop == "cssFloat")
prop = jQuery.browser.msie ? "styleFloat" : "cssFloat";
return ret;
},
- clean: function(a) {
+ clean: function(a, doc) {
var r = [];
+ doc = doc || document;
jQuery.each( a, function(i,arg){
if ( !arg ) return;
// Convert html string into DOM nodes
if ( typeof arg == "string" ) {
// Trim whitespace, otherwise indexOf won't work as expected
- var s = jQuery.trim(arg), div = document.createElement("div"), tb = [];
+ var s = jQuery.trim(arg), div = doc.createElement("div"), tb = [];
var wrap =
// option or optgroup
}
return elem.filter ?
- (parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100).toString() : "1";
+ (parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100).toString() : "";
}
// Certain attributes only work when accessed via the old DOM 0 way
* @cat JavaScript
*/
merge: function(first, second) {
- var r = [].slice.call( first, 0 );
+ // We have to loop this way because IE & Opera overwrite the length
+ // expando of getElementsByTagName
+ for ( var i = 0; second[i]; i++ )
+ first.push(second[i]);
+ return first;
+ },
- // Now check for duplicates between the two arrays
- // and only add the unique items
- for ( var i = 0, sl = second.length; i < sl; i++ )
- // Check for duplicates
- if ( jQuery.inArray( second[i], r ) == -1 )
- // The item is unique, add it
- first.push( second[i] );
+ unique: function(first) {
+ var r = [], num = jQuery.mergeNum++;
- return first;
+ for ( var i = 0, fl = first.length; i < fl; i++ )
+ if ( first[i].mergeNum != num ) {
+ first[i].mergeNum = num;
+ r.push(first[i]);
+ }
+
+ return r;
},
+ mergeNum: 0,
+
/**
* Filter items out of an array, by using a filter function.
*
}
}
- var r = result.length ? [ result[0] ] : [];
-
- check: for ( var i = 1, rl = result.length; i < rl; i++ ) {
- for ( var j = 0; j < i; j++ )
- if ( result[i] == r[j] )
- continue check;
-
- r.push( result[i] );
- }
-
- return r;
+ return result;
}
});