Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
No ticket: Clean up code and comments
  • Loading branch information
gibson042 committed Sep 12, 2013
1 parent 1b7c56d commit 2921b4f
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 61 deletions.
58 changes: 28 additions & 30 deletions dist/sizzle.js
Expand Up @@ -6,19 +6,19 @@
* Released under the MIT license
* http://jquery.org/license
*
* Date: 2013-09-11
* Date: 2013-09-12
*/
(function( window ) {

var i,
support,
cachedruns,
Expr,
getText,
isXML,
compile,
outermostContext,
sortInput,
hasDuplicate,

// Local document vars
setDocument,
Expand All @@ -38,11 +38,9 @@ var i,
classCache = createCache(),
tokenCache = createCache(),
compilerCache = createCache(),
hasDuplicate = false,
sortOrder = function( a, b ) {
if ( a === b ) {
hasDuplicate = true;
return 0;
}
return 0;
},
Expand All @@ -51,8 +49,11 @@ var i,
strundefined = typeof undefined,
MAX_NEGATIVE = 1 << 31,

// Expose support vars for convenience
support = Sizzle.support = {},

// Instance methods
hasOwn = ({}).hasOwnProperty,
hasOwn = support.hasOwnProperty,
arr = [],
pop = arr.pop,
push_native = arr.push,
Expand Down Expand Up @@ -102,7 +103,6 @@ var i,
rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),

rsibling = new RegExp( whitespace + "*[+~]" ),
rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*)" + whitespace + "*\\]", "g" ),

rpseudo = new RegExp( pseudos ),
Expand All @@ -124,14 +124,15 @@ var i,
whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
},

rinputs = /^(?:input|select|textarea|button)$/i,
rheader = /^h\d$/i,

rnative = /^[^{]+\{\s*\[native \w/,

// Easily-parseable/retrievable ID or TAG or CLASS selectors
rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,

rinputs = /^(?:input|select|textarea|button)$/i,
rheader = /^h\d$/i,

rsibling = /[+~]/,
rescape = /'|\\/g,

// CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
Expand All @@ -143,8 +144,8 @@ var i,
// Workaround erroneous numeric interpretation of +"0x"
return high !== high || escapedWhitespace ?
escaped :
// BMP codepoint
high < 0 ?
// BMP codepoint
String.fromCharCode( high + 0x10000 ) :
// Supplemental Plane codepoint (surrogate pair)
String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
Expand Down Expand Up @@ -208,7 +209,7 @@ function Sizzle( selector, context, results, seed ) {
if ( nodeType === 9 ) {
elem = context.getElementById( m );
// Check parentNode to catch when Blackberry 4.6 returns
// nodes that are no longer in the document #6963
// nodes that are no longer in the document (jQuery #6963)
if ( elem && elem.parentNode ) {
// Handle the case where IE, Opera, and Webkit return items
// by name instead of ID
Expand Down Expand Up @@ -299,11 +300,11 @@ function createCache() {

function cache( key, value ) {
// Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
if ( keys.push( key += " " ) > Expr.cacheLength ) {
if ( keys.push( key + " " ) > Expr.cacheLength ) {
// Only keep the most recent entries
delete cache[ keys.shift() ];
}
return (cache[ key ] = value);
return (cache[ key + " " ] = value);
}
return cache;
}
Expand Down Expand Up @@ -446,9 +447,6 @@ isXML = Sizzle.isXML = function( elem ) {
return documentElement ? documentElement.nodeName !== "HTML" : false;
};

// Expose support vars for convenience
support = Sizzle.support = {};

/**
* Sets document-related variables once based on the current document
* @param {Element|Object} [doc] An element or document object to use to set the document
Expand Down Expand Up @@ -846,13 +844,13 @@ Sizzle.attr = function( elem, name ) {
fn( elem, name, !documentIsHTML ) :
undefined;

return val === undefined ?
return val !== undefined ?
val :
support.attributes || !documentIsHTML ?
elem.getAttribute( name ) :
(val = elem.getAttributeNode(name)) && val.specified ?
val.value :
null :
val;
null;
};

Sizzle.error = function( msg ) {
Expand Down Expand Up @@ -900,13 +898,13 @@ getText = Sizzle.getText = function( elem ) {

if ( !nodeType ) {
// If no nodeType, this is expected to be an array
for ( ; (node = elem[i]); i++ ) {
while ( (node = elem[i++]) ) {
// Do not traverse comment nodes
ret += getText( node );
}
} else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
// Use textContent for elements
// innerText usage removed for consistency of new lines (see #11153)
// innerText usage removed for consistency of new lines (jQuery #11153)
if ( typeof elem.textContent === "string" ) {
return elem.textContent;
} else {
Expand Down Expand Up @@ -1303,12 +1301,11 @@ Expr = Sizzle.selectors = {
// Contents
"empty": function( elem ) {
// http://www.w3.org/TR/selectors/#empty-pseudo
// :empty is only affected by element nodes and content nodes(including text(3), cdata(4)),
// not comment, processing instructions, or others
// Thanks to Diego Perini for the nodeName shortcut
// Greater than "@" means alpha characters (specifically not starting with "#" or "?")
// :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
// but not by others (comment: 8; processing instruction: 7; etc.)
// nodeType < 6 works because attributes (2) do not appear as children
for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
if ( elem.nodeName > "@" || elem.nodeType === 3 || elem.nodeType === 4 ) {
if ( elem.nodeType < 6 ) {
return false;
}
}
Expand All @@ -1335,10 +1332,11 @@ Expr = Sizzle.selectors = {

"text": function( elem ) {
var attr;
// IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
// use getAttribute instead to test this case
return elem.nodeName.toLowerCase() === "input" &&
elem.type === "text" &&

// Support: IE<8
// New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === elem.type );
},

Expand Down Expand Up @@ -1425,7 +1423,7 @@ function tokenize( selector, parseOnly ) {
// Don't consume trailing commas as valid
soFar = soFar.slice( match[0].length ) || soFar;
}
groups.push( tokens = [] );
groups.push( (tokens = []) );
}

matched = false;
Expand Down Expand Up @@ -1924,7 +1922,7 @@ support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;

// Support: Chrome<14
// Always assume duplicates if they aren't passed to the comparison function
support.detectDuplicates = hasDuplicate;
support.detectDuplicates = !!hasDuplicate;

// Initialize against the default document
setDocument();
Expand Down

0 comments on commit 2921b4f

Please sign in to comment.