) matching elements by id
- for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
+ for ( ; i !== len && ( elem = elems[ i ] ) != null; i++ ) {
if ( byElement && elem ) {
j = 0;
if ( !context && elem.ownerDocument !== document ) {
setDocument( elem );
xml = !documentIsHTML;
}
- while ( (matcher = elementMatchers[j++]) ) {
- if ( matcher( elem, context || document, xml) ) {
+ while ( ( matcher = elementMatchers[ j++ ] ) ) {
+ if ( matcher( elem, context || document, xml ) ) {
results.push( elem );
break;
}
@@ -2018,8 +2118,9 @@ function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
// Track unmatched elements for set filters
if ( bySet ) {
+
// They will have gone through all possible matchers
- if ( (elem = !matcher && elem) ) {
+ if ( ( elem = !matcher && elem ) ) {
matchedCount--;
}
@@ -2043,16 +2144,17 @@ function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
// numerically zero.
if ( bySet && i !== matchedCount ) {
j = 0;
- while ( (matcher = setMatchers[j++]) ) {
+ while ( ( matcher = setMatchers[ j++ ] ) ) {
matcher( unmatched, setMatched, context, xml );
}
if ( seed ) {
+
// Reintegrate element matches to eliminate the need for sorting
if ( matchedCount > 0 ) {
while ( i-- ) {
- if ( !(unmatched[i] || setMatched[i]) ) {
- setMatched[i] = pop.call( results );
+ if ( !( unmatched[ i ] || setMatched[ i ] ) ) {
+ setMatched[ i ] = pop.call( results );
}
}
}
@@ -2093,13 +2195,14 @@ compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
cached = compilerCache[ selector + " " ];
if ( !cached ) {
+
// Generate a function of recursive functions that can be used to check each element
if ( !match ) {
match = tokenize( selector );
}
i = match.length;
while ( i-- ) {
- cached = matcherFromTokens( match[i] );
+ cached = matcherFromTokens( match[ i ] );
if ( cached[ expando ] ) {
setMatchers.push( cached );
} else {
@@ -2108,7 +2211,10 @@ compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
}
// Cache the compiled function
- cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
+ cached = compilerCache(
+ selector,
+ matcherFromGroupMatchers( elementMatchers, setMatchers )
+ );
// Save selector and tokenization
cached.selector = selector;
@@ -2128,7 +2234,7 @@ compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
select = Sizzle.select = function( selector, context, results, seed ) {
var i, tokens, token, type, find,
compiled = typeof selector === "function" && selector,
- match = !seed && tokenize( (selector = compiled.selector || selector) );
+ match = !seed && tokenize( ( selector = compiled.selector || selector ) );
results = results || [];
@@ -2137,11 +2243,12 @@ select = Sizzle.select = function( selector, context, results, seed ) {
if ( match.length === 1 ) {
// Reduce context if the leading compound selector is an ID
- tokens = match[0] = match[0].slice( 0 );
- if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
- context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[1].type ] ) {
+ tokens = match[ 0 ] = match[ 0 ].slice( 0 );
+ if ( tokens.length > 2 && ( token = tokens[ 0 ] ).type === "ID" &&
+ context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[ 1 ].type ] ) {
- context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
+ context = ( Expr.find[ "ID" ]( token.matches[ 0 ]
+ .replace( runescape, funescape ), context ) || [] )[ 0 ];
if ( !context ) {
return results;
@@ -2154,20 +2261,22 @@ select = Sizzle.select = function( selector, context, results, seed ) {
}
// Fetch a seed set for right-to-left matching
- i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
+ i = matchExpr[ "needsContext" ].test( selector ) ? 0 : tokens.length;
while ( i-- ) {
- token = tokens[i];
+ token = tokens[ i ];
// Abort if we hit a combinator
- if ( Expr.relative[ (type = token.type) ] ) {
+ if ( Expr.relative[ ( type = token.type ) ] ) {
break;
}
- if ( (find = Expr.find[ type ]) ) {
+ if ( ( find = Expr.find[ type ] ) ) {
+
// Search, expanding context for leading sibling combinators
- if ( (seed = find(
- token.matches[0].replace( runescape, funescape ),
- rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
- )) ) {
+ if ( ( seed = find(
+ token.matches[ 0 ].replace( runescape, funescape ),
+ rsibling.test( tokens[ 0 ].type ) && testContext( context.parentNode ) ||
+ context
+ ) ) ) {
// If seed is empty or no tokens remain, we can return early
tokens.splice( i, 1 );
@@ -2198,7 +2307,7 @@ select = Sizzle.select = function( selector, context, results, seed ) {
// One-time assignments
// Sort stability
-support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
+support.sortStable = expando.split( "" ).sort( sortOrder ).join( "" ) === expando;
// Support: Chrome 14-35+
// Always assume duplicates if they aren't passed to the comparison function
@@ -2209,53 +2318,54 @@ setDocument();
// Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
// Detached nodes confoundingly follow *each other*
-support.sortDetached = assert(function( el ) {
+support.sortDetached = assert( function( el ) {
+
// Should return 1, but returns 4 (following)
- return el.compareDocumentPosition( document.createElement("fieldset") ) & 1;
-});
+ return el.compareDocumentPosition( document.createElement( "fieldset" ) ) & 1;
+} );
// Support: IE<8
// Prevent attribute/property "interpolation"
// https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
-if ( !assert(function( el ) {
+if ( !assert( function( el ) {
el.innerHTML = "";
- return el.firstChild.getAttribute("href") === "#" ;
-}) ) {
+ return el.firstChild.getAttribute( "href" ) === "#";
+} ) ) {
addHandle( "type|href|height|width", function( elem, name, isXML ) {
if ( !isXML ) {
return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
}
- });
+ } );
}
// Support: IE<9
// Use defaultValue in place of getAttribute("value")
-if ( !support.attributes || !assert(function( el ) {
+if ( !support.attributes || !assert( function( el ) {
el.innerHTML = "";
el.firstChild.setAttribute( "value", "" );
return el.firstChild.getAttribute( "value" ) === "";
-}) ) {
+} ) ) {
addHandle( "value", function( elem, name, isXML ) {
if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
return elem.defaultValue;
}
- });
+ } );
}
// Support: IE<9
// Use getAttributeNode to fetch booleans when getAttribute lies
-if ( !assert(function( el ) {
- return el.getAttribute("disabled") == null;
-}) ) {
+if ( !assert( function( el ) {
+ return el.getAttribute( "disabled" ) == null;
+} ) ) {
addHandle( booleans, function( elem, name, isXML ) {
var val;
if ( !isXML ) {
return elem[ name ] === true ? name.toLowerCase() :
- (val = elem.getAttributeNode( name )) && val.specified ?
+ ( val = elem.getAttributeNode( name ) ) && val.specified ?
val.value :
- null;
+ null;
}
- });
+ } );
}
// EXPOSE
@@ -2270,13 +2380,17 @@ Sizzle.noConflict = function() {
};
if ( typeof define === "function" && define.amd ) {
- define(function() { return Sizzle; });
+ define( function() {
+ return Sizzle;
+ } );
+
// Sizzle requires that there be a global window in Common-JS like environments
} else if ( typeof module !== "undefined" && module.exports ) {
module.exports = Sizzle;
} else {
window.Sizzle = Sizzle;
}
+
// EXPOSE
-})( window );
+} )( window );
diff --git a/tasks/commit.js b/tasks/commit.js
index 18d57b4b..91a90849 100644
--- a/tasks/commit.js
+++ b/tasks/commit.js
@@ -1,10 +1,10 @@
"use strict";
-
var exec = require( "child_process" ).exec;
module.exports = function( grunt ) {
grunt.registerTask( "commit", "Add and commit changes", function( message ) {
+
// Always add dist directory
exec( "git add dist && git commit -m " + message, this.async() );
- });
+ } );
};
diff --git a/tasks/compile.js b/tasks/compile.js
index b5ff73a5..3777f32d 100644
--- a/tasks/compile.js
+++ b/tasks/compile.js
@@ -23,7 +23,7 @@ module.exports = function( grunt ) {
( "0" + ( date.getMonth() + 1 ) ).slice( -2 ),
( "0" + date.getDate() ).slice( -2 )
].join( "-" );
- });
+ } );
// Write source to file
grunt.file.write( dest, compiled );
diff --git a/tasks/dist.js b/tasks/dist.js
index f0fdcb9c..bfe748e8 100644
--- a/tasks/dist.js
+++ b/tasks/dist.js
@@ -6,7 +6,7 @@ module.exports = function( grunt ) {
grunt.registerTask( "dist", "Process files for distribution", function() {
var files = grunt.file.expand( { filter: "isFile" }, "dist/*" );
- files.forEach(function( filename ) {
+ files.forEach( function( filename ) {
var map,
text = fs.readFileSync( filename, "utf8" );
@@ -16,20 +16,21 @@ module.exports = function( grunt ) {
text = text.replace( /"dist\//g, "\"" );
fs.writeFileSync( filename, text, "utf-8" );
} else if ( /\.min\.js$/.test( filename ) ) {
+
// Wrap sourceMap directive in multiline comments (#13274)
text = text.replace( /\n?(\/\/@\s*sourceMappingURL=)(.*)/,
function( _, directive, path ) {
map = "\n" + directive + path.replace( /^dist\//, "" );
return "";
- });
+ } );
if ( map ) {
text = text.replace( /(^\/\*[\w\W]*?)\s*\*\/|$/,
function( _, comment ) {
return ( comment || "\n/*" ) + map + "\n*/";
- });
+ } );
}
fs.writeFileSync( filename, text, "utf-8" );
}
- });
- });
+ } );
+ } );
};
diff --git a/tasks/ensure_ascii.js b/tasks/ensure_ascii.js
index cb3941c3..878b32f1 100644
--- a/tasks/ensure_ascii.js
+++ b/tasks/ensure_ascii.js
@@ -26,7 +26,7 @@ module.exports = function( grunt ) {
}
context = text.slice( lineStart + 1, lineEnd );
if ( context.length > MAX_CONTEXT ) {
- if ( (firstIndex - lineStart) < MAX_CONTEXT ) {
+ if ( ( firstIndex - lineStart ) < MAX_CONTEXT ) {
context = context.slice( 0, MAX_CONTEXT );
} else {
context = context.substr(
@@ -35,7 +35,7 @@ module.exports = function( grunt ) {
);
}
}
- first = "U+" + ("000" + offenses[ 0 ].charCodeAt( 0 ).toString( 16 ))
+ first = "U+" + ( "000" + offenses[ 0 ].charCodeAt( 0 ).toString( 16 ) )
.slice( -4 ).toUpperCase();
grunt.log.error( offenses.length + " non-ASCII character(s) in " + file );
grunt.log.error( "First (" + first + ") at index " + firstIndex + ": " +
diff --git a/tasks/release.js b/tasks/release.js
index 870c1ac1..7190ddc9 100644
--- a/tasks/release.js
+++ b/tasks/release.js
@@ -30,16 +30,20 @@ module.exports = function( grunt ) {
);
return;
}
+
// Build to dist directories along with a map and tag the release
- grunt.task.run([
+ grunt.task.run( [
+
// Commit new version
"version:" + version,
+
// Tag new version
"tag:" + version,
+
// Commit next version
"version:" + next
- ]);
+ ] );
done();
- });
- });
+ } );
+ } );
};
diff --git a/tasks/tag.js b/tasks/tag.js
index 23d6df09..4cc99d0a 100644
--- a/tasks/tag.js
+++ b/tasks/tag.js
@@ -5,5 +5,5 @@ var exec = require( "child_process" ).exec;
module.exports = function( grunt ) {
grunt.registerTask( "tag", "Tag the specified version", function( version ) {
exec( "git tag " + version, this.async() );
- });
+ } );
};
diff --git a/tasks/test.js b/tasks/test.js
index f9278d80..0f6c1767 100644
--- a/tasks/test.js
+++ b/tasks/test.js
@@ -8,10 +8,10 @@ module.exports = function( grunt ) {
if ( browsers ) {
options.browsers = browsers.split( "," );
- grunt.task.run([ "lint", "karma:all" ]);
+ grunt.task.run( [ "lint", "karma:all" ] );
} else {
- grunt.task.run([ "lint", "tests" ]);
+ grunt.task.run( [ "lint", "tests" ] );
}
- });
+ } );
};
diff --git a/tasks/version.js b/tasks/version.js
index 1462ccdd..7e177272 100644
--- a/tasks/version.js
+++ b/tasks/version.js
@@ -14,11 +14,11 @@ module.exports = function( grunt ) {
rversion = /("version":\s*")[^"]+/;
// Update version in specified files
- files.forEach(function( filename ) {
+ files.forEach( function( filename ) {
var text = grunt.file.read( filename );
text = text.replace( rversion, "$1" + version );
grunt.file.write( filename, text );
- });
+ } );
// Add files to git index
exec( "git add -A", function( err ) {
@@ -26,14 +26,15 @@ module.exports = function( grunt ) {
grunt.fatal( err );
return;
}
+
// Commit next pre version
grunt.config( "pkg.version", version );
- grunt.task.run([
+ grunt.task.run( [
"build",
"tests",
"commit:'Release\\: Update version to " + version + "'"
- ]);
+ ] );
done();
- });
- });
+ } );
+ } );
};
diff --git a/test/.eslintrc b/test/.eslintrc
new file mode 100644
index 00000000..ff220bbd
--- /dev/null
+++ b/test/.eslintrc
@@ -0,0 +1,42 @@
+{
+ "root": true,
+
+ "extends": "../.eslintrc-browser.json",
+
+ "env": {
+
+ // In source the browser env is not enabled but unit tests rely on them
+ // too much and we don't run them in non-browser environments anyway.
+ "browser": true,
+ "node": true
+ },
+
+ "globals": {
+ "Sizzle": true,
+ "require": false,
+ "QUnit": true,
+ "q": true,
+ "t": true,
+ "setup": true,
+ "testIframeWithCallback": true,
+ "createWithFriesXML": true
+ },
+
+ "rules": {
+ // See https://github.com/eslint/eslint/issues/2342
+ "no-unused-vars": "off",
+
+ // Too many errors
+ "max-len": "off",
+ "brace-style": "off",
+ "key-spacing": "off",
+ "camelcase": "off",
+ "strict": "off",
+
+ // Not really too many - waiting for autofix features for these rules
+ "lines-around-comment": "off",
+
+ // Turned off for compatibility with Google Closure Compiler's advanced mode
+ "dot-notation": "off"
+ }
+}
diff --git a/test/.jshintrc b/test/.jshintrc
deleted file mode 100644
index 1ee88706..00000000
--- a/test/.jshintrc
+++ /dev/null
@@ -1,36 +0,0 @@
-{
- "boss": true,
- "curly": true,
- "eqeqeq": true,
- "eqnull": true,
- "expr": true,
- "immed": true,
- "noarg": true,
- "onevar": true,
- "quotmark": "double",
- "smarttabs": true,
- "trailing": true,
- "undef": true,
- "unused": true,
-
- "sub": true,
-
- "browser": true,
- "wsh": true,
-
- "globals": {
- "QUnit": false,
- "console": false,
-
- "createWithFriesXML": false,
- "setup": false,
- "q": false,
- "t": false,
- "testIframeWithCallback": false,
- "url": false,
-
- "jQuery": false,
-
- "Sizzle": false
- }
-}
diff --git a/test/karma/.jshintrc b/test/karma/.jshintrc
deleted file mode 100644
index d34c42da..00000000
--- a/test/karma/.jshintrc
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "boss": true,
- "curly": true,
- "eqeqeq": true,
- "eqnull": true,
- "expr": true,
- "immed": true,
- "noarg": true,
- "onevar": true,
- "quotmark": "double",
- "smarttabs": true,
- "trailing": true,
- "undef": true,
- "unused": true,
-
- "node": true
-}
diff --git a/test/karma/karma.conf.js b/test/karma/karma.conf.js
index fdd6a002..4a262364 100644
--- a/test/karma/karma.conf.js
+++ b/test/karma/karma.conf.js
@@ -7,12 +7,12 @@ module.exports = function( config ) {
dateString = grunt.config( "dateString" ),
isBrowserStack = !!( process.env.BROWSER_STACK_USERNAME &&
process.env.BROWSER_STACK_ACCESS_KEY ),
- hostName = isBrowserStack? "bs-local.com" : "localhost";
+ hostName = isBrowserStack ? "bs-local.com" : "localhost";
- config.set({
+ config.set( {
browserStack: {
project: "sizzle",
- build: "local run" + (dateString ? ", " + dateString : ""),
+ build: "local run" + ( dateString ? ", " + dateString : "" ),
timeout: 600, // 10 min
// BrowserStack has a limit of 120 requests per minute. The default
// "request per second" strategy doesn't scale to so many browsers.
@@ -91,7 +91,7 @@ module.exports = function( config ) {
browserNoActivityTimeout: 3e5,
browserDisconnectTimeout: 3e5,
browserDisconnectTolerance: 3
- });
+ } );
// Deal with Travis environment
if ( isTravis ) {
diff --git a/test/unit/extending.js b/test/unit/extending.js
index fd2f4b72..6d61e5fa 100644
--- a/test/unit/extending.js
+++ b/test/unit/extending.js
@@ -1,68 +1,68 @@
QUnit.module( "extending", { beforeEach: setup } );
-QUnit.test("custom pseudos", function( assert ) {
+QUnit.test( "custom pseudos", function( assert ) {
assert.expect( 6 );
Sizzle.selectors.filters.foundation = Sizzle.selectors.filters.root;
- assert.deepEqual( Sizzle(":foundation"), [ document.documentElement ], "Copy element filter with new name" );
+ assert.deepEqual( Sizzle( ":foundation" ), [ document.documentElement ], "Copy element filter with new name" );
delete Sizzle.selectors.filters.foundation;
Sizzle.selectors.setFilters.primary = Sizzle.selectors.setFilters.first;
t( "Copy set filter with new name", "div#qunit-fixture :primary", [ "firstp" ] );
delete Sizzle.selectors.setFilters.primary;
- Sizzle.selectors.filters.aristotlean = Sizzle.selectors.createPseudo(function() {
+ Sizzle.selectors.filters.aristotlean = Sizzle.selectors.createPseudo( function() {
return function( elem ) {
return !!elem.id;
};
- });
+ } );
t( "Custom element filter", "#foo :aristotlean", [ "sndp", "en", "yahoo", "sap", "anchor2", "simon" ] );
delete Sizzle.selectors.filters.aristotlean;
- Sizzle.selectors.filters.endswith = Sizzle.selectors.createPseudo(function( text ) {
+ Sizzle.selectors.filters.endswith = Sizzle.selectors.createPseudo( function( text ) {
return function( elem ) {
return Sizzle.getText( elem ).slice( -text.length ) === text;
};
- });
- t( "Custom element filter with argument", "a:endswith(ogle)", ["google"] );
+ } );
+ t( "Custom element filter with argument", "a:endswith(ogle)", [ "google" ] );
delete Sizzle.selectors.filters.endswith;
- Sizzle.selectors.setFilters.second = Sizzle.selectors.createPseudo(function() {
- return Sizzle.selectors.createPseudo(function( seed, matches ) {
- if ( seed[1] ) {
- matches[1] = seed[1];
- seed[1] = false;
+ Sizzle.selectors.setFilters.second = Sizzle.selectors.createPseudo( function() {
+ return Sizzle.selectors.createPseudo( function( seed, matches ) {
+ if ( seed[ 1 ] ) {
+ matches[ 1 ] = seed[ 1 ];
+ seed[ 1 ] = false;
}
- });
- });
- t( "Custom set filter", "#qunit-fixture p:second", ["ap"] );
+ } );
+ } );
+ t( "Custom set filter", "#qunit-fixture p:second", [ "ap" ] );
delete Sizzle.selectors.filters.second;
- Sizzle.selectors.setFilters.slice = Sizzle.selectors.createPseudo(function( argument ) {
- var bounds = argument.split(":");
- return Sizzle.selectors.createPseudo(function( seed, matches ) {
- var i = bounds[1];
+ Sizzle.selectors.setFilters.slice = Sizzle.selectors.createPseudo( function( argument ) {
+ var bounds = argument.split( ":" );
+ return Sizzle.selectors.createPseudo( function( seed, matches ) {
+ var i = bounds[ 1 ];
// Match elements found at the specified indexes
- while ( --i >= bounds[0] ) {
- if ( seed[i] ) {
- matches[i] = seed[i];
- seed[i] = false;
+ while ( --i >= bounds[ 0 ] ) {
+ if ( seed[ i ] ) {
+ matches[ i ] = seed[ i ];
+ seed[ i ] = false;
}
}
- });
- });
+ } );
+ } );
t( "Custom set filter with argument", "#qunit-fixture p:slice(1:3)", [ "ap", "sndp" ] );
delete Sizzle.selectors.filters.slice;
-});
+} );
-QUnit.test("backwards-compatible custom pseudos", function( assert ) {
+QUnit.test( "backwards-compatible custom pseudos", function( assert ) {
assert.expect( 3 );
Sizzle.selectors.filters.icontains = function( elem, i, match ) {
- return Sizzle.getText( elem ).toLowerCase().indexOf( (match[3] || "").toLowerCase() ) > -1;
+ return Sizzle.getText( elem ).toLowerCase().indexOf( ( match[ 3 ] || "" ).toLowerCase() ) > -1;
};
- t( "Custom element filter with argument", "a:icontains(THIS BLOG ENTRY)", ["simon1"] );
+ t( "Custom element filter with argument", "a:icontains(THIS BLOG ENTRY)", [ "simon1" ] );
delete Sizzle.selectors.filters.icontains;
Sizzle.selectors.setFilters.podium = function( elements, argument ) {
@@ -71,32 +71,32 @@ QUnit.test("backwards-compatible custom pseudos", function( assert ) {
};
// Using TAG as the first token here forces this setMatcher into a fail state
// Where the descendent combinator was lost
- t( "Custom setFilter", "form#form :PODIUM", ["label-for", "text1", "text2"] );
- t( "Custom setFilter with argument", "#form input:Podium(1)", ["text1"] );
+ t( "Custom setFilter", "form#form :PODIUM", [ "label-for", "text1", "text2" ] );
+ t( "Custom setFilter with argument", "#form input:Podium(1)", [ "text1" ] );
delete Sizzle.selectors.setFilters.podium;
-});
+} );
-QUnit.test("custom attribute getters", function( assert ) {
+QUnit.test( "custom attribute getters", function( assert ) {
assert.expect( 2 );
var original = Sizzle.selectors.attrHandle.hreflang,
selector = "a:contains('mark')[hreflang='http://diveintomark.org/en']";
Sizzle.selectors.attrHandle.hreflang = function( elem, name ) {
- var href = elem.getAttribute("href"),
+ var href = elem.getAttribute( "href" ),
lang = elem.getAttribute( name );
return lang && ( href + lang );
};
- assert.deepEqual( Sizzle(selector, createWithFriesXML()), [], "Custom attrHandle (preferred document)" );
- t( "Custom attrHandle (preferred document)", selector, ["mark"] );
+ assert.deepEqual( Sizzle( selector, createWithFriesXML() ), [], "Custom attrHandle (preferred document)" );
+ t( "Custom attrHandle (preferred document)", selector, [ "mark" ] );
Sizzle.selectors.attrHandle.hreflang = original;
-});
+} );
-QUnit.test("Ensure no 'undefined' handler is added", function( assert ) {
+QUnit.test( "Ensure no 'undefined' handler is added", function( assert ) {
assert.expect( 1 );
assert.ok( !Sizzle.selectors.attrHandle.hasOwnProperty( "undefined" ),
"Extra attr handlers are not added to Expr.attrHandle (gh-353)" );
-});
+} );
diff --git a/test/unit/selector.js b/test/unit/selector.js
index 3117daa9..0e80f2f0 100644
--- a/test/unit/selector.js
+++ b/test/unit/selector.js
@@ -18,44 +18,44 @@ QUnit.module( "selector", { beforeEach: setup } );
@example url("data/test.php?foo=bar") => "data/test.php?foo=bar&10538358345554"
*/
-QUnit.test("element", function( assert ) {
+QUnit.test( "element", function( assert ) {
assert.expect( 35 );
var form, all, good, i, lengthtest, siblingTest, html;
- assert.equal( Sizzle("").length, 0, "Empty selector returns an empty array" );
- assert.deepEqual( Sizzle("div", document.createTextNode("")), [],
+ assert.equal( Sizzle( "" ).length, 0, "Empty selector returns an empty array" );
+ assert.deepEqual( Sizzle( "div", document.createTextNode( "" ) ), [],
"Text element as context fails silently" );
- form = document.getElementById("form");
+ form = document.getElementById( "form" );
assert.ok( !Sizzle.matchesSelector( form, "" ),
"Empty string passed to matchesSelector does not match" );
- assert.equal( Sizzle(" ").length, 0, "Empty selector returns an empty array" );
- assert.equal( Sizzle("\t").length, 0, "Empty selector returns an empty array" );
+ assert.equal( Sizzle( " " ).length, 0, "Empty selector returns an empty array" );
+ assert.equal( Sizzle( "\t" ).length, 0, "Empty selector returns an empty array" );
- all = Sizzle("*");
+ all = Sizzle( "*" );
assert.ok( all.length >= 30, "Select all" );
good = true;
for ( i = 0; i < all.length; i++ ) {
- if ( all[i].nodeType === 8 ) {
+ if ( all[ i ].nodeType === 8 ) {
good = false;
}
}
assert.ok( good, "Select all elements, no comment nodes" );
- t( "Element Selector", "html", ["html"] );
- t( "Element Selector", "body", ["body"] );
- t( "Element Selector", "#qunit-fixture p", ["firstp","ap","sndp","en","sap","first"] );
-
- t( "Leading space", " #qunit-fixture p", ["firstp","ap","sndp","en","sap","first"] );
- t( "Leading tab", "\t#qunit-fixture p", ["firstp","ap","sndp","en","sap","first"] );
- t( "Leading carriage return", "\r#qunit-fixture p", ["firstp","ap","sndp","en","sap","first"] );
- t( "Leading line feed", "\n#qunit-fixture p", ["firstp","ap","sndp","en","sap","first"] );
- t( "Leading form feed", "\f#qunit-fixture p", ["firstp","ap","sndp","en","sap","first"] );
- t( "Trailing space", "#qunit-fixture p ", ["firstp","ap","sndp","en","sap","first"] );
- t( "Trailing tab", "#qunit-fixture p\t", ["firstp","ap","sndp","en","sap","first"] );
+ t( "Element Selector", "html", [ "html" ] );
+ t( "Element Selector", "body", [ "body" ] );
+ t( "Element Selector", "#qunit-fixture p", [ "firstp", "ap", "sndp", "en", "sap", "first" ] );
+
+ t( "Leading space", " #qunit-fixture p", [ "firstp", "ap", "sndp", "en", "sap", "first" ] );
+ t( "Leading tab", "\t#qunit-fixture p", [ "firstp", "ap", "sndp", "en", "sap", "first" ] );
+ t( "Leading carriage return", "\r#qunit-fixture p", [ "firstp", "ap", "sndp", "en", "sap", "first" ] );
+ t( "Leading line feed", "\n#qunit-fixture p", [ "firstp", "ap", "sndp", "en", "sap", "first" ] );
+ t( "Leading form feed", "\f#qunit-fixture p", [ "firstp", "ap", "sndp", "en", "sap", "first" ] );
+ t( "Trailing space", "#qunit-fixture p ", [ "firstp", "ap", "sndp", "en", "sap", "first" ] );
+ t( "Trailing tab", "#qunit-fixture p\t", [ "firstp", "ap", "sndp", "en", "sap", "first" ] );
t( "Trailing carriage return", "#qunit-fixture p\r",
- ["firstp","ap","sndp","en","sap","first"] );
- t( "Trailing line feed", "#qunit-fixture p\n", ["firstp","ap","sndp","en","sap","first"] );
- t( "Trailing form feed", "#qunit-fixture p\f", ["firstp","ap","sndp","en","sap","first"] );
+ [ "firstp", "ap", "sndp", "en", "sap", "first" ] );
+ t( "Trailing line feed", "#qunit-fixture p\n", [ "firstp", "ap", "sndp", "en", "sap", "first" ] );
+ t( "Trailing form feed", "#qunit-fixture p\f", [ "firstp", "ap", "sndp", "en", "sap", "first" ] );
assert.deepEqual(
jQuery( Sizzle( "div ol" ) ).filter( "#qunit-fixture *" ).get(),
@@ -69,30 +69,30 @@ QUnit.test("element", function( assert ) {
);
// Check for unique-ness and sort order
- assert.deepEqual( Sizzle("p, div p"), Sizzle("p"), "Check for duplicates: p, div p" );
+ assert.deepEqual( Sizzle( "p, div p" ), Sizzle( "p" ), "Check for duplicates: p, div p" );
jQuery( "" ).prependTo( "#qunit-fixture" );
- t( "Checking sort order", "#qunit-fixture h2, #qunit-fixture h1", ["h1", "h2", "h2-2"] );
- t( "Checking sort order", "#qunit-fixture h2:first, #qunit-fixture h1:first", ["h1", "h2"] );
+ t( "Checking sort order", "#qunit-fixture h2, #qunit-fixture h1", [ "h1", "h2", "h2-2" ] );
+ t( "Checking sort order", "#qunit-fixture h2:first, #qunit-fixture h1:first", [ "h1", "h2" ] );
t( "Checking sort order", "#qunit-fixture p, #qunit-fixture p a",
[ "firstp", "simon1", "ap", "google", "groups", "anchor1", "mark", "sndp", "en", "yahoo",
- "sap", "anchor2", "simon", "first"] );
+ "sap", "anchor2", "simon", "first" ] );
// Test Conflict ID
- lengthtest = document.getElementById("lengthtest");
- assert.deepEqual( Sizzle("#idTest", lengthtest), q("idTest"),
+ lengthtest = document.getElementById( "lengthtest" );
+ assert.deepEqual( Sizzle( "#idTest", lengthtest ), q( "idTest" ),
"Finding element with id of ID." );
- assert.deepEqual( Sizzle("[name='id']", lengthtest), q("idTest"),
+ assert.deepEqual( Sizzle( "[name='id']", lengthtest ), q( "idTest" ),
"Finding element with id of ID." );
- assert.deepEqual( Sizzle("input[id='idTest']", lengthtest), q("idTest"),
+ assert.deepEqual( Sizzle( "input[id='idTest']", lengthtest ), q( "idTest" ),
"Finding elements with id of ID." );
- siblingTest = document.getElementById("siblingTest");
- assert.deepEqual( Sizzle("div em", siblingTest), [],
+ siblingTest = document.getElementById( "siblingTest" );
+ assert.deepEqual( Sizzle( "div em", siblingTest ), [],
"Element-rooted QSA does not select based on document context" );
- assert.deepEqual( Sizzle("div em, div em, div em:not(div em)", siblingTest), [],
+ assert.deepEqual( Sizzle( "div em, div em, div em:not(div em)", siblingTest ), [],
"Element-rooted QSA does not select based on document context" );
- assert.deepEqual( Sizzle("div em, em\\,", siblingTest), [],
+ assert.deepEqual( Sizzle( "div em, em\\,", siblingTest ), [],
"Escaped commas do not get treated with an id in element-rooted QSA" );
html = "";
@@ -100,53 +100,53 @@ QUnit.test("element", function( assert ) {
html = "" + html + "
";
}
html = jQuery( html ).appendTo( document.body );
- assert.ok( !!Sizzle("body div div div").length,
+ assert.ok( !!Sizzle( "body div div div" ).length,
"No stack or performance problems with large amounts of descendants" );
- assert.ok( !!Sizzle("body>div div div").length,
+ assert.ok( !!Sizzle( "body>div div div" ).length,
"No stack or performance problems with large amounts of descendants" );
html.remove();
// Real use case would be using .watch in browsers with window.watch (see Issue #157)
- q("qunit-fixture")[0].appendChild( document.createElement("toString") ).id = "toString";
- t( "Element name matches Object.prototype property", "toString#toString", ["toString"] );
-});
+ q( "qunit-fixture" )[ 0 ].appendChild( document.createElement( "toString" ) ).id = "toString";
+ t( "Element name matches Object.prototype property", "toString#toString", [ "toString" ] );
+} );
-QUnit.test("XML Document Selectors", function( assert ) {
+QUnit.test( "XML Document Selectors", function( assert ) {
var xml = createWithFriesXML();
assert.expect( 11 );
- assert.equal( Sizzle("foo_bar", xml).length, 1, "Element Selector with underscore" );
- assert.equal( Sizzle(".component", xml).length, 1, "Class selector" );
- assert.equal( Sizzle("[class*=component]", xml).length, 1, "Attribute selector for class" );
- assert.equal( Sizzle("property[name=prop2]", xml).length, 1, "Attribute selector with name" );
- assert.equal( Sizzle("[name=prop2]", xml).length, 1, "Attribute selector with name" );
- assert.equal( Sizzle("#seite1", xml).length, 1, "Attribute selector with ID" );
- assert.equal( Sizzle("component#seite1", xml).length, 1, "Attribute selector with ID" );
- assert.equal( Sizzle.matches( "#seite1", Sizzle("component", xml) ).length, 1,
+ assert.equal( Sizzle( "foo_bar", xml ).length, 1, "Element Selector with underscore" );
+ assert.equal( Sizzle( ".component", xml ).length, 1, "Class selector" );
+ assert.equal( Sizzle( "[class*=component]", xml ).length, 1, "Attribute selector for class" );
+ assert.equal( Sizzle( "property[name=prop2]", xml ).length, 1, "Attribute selector with name" );
+ assert.equal( Sizzle( "[name=prop2]", xml ).length, 1, "Attribute selector with name" );
+ assert.equal( Sizzle( "#seite1", xml ).length, 1, "Attribute selector with ID" );
+ assert.equal( Sizzle( "component#seite1", xml ).length, 1, "Attribute selector with ID" );
+ assert.equal( Sizzle.matches( "#seite1", Sizzle( "component", xml ) ).length, 1,
"Attribute selector filter with ID" );
- assert.equal( Sizzle("meta property thing", xml).length, 2,
+ assert.equal( Sizzle( "meta property thing", xml ).length, 2,
"Descendent selector and dir caching" );
assert.ok( Sizzle.matchesSelector( xml.lastChild, "soap\\:Envelope" ),
"Check for namespaced element" );
- xml = jQuery.parseXML("");
+ xml = jQuery.parseXML( "" );
assert.equal( Sizzle( "elem:not(:has(*))", xml ).length, 1,
"Non-qSA path correctly handles numeric ids (jQuery #14142)" );
-});
+} );
-QUnit.test("broken", function( assert ) {
+QUnit.test( "broken", function( assert ) {
assert.expect( 29 );
var attrbad,
broken = function( name, selector ) {
- assert.throws(function() {
+ assert.throws( function() {
// Setting context to null here somehow avoids QUnit's window.error handling
// making the e & e.message correct
// For whatever reason, without this,
// Sizzle.error will be called but no error will be seen in oldIE
Sizzle.call( null, selector );
}, function( e ) {
- return e.message.indexOf("Syntax error") >= 0;
+ return e.message.indexOf( "Syntax error" ) >= 0;
}, name + ": " + selector );
};
@@ -161,7 +161,7 @@ QUnit.test("broken", function( assert ) {
broken( "Broken Selector", ",a" );
broken( "Broken Selector", "a," );
// Hangs on IE 9 if regular expression is inefficient
- broken( "Broken Selector", "[id=012345678901234567890123456789");
+ broken( "Broken Selector", "[id=012345678901234567890123456789" );
broken( "Doesn't exist", ":visble" );
broken( "Nth-child", ":nth-child" );
// Sigh again. IE 9 thinks this is also a real selector
@@ -184,171 +184,171 @@ QUnit.test("broken", function( assert ) {
broken( "Only-last-child", ":only-last-child" );
// Make sure attribute value quoting works correctly. See: #6093
- attrbad = jQuery("").appendTo("#qunit-fixture");
+ attrbad = jQuery( "" ).appendTo( "#qunit-fixture" );
broken( "Attribute equals non-value", "input[name=]" );
broken( "Attribute equals unquoted non-identifer", "input[name=foo.baz]" );
broken( "Attribute equals unquoted non-identifer", "input[name=foo[baz]]" );
broken( "Attribute equals bad string", "input[name=''double-quoted'']" );
broken( "Attribute equals bad string", "input[name='apostrophe'd']" );
-});
+} );
-QUnit.test("id", function( assert ) {
+QUnit.test( "id", function( assert ) {
assert.expect( 34 );
var fiddle, a;
- t( "ID Selector", "#body", ["body"] );
- t( "ID Selector w/ Element", "body#body", ["body"] );
+ t( "ID Selector", "#body", [ "body" ] );
+ t( "ID Selector w/ Element", "body#body", [ "body" ] );
t( "ID Selector w/ Element", "ul#first", [] );
- t( "ID selector with existing ID descendant", "#firstp #simon1", ["simon1"] );
+ t( "ID selector with existing ID descendant", "#firstp #simon1", [ "simon1" ] );
t( "ID selector with non-existant descendant", "#firstp #foobar", [] );
- t( "ID selector using UTF8", "#台北Táiběi", ["台北Táiběi"] );
- t( "Multiple ID selectors using UTF8", "#台北Táiběi, #台北", ["台北Táiběi","台北"] );
- t( "Descendant ID selector using UTF8", "div #台北", ["台北"] );
- t( "Child ID selector using UTF8", "form > #台北", ["台北"] );
-
- t( "Escaped ID", "#foo\\:bar", ["foo:bar"] );
- t( "Escaped ID with descendant", "#foo\\:bar span:not(:input)", ["foo_descendant"] );
- t( "Escaped ID", "#test\\.foo\\[5\\]bar", ["test.foo[5]bar"] );
- t( "Descendant escaped ID", "div #foo\\:bar", ["foo:bar"] );
- t( "Descendant escaped ID", "div #test\\.foo\\[5\\]bar", ["test.foo[5]bar"] );
- t( "Child escaped ID", "form > #foo\\:bar", ["foo:bar"] );
- t( "Child escaped ID", "form > #test\\.foo\\[5\\]bar", ["test.foo[5]bar"] );
-
- fiddle = jQuery("
")
- .appendTo("#qunit-fixture");
- assert.deepEqual( Sizzle( "> span", Sizzle("#fiddle\\\\Foo")[0] ), q([ "fiddleSpan" ]),
+ t( "ID selector using UTF8", "#台北Táiběi", [ "台北Táiběi" ] );
+ t( "Multiple ID selectors using UTF8", "#台北Táiběi, #台北", [ "台北Táiběi", "台北" ] );
+ t( "Descendant ID selector using UTF8", "div #台北", [ "台北" ] );
+ t( "Child ID selector using UTF8", "form > #台北", [ "台北" ] );
+
+ t( "Escaped ID", "#foo\\:bar", [ "foo:bar" ] );
+ t( "Escaped ID with descendant", "#foo\\:bar span:not(:input)", [ "foo_descendant" ] );
+ t( "Escaped ID", "#test\\.foo\\[5\\]bar", [ "test.foo[5]bar" ] );
+ t( "Descendant escaped ID", "div #foo\\:bar", [ "foo:bar" ] );
+ t( "Descendant escaped ID", "div #test\\.foo\\[5\\]bar", [ "test.foo[5]bar" ] );
+ t( "Child escaped ID", "form > #foo\\:bar", [ "foo:bar" ] );
+ t( "Child escaped ID", "form > #test\\.foo\\[5\\]bar", [ "test.foo[5]bar" ] );
+
+ fiddle = jQuery( "
" )
+ .appendTo( "#qunit-fixture" );
+ assert.deepEqual( Sizzle( "> span", Sizzle( "#fiddle\\\\Foo" )[ 0 ] ), q( [ "fiddleSpan" ] ),
"Escaped ID as context" );
fiddle.remove();
- t( "ID Selector, child ID present", "#form > #radio1", ["radio1"] ); // bug #267
+ t( "ID Selector, child ID present", "#form > #radio1", [ "radio1" ] ); // bug #267
t( "ID Selector, not an ancestor ID", "#form #first", [] );
t( "ID Selector, not a child ID", "#form > #option1a", [] );
- t( "All Children of ID", "#foo > *", ["sndp", "en", "sap"] );
+ t( "All Children of ID", "#foo > *", [ "sndp", "en", "sap" ] );
t( "All Children of ID with no children", "#firstUL > *", [] );
- assert.equal( Sizzle("#tName1")[0].id, "tName1",
+ assert.equal( Sizzle( "#tName1" )[ 0 ].id, "tName1",
"ID selector with same value for a name attribute" );
t( "ID selector non-existing but name attribute on an A tag", "#tName2", [] );
t( "Leading ID selector non-existing but name attribute on an A tag", "#tName2 span", [] );
- t( "Leading ID selector existing, retrieving the child", "#tName1 span", ["tName1-span"] );
- assert.equal( Sizzle("div > div #tName1")[0].id, Sizzle("#tName1-span")[0].parentNode.id,
+ t( "Leading ID selector existing, retrieving the child", "#tName1 span", [ "tName1-span" ] );
+ assert.equal( Sizzle( "div > div #tName1" )[ 0 ].id, Sizzle( "#tName1-span" )[ 0 ].parentNode.id,
"Ending with ID" );
- a = jQuery("").appendTo("#qunit-fixture");
- t( "ID Selector contains backslash", "#backslash\\\\foo", ["backslash\\foo"] );
+ a = jQuery( "" ).appendTo( "#qunit-fixture" );
+ t( "ID Selector contains backslash", "#backslash\\\\foo", [ "backslash\\foo" ] );
- t( "ID Selector on Form with an input that has a name of 'id'", "#lengthtest", ["lengthtest"] );
+ t( "ID Selector on Form with an input that has a name of 'id'", "#lengthtest", [ "lengthtest" ] );
t( "ID selector with non-existant ancestor", "#asdfasdf #foobar", [] ); // bug #986
- assert.deepEqual( Sizzle("div#form", document.body), [],
+ assert.deepEqual( Sizzle( "div#form", document.body ), [],
"ID selector within the context of another element" );
- t( "Underscore ID", "#types_all", ["types_all"] );
- t( "Dash ID", "#qunit-fixture", ["qunit-fixture"] );
+ t( "Underscore ID", "#types_all", [ "types_all" ] );
+ t( "Dash ID", "#qunit-fixture", [ "qunit-fixture" ] );
- t( "ID with weird characters in it", "#name\\+value", ["name+value"] );
-});
+ t( "ID with weird characters in it", "#name\\+value", [ "name+value" ] );
+} );
-QUnit.test("class", function( assert ) {
+QUnit.test( "class", function( assert ) {
assert.expect( 27 );
- t( "Class Selector", ".blog", ["mark","simon"] );
- t( "Class Selector", ".GROUPS", ["groups"] );
- t( "Class Selector", ".blog.link", ["simon"] );
- t( "Class Selector w/ Element", "a.blog", ["mark","simon"] );
- t( "Parent Class Selector", "p .blog", ["mark","simon"] );
+ t( "Class Selector", ".blog", [ "mark", "simon" ] );
+ t( "Class Selector", ".GROUPS", [ "groups" ] );
+ t( "Class Selector", ".blog.link", [ "simon" ] );
+ t( "Class Selector w/ Element", "a.blog", [ "mark", "simon" ] );
+ t( "Parent Class Selector", "p .blog", [ "mark", "simon" ] );
- t( "Class selector using UTF8", ".台北Táiběi", ["utf8class1"] );
+ t( "Class selector using UTF8", ".台北Táiběi", [ "utf8class1" ] );
//t( "Class selector using UTF8", ".台北", ["utf8class1","utf8class2"] );
- t( "Class selector using UTF8", ".台北Táiběi.台北", ["utf8class1"] );
- t( "Class selector using UTF8", ".台北Táiběi, .台北", ["utf8class1","utf8class2"] );
- t( "Descendant class selector using UTF8", "div .台北Táiběi", ["utf8class1"] );
- t( "Child class selector using UTF8", "form > .台北Táiběi", ["utf8class1"] );
-
- t( "Escaped Class", ".foo\\:bar", ["foo:bar"] );
- t( "Escaped Class", ".test\\.foo\\[5\\]bar", ["test.foo[5]bar"] );
- t( "Descendant escaped Class", "div .foo\\:bar", ["foo:bar"] );
- t( "Descendant escaped Class", "div .test\\.foo\\[5\\]bar", ["test.foo[5]bar"] );
- t( "Child escaped Class", "form > .foo\\:bar", ["foo:bar"] );
- t( "Child escaped Class", "form > .test\\.foo\\[5\\]bar", ["test.foo[5]bar"] );
-
- var div = document.createElement("div");
+ t( "Class selector using UTF8", ".台北Táiběi.台北", [ "utf8class1" ] );
+ t( "Class selector using UTF8", ".台北Táiběi, .台北", [ "utf8class1", "utf8class2" ] );
+ t( "Descendant class selector using UTF8", "div .台北Táiběi", [ "utf8class1" ] );
+ t( "Child class selector using UTF8", "form > .台北Táiběi", [ "utf8class1" ] );
+
+ t( "Escaped Class", ".foo\\:bar", [ "foo:bar" ] );
+ t( "Escaped Class", ".test\\.foo\\[5\\]bar", [ "test.foo[5]bar" ] );
+ t( "Descendant escaped Class", "div .foo\\:bar", [ "foo:bar" ] );
+ t( "Descendant escaped Class", "div .test\\.foo\\[5\\]bar", [ "test.foo[5]bar" ] );
+ t( "Child escaped Class", "form > .foo\\:bar", [ "foo:bar" ] );
+ t( "Child escaped Class", "form > .test\\.foo\\[5\\]bar", [ "test.foo[5]bar" ] );
+
+ var div = document.createElement( "div" );
div.innerHTML = "";
- assert.deepEqual( Sizzle(".e", div), [ div.firstChild ], "Finding a second class." );
+ assert.deepEqual( Sizzle( ".e", div ), [ div.firstChild ], "Finding a second class." );
div.lastChild.className = "e";
- assert.deepEqual( Sizzle(".e", div), [ div.firstChild, div.lastChild ],
+ assert.deepEqual( Sizzle( ".e", div ), [ div.firstChild, div.lastChild ],
"Finding a modified class." );
- assert.ok( !Sizzle.matchesSelector( div, ".null"),
+ assert.ok( !Sizzle.matchesSelector( div, ".null" ),
".null does not match an element with no class" );
- assert.ok( !Sizzle.matchesSelector( div.firstChild, ".null div"),
+ assert.ok( !Sizzle.matchesSelector( div.firstChild, ".null div" ),
".null does not match an element with no class" );
div.className = "null";
- assert.ok( Sizzle.matchesSelector( div, ".null"), ".null matches element with class 'null'" );
- assert.ok( Sizzle.matchesSelector( div.firstChild, ".null div"),
+ assert.ok( Sizzle.matchesSelector( div, ".null" ), ".null matches element with class 'null'" );
+ assert.ok( Sizzle.matchesSelector( div.firstChild, ".null div" ),
"caching system respects DOM changes" );
assert.ok( !Sizzle.matchesSelector( document, ".foo" ),
"testing class on document doesn't error" );
assert.ok( !Sizzle.matchesSelector( window, ".foo" ), "testing class on window doesn't error" );
div.lastChild.className += " hasOwnProperty toString";
- assert.deepEqual( Sizzle(".e.hasOwnProperty.toString", div), [ div.lastChild ],
+ assert.deepEqual( Sizzle( ".e.hasOwnProperty.toString", div ), [ div.lastChild ],
"Classes match Object.prototype properties" );
div = jQuery( "" )[ 0 ];
- assert.equal( Sizzle(".foo", div).length, 1, "Class selector against SVG container" );
+ assert.equal( Sizzle( ".foo", div ).length, 1, "Class selector against SVG container" );
// Support: IE <=7
// Test SVG selection only if SVG works
if ( div.firstChild.firstChild ) {
- assert.equal( Sizzle(".foo", div.firstChild).length, 1,
+ assert.equal( Sizzle( ".foo", div.firstChild ).length, 1,
"Class selector directly against SVG" );
} else {
assert.ok( true, "SVG not supported" );
}
-});
+} );
-QUnit.test("name", function( assert ) {
+QUnit.test( "name", function( assert ) {
assert.expect( 14 );
var form;
- t( "Name selector", "input[name=action]", ["text1"] );
- t( "Name selector with single quotes", "input[name='action']", ["text1"] );
- t( "Name selector with double quotes", "input[name=\"action\"]", ["text1"] );
+ t( "Name selector", "input[name=action]", [ "text1" ] );
+ t( "Name selector with single quotes", "input[name='action']", [ "text1" ] );
+ t( "Name selector with double quotes", "input[name=\"action\"]", [ "text1" ] );
- t( "Name selector non-input", "[name=example]", ["name-is-example"] );
- t( "Name selector non-input", "[name=div]", ["name-is-div"] );
- t( "Name selector non-input", "*[name=iframe]", ["iframe"] );
+ t( "Name selector non-input", "[name=example]", [ "name-is-example" ] );
+ t( "Name selector non-input", "[name=div]", [ "name-is-div" ] );
+ t( "Name selector non-input", "*[name=iframe]", [ "iframe" ] );
- t( "Name selector for grouped input", "input[name='types[]']", ["types_all", "types_anime", "types_movie"] );
+ t( "Name selector for grouped input", "input[name='types[]']", [ "types_all", "types_anime", "types_movie" ] );
- form = document.getElementById("form");
- assert.deepEqual( Sizzle("input[name=action]", form), q("text1"),
+ form = document.getElementById( "form" );
+ assert.deepEqual( Sizzle( "input[name=action]", form ), q( "text1" ),
"Name selector within the context of another element" );
- assert.deepEqual( Sizzle("input[name='foo[bar]']", form), q("hidden2"),
+ assert.deepEqual( Sizzle( "input[name='foo[bar]']", form ), q( "hidden2" ),
"Name selector for grouped form element within the context of another element" );
- form = jQuery("").appendTo("body");
- assert.equal( Sizzle("input", form[0]).length, 1,
+ form = jQuery( "" ).appendTo( "body" );
+ assert.equal( Sizzle( "input", form[ 0 ] ).length, 1,
"Make sure that rooted queries on forms (with possible expandos) work." );
form.remove();
- t( "Find elements that have similar IDs", "[name=tName1]", ["tName1ID"] );
- t( "Find elements that have similar IDs", "[name=tName2]", ["tName2ID"] );
- t( "Find elements that have similar IDs", "#tName2ID", ["tName2ID"] );
+ t( "Find elements that have similar IDs", "[name=tName1]", [ "tName1ID" ] );
+ t( "Find elements that have similar IDs", "[name=tName2]", [ "tName2ID" ] );
+ t( "Find elements that have similar IDs", "#tName2ID", [ "tName2ID" ] );
t( "Case-sensitivity", "[name=tname1]", [] );
-});
+} );
QUnit.test( "multiple", function( assert ) {
assert.expect( 6 );
@@ -356,108 +356,108 @@ QUnit.test( "multiple", function( assert ) {
jQuery( "#qunit-fixture" ).prepend( "" );
t( "Comma Support", "#qunit-fixture h2, #qunit-fixture p",
- [ "h2","firstp","ap","sndp","en","sap","first" ] );
+ [ "h2", "firstp", "ap", "sndp", "en", "sap", "first" ] );
t( "Comma Support", "#qunit-fixture h2 , #qunit-fixture p",
- [ "h2","firstp","ap","sndp","en","sap","first" ] );
+ [ "h2", "firstp", "ap", "sndp", "en", "sap", "first" ] );
t( "Comma Support", "#qunit-fixture h2 , #qunit-fixture p",
- [ "h2","firstp","ap","sndp","en","sap","first" ] );
+ [ "h2", "firstp", "ap", "sndp", "en", "sap", "first" ] );
t( "Comma Support", "#qunit-fixture h2,#qunit-fixture p",
- [ "h2","firstp","ap","sndp","en","sap","first" ] );
+ [ "h2", "firstp", "ap", "sndp", "en", "sap", "first" ] );
t( "Comma Support", "#qunit-fixture h2,#qunit-fixture p ",
- [ "h2","firstp","ap","sndp","en","sap","first" ] );
+ [ "h2", "firstp", "ap", "sndp", "en", "sap", "first" ] );
t( "Comma Support", "#qunit-fixture h2\t,\r#qunit-fixture p\n",
- [ "h2","firstp","ap","sndp","en","sap","first" ] );
-});
+ [ "h2", "firstp", "ap", "sndp", "en", "sap", "first" ] );
+} );
-QUnit.test("child and adjacent", function( assert ) {
+QUnit.test( "child and adjacent", function( assert ) {
assert.expect( 43 );
var siblingFirst, en, nothiddendiv;
- t( "Child", "p > a", ["simon1","google","groups","mark","yahoo","simon"] );
- t( "Child minus whitespace", "p>a", ["simon1","google","groups","mark","yahoo","simon"] );
+ t( "Child", "p > a", [ "simon1", "google", "groups", "mark", "yahoo", "simon" ] );
+ t( "Child minus whitespace", "p>a", [ "simon1", "google", "groups", "mark", "yahoo", "simon" ] );
t( "Child minus trailing whitespace", "p> a",
- ["simon1","google","groups","mark","yahoo","simon"] );
+ [ "simon1", "google", "groups", "mark", "yahoo", "simon" ] );
t( "Child minus leading whitespace", "p >a",
- ["simon1","google","groups","mark","yahoo","simon"] );
- t( "Child w/ Class", "p > a.blog", ["mark","simon"] );
- t( "All Children", "code > *", ["anchor1","anchor2"] );
- t( "All Grandchildren", "p > * > *", ["anchor1","anchor2"] );
- t( "Rooted tag adjacent", "#qunit-fixture a + a", ["groups", "tName2ID"] );
- t( "Rooted tag adjacent minus whitespace", "#qunit-fixture a+a", ["groups", "tName2ID"] );
+ [ "simon1", "google", "groups", "mark", "yahoo", "simon" ] );
+ t( "Child w/ Class", "p > a.blog", [ "mark", "simon" ] );
+ t( "All Children", "code > *", [ "anchor1", "anchor2" ] );
+ t( "All Grandchildren", "p > * > *", [ "anchor1", "anchor2" ] );
+ t( "Rooted tag adjacent", "#qunit-fixture a + a", [ "groups", "tName2ID" ] );
+ t( "Rooted tag adjacent minus whitespace", "#qunit-fixture a+a", [ "groups", "tName2ID" ] );
t( "Rooted tag adjacent minus leading whitespace", "#qunit-fixture a +a",
- ["groups", "tName2ID"] );
+ [ "groups", "tName2ID" ] );
t( "Rooted tag adjacent minus trailing whitespace", "#qunit-fixture a+ a",
- ["groups", "tName2ID"] );
- t( "Tag adjacent", "p + p", ["ap","en","sap"] );
- t( "#id adjacent", "#firstp + p", ["ap"] );
- t( "Tag#id adjacent", "p#firstp + p", ["ap"] );
- t( "Tag[attr] adjacent", "p[lang=en] + p", ["sap"] );
- t( "Tag.class adjacent", "a.GROUPS + code + a", ["mark"] );
+ [ "groups", "tName2ID" ] );
+ t( "Tag adjacent", "p + p", [ "ap", "en", "sap" ] );
+ t( "#id adjacent", "#firstp + p", [ "ap" ] );
+ t( "Tag#id adjacent", "p#firstp + p", [ "ap" ] );
+ t( "Tag[attr] adjacent", "p[lang=en] + p", [ "sap" ] );
+ t( "Tag.class adjacent", "a.GROUPS + code + a", [ "mark" ] );
t( "Comma, Child, and Adjacent", "#qunit-fixture a + a, code > a",
- ["groups","anchor1","anchor2","tName2ID"] );
+ [ "groups", "anchor1", "anchor2", "tName2ID" ] );
t( "Element Preceded By", "#qunit-fixture p ~ div",
- ["foo", "nothiddendiv", "moretests","tabindex-tests", "liveHandlerOrder", "siblingTest"] );
+ [ "foo", "nothiddendiv", "moretests", "tabindex-tests", "liveHandlerOrder", "siblingTest" ] );
t( "Element Preceded By", "#first ~ div",
- ["moretests","tabindex-tests", "liveHandlerOrder", "siblingTest"] );
- t( "Element Preceded By", "#groups ~ a", ["mark"] );
- t( "Element Preceded By", "#length ~ input", ["idTest"] );
- t( "Element Preceded By", "#siblingfirst ~ em", ["siblingnext", "siblingthird"] );
- t( "Element Preceded By (multiple)", "#siblingTest em ~ em ~ em ~ span", ["siblingspan"] );
+ [ "moretests", "tabindex-tests", "liveHandlerOrder", "siblingTest" ] );
+ t( "Element Preceded By", "#groups ~ a", [ "mark" ] );
+ t( "Element Preceded By", "#length ~ input", [ "idTest" ] );
+ t( "Element Preceded By", "#siblingfirst ~ em", [ "siblingnext", "siblingthird" ] );
+ t( "Element Preceded By (multiple)", "#siblingTest em ~ em ~ em ~ span", [ "siblingspan" ] );
t( "Element Preceded By, Containing", "#liveHandlerOrder ~ div em:contains('1')",
- ["siblingfirst"] );
+ [ "siblingfirst" ] );
- siblingFirst = document.getElementById("siblingfirst");
+ siblingFirst = document.getElementById( "siblingfirst" );
- assert.deepEqual( Sizzle("~ em", siblingFirst), q("siblingnext", "siblingthird"),
+ assert.deepEqual( Sizzle( "~ em", siblingFirst ), q( "siblingnext", "siblingthird" ),
"Element Preceded By with a context." );
- assert.deepEqual( Sizzle("+ em", siblingFirst), q("siblingnext"),
+ assert.deepEqual( Sizzle( "+ em", siblingFirst ), q( "siblingnext" ),
"Element Directly Preceded By with a context." );
- assert.deepEqual( Sizzle("~ em:first", siblingFirst), q("siblingnext"),
+ assert.deepEqual( Sizzle( "~ em:first", siblingFirst ), q( "siblingnext" ),
"Element Preceded By positional with a context." );
- en = document.getElementById("en");
- assert.deepEqual( Sizzle("+ p, a", en), q("yahoo", "sap"),
+ en = document.getElementById( "en" );
+ assert.deepEqual( Sizzle( "+ p, a", en ), q( "yahoo", "sap" ),
"Compound selector with context, beginning with sibling test." );
- assert.deepEqual( Sizzle("a, + p", en), q("yahoo", "sap"),
+ assert.deepEqual( Sizzle( "a, + p", en ), q( "yahoo", "sap" ),
"Compound selector with context, containing sibling test." );
t( "Multiple combinators selects all levels", "#siblingTest em *",
- ["siblingchild", "siblinggrandchild", "siblinggreatgrandchild"] );
+ [ "siblingchild", "siblinggrandchild", "siblinggreatgrandchild" ] );
t( "Multiple combinators selects all levels", "#siblingTest > em *",
- ["siblingchild", "siblinggrandchild", "siblinggreatgrandchild"] );
+ [ "siblingchild", "siblinggrandchild", "siblinggreatgrandchild" ] );
t( "Multiple sibling combinators doesn't miss general siblings",
"#siblingTest > em:first-child + em ~ span",
- ["siblingspan"] );
+ [ "siblingspan" ] );
t( "Combinators are not skipped when mixing general and specific",
"#siblingTest > em:contains('x') + em ~ span",
[] );
- assert.equal( Sizzle("#listWithTabIndex").length, 1,
+ assert.equal( Sizzle( "#listWithTabIndex" ).length, 1,
"Parent div for next test is found via ID (#8310)" );
- assert.equal( Sizzle("#listWithTabIndex li:eq(2) ~ li").length, 1,
+ assert.equal( Sizzle( "#listWithTabIndex li:eq(2) ~ li" ).length, 1,
"Find by general sibling combinator (#8310)" );
- assert.equal( Sizzle("#__sizzle__").length, 0,
+ assert.equal( Sizzle( "#__sizzle__" ).length, 0,
"Make sure the temporary id assigned by sizzle is cleared out (#8310)" );
- assert.equal( Sizzle("#listWithTabIndex").length, 1,
+ assert.equal( Sizzle( "#listWithTabIndex" ).length, 1,
"Parent div for previous test is still found via ID (#8310)" );
t( "Verify deep class selector", "div.blah > p > a", [] );
t( "No element deep selector", "div.foo > span > a", [] );
- nothiddendiv = document.getElementById("nothiddendiv");
- assert.deepEqual( Sizzle("> :first", nothiddendiv), q("nothiddendivchild"),
+ nothiddendiv = document.getElementById( "nothiddendiv" );
+ assert.deepEqual( Sizzle( "> :first", nothiddendiv ), q( "nothiddendivchild" ),
"Verify child context positional selector" );
- assert.deepEqual( Sizzle("> :eq(0)", nothiddendiv), q("nothiddendivchild"),
+ assert.deepEqual( Sizzle( "> :eq(0)", nothiddendiv ), q( "nothiddendivchild" ),
"Verify child context positional selector" );
- assert.deepEqual( Sizzle("> *:first", nothiddendiv), q("nothiddendivchild"),
+ assert.deepEqual( Sizzle( "> *:first", nothiddendiv ), q( "nothiddendivchild" ),
"Verify child context positional selector" );
t( "Non-existant ancestors", ".fototab > .thumbnails > a", [] );
-});
+} );
-QUnit.test("attributes - existence", function( assert ) {
+QUnit.test( "attributes - existence", function( assert ) {
assert.expect( 7 );
t( "on element", "#qunit-fixture a[title]", [ "google" ] );
@@ -465,15 +465,15 @@ QUnit.test("attributes - existence", function( assert ) {
t( "on element (case-insensitive)", "#qunit-fixture a[TITLE]", [ "google" ] );
t( "on any element", "#qunit-fixture *[title]", [ "google" ] );
t( "on implicit element", "#qunit-fixture [title]", [ "google" ] );
- t( "boolean", "#select2 option[selected]", [ "option2d" ]);
+ t( "boolean", "#select2 option[selected]", [ "option2d" ] );
t( "for attribute on label", "form label[for]", [ "label-for" ] );
-});
+} );
-QUnit.test("attributes - equals", function( assert ) {
+QUnit.test( "attributes - equals", function( assert ) {
assert.expect( 20 );
t( "identifier", "#qunit-fixture a[rel=bookmark]", [ "simon1" ] );
- t( "identifier containing underscore", "input[id=types_all]", ["types_all"] );
+ t( "identifier containing underscore", "input[id=types_all]", [ "types_all" ] );
t( "string", "#qunit-fixture a[rel='bookmark']", [ "simon1" ] );
t( "string (whitespace ignored)", "#qunit-fixture a[ rel = 'bookmark' ]", [ "simon1" ] );
t( "non-identifier string", "#qunit-fixture a[href='http://www.google.com/']", [ "google" ] );
@@ -482,12 +482,12 @@ QUnit.test("attributes - equals", function( assert ) {
"#qunit-fixture option[value=1]",
[ "option1b", "option2b", "option3b", "option4b", "option5c" ] );
t( "negative number", "#qunit-fixture li[tabIndex=-1]", [ "foodWithNegativeTabIndex" ] );
- t( "non-ASCII identifier", "span[lang=中文]", ["台北"] );
+ t( "non-ASCII identifier", "span[lang=中文]", [ "台北" ] );
t( "input[type=text]", "#form input[type=text]", [ "text1", "text2", "hidden2", "name" ] );
t( "input[type=search]", "#form input[type=search]", [ "search" ] );
t( "script[src] (jQuery #13777)", "#moretests script[src]", [ "script-src" ] );
- t( "boolean attribute equals name", "#select2 option[selected='selected']", [ "option2d" ]);
+ t( "boolean attribute equals name", "#select2 option[selected='selected']", [ "option2d" ] );
t( "for attribute in form", "#form [for=action]", [ "label-for" ] );
t( "name attribute", "input[name='foo[bar]']", [ "hidden2" ] );
t( "value attribute", "input[value=Test]", [ "text1", "text2" ] );
@@ -508,28 +508,28 @@ QUnit.test("attributes - equals", function( assert ) {
Sizzle( "input[data-comma=\"0,1\"]", document.getElementById( "t12087" ) ),
q( "el12087" ),
"With context, double-quoted attribute containing ','" );
-});
+} );
-QUnit.test("attributes - does not equal", function( assert ) {
+QUnit.test( "attributes - does not equal", function( assert ) {
assert.expect( 2 );
t( "string", "#ap a[hreflang!='en']", [ "google", "groups", "anchor1" ] );
t( "empty string", "#select1 option[value!='']", [ "option1b", "option1c", "option1d" ] );
-});
+} );
-QUnit.test("attributes - starts with", function( assert ) {
+QUnit.test( "attributes - starts with", function( assert ) {
assert.expect( 4 );
// Support: IE<8
// There is apparently no way to bypass interpolation of the *originally-defined* href attribute
- document.getElementById("anchor2").href = "#2";
+ document.getElementById( "anchor2" ).href = "#2";
t( "string (whitespace ignored)", "a[href ^= 'http://www']", [ "google", "yahoo" ] );
t( "href starts with hash", "p a[href^='#']", [ "anchor2" ] );
t( "string containing '['", "input[name^='foo[']", [ "hidden2" ] );
t( "string containing '[' ... ']'", "input[name^='foo[bar]']", [ "hidden2" ] );
-});
+} );
-QUnit.test("attributes - contains", function( assert ) {
+QUnit.test( "attributes - contains", function( assert ) {
assert.expect( 4 );
t( "string (whitespace ignored)", "a[href *= 'google']", [ "google", "groups" ] );
@@ -537,18 +537,18 @@ QUnit.test("attributes - contains", function( assert ) {
t( "string containing '[' ... ']'", "input[name*='foo[bar]']", [ "hidden2" ] );
t( "href contains hash", "p a[href*='#']", [ "simon1", "anchor2" ] );
-});
+} );
-QUnit.test("attributes - ends with", function( assert ) {
+QUnit.test( "attributes - ends with", function( assert ) {
assert.expect( 4 );
t( "string (whitespace ignored)", "a[href $= 'org/']", [ "mark" ] );
t( "string ending with ']'", "input[name$='bar]']", [ "hidden2" ] );
t( "string like '[' ... ']'", "input[name$='[bar]']", [ "hidden2" ] );
t( "string containing '[' ... ']'", "input[name$='foo[bar]']", [ "hidden2" ] );
-});
+} );
-QUnit.test("attributes - whitespace list includes", function( assert ) {
+QUnit.test( "attributes - whitespace list includes", function( assert ) {
assert.expect( 3 );
t( "string found at the beginning",
@@ -558,9 +558,9 @@ QUnit.test("attributes - whitespace list includes", function( assert ) {
"input[data-15233~='bar']",
[ "t15233-double", "t15233-double-tab", "t15233-double-nl", "t15233-triple" ] );
t( "string found at the end", "input[data-15233~='baz']", [ "t15233-triple" ] );
-});
+} );
-QUnit.test("attributes - hyphen-prefix matches", function( assert ) {
+QUnit.test( "attributes - hyphen-prefix matches", function( assert ) {
assert.expect( 3 );
t( "string", "#names-group span[id|='name']", [ "name-is-example", "name-is-div" ] );
@@ -568,9 +568,9 @@ QUnit.test("attributes - hyphen-prefix matches", function( assert ) {
"#names-group span[id|='name-is']",
[ "name-is-example", "name-is-div" ] );
t( "string ending with hyphen", "#names-group span[id|='name-is-']", [] );
-});
+} );
-QUnit.test("attributes - special characters", function( assert ) {
+QUnit.test( "attributes - special characters", function( assert ) {
assert.expect( 13 );
var attrbad,
@@ -594,7 +594,7 @@ QUnit.test("attributes - special characters", function( assert ) {
"" +
"" +
""
- ).appendTo("#qunit-fixture").get();
+ ).appendTo( "#qunit-fixture" ).get();
assert.deepEqual( Sizzle( "input[name=foo\\ bar]", null, null, attrbad ),
q( "attrbad_space" ),
@@ -640,9 +640,9 @@ QUnit.test("attributes - special characters", function( assert ) {
// assert.deepEqual( Sizzle( "input[data-attr='\\01D306A']", null, null, attrbad ),
// q( "attrbad_unicode" ),
// "Long numeric escape (non-BMP)" );
-});
+} );
-QUnit.test("attributes - other", function( assert ) {
+QUnit.test( "attributes - other", function( assert ) {
assert.expect( 7 );
var div = document.getElementById( "foo" );
@@ -671,166 +671,166 @@ QUnit.test("attributes - other", function( assert ) {
t( "attribute name is Gecko Object.prototype property \"watch\"",
"[watch='bar']",
[ "foo" ] );
-});
+} );
-QUnit.test("pseudo - (parent|empty)", function( assert ) {
+QUnit.test( "pseudo - (parent|empty)", function( assert ) {
assert.expect( 3 );
- t( "Empty", "#qunit-fixture ul:empty", ["firstUL"] );
- t( "Empty with comment node", "#qunit-fixture ol:empty", ["empty"] );
- t( "Is A Parent", "#qunit-fixture p:parent", ["firstp","ap","sndp","en","sap","first"] );
-});
+ t( "Empty", "#qunit-fixture ul:empty", [ "firstUL" ] );
+ t( "Empty with comment node", "#qunit-fixture ol:empty", [ "empty" ] );
+ t( "Is A Parent", "#qunit-fixture p:parent", [ "firstp", "ap", "sndp", "en", "sap", "first" ] );
+} );
-QUnit.test("pseudo - (first|last|only)-(child|of-type)", function( assert ) {
+QUnit.test( "pseudo - (first|last|only)-(child|of-type)", function( assert ) {
assert.expect( 12 );
- t( "First Child", "#qunit-fixture p:first-child", ["firstp","sndp"] );
- t( "First Child (leading id)", "#qunit-fixture p:first-child", ["firstp","sndp"] );
- t( "First Child (leading class)", ".nothiddendiv div:first-child", ["nothiddendivchild"] );
- t( "First Child (case-insensitive)", "#qunit-fixture p:FIRST-CHILD", ["firstp","sndp"] );
+ t( "First Child", "#qunit-fixture p:first-child", [ "firstp", "sndp" ] );
+ t( "First Child (leading id)", "#qunit-fixture p:first-child", [ "firstp", "sndp" ] );
+ t( "First Child (leading class)", ".nothiddendiv div:first-child", [ "nothiddendivchild" ] );
+ t( "First Child (case-insensitive)", "#qunit-fixture p:FIRST-CHILD", [ "firstp", "sndp" ] );
- t( "Last Child", "#qunit-fixture p:last-child", ["sap"] );
- t( "Last Child (leading id)", "#qunit-fixture a:last-child", ["simon1","anchor1","mark","yahoo","anchor2","simon","liveLink1","liveLink2"] );
+ t( "Last Child", "#qunit-fixture p:last-child", [ "sap" ] );
+ t( "Last Child (leading id)", "#qunit-fixture a:last-child", [ "simon1", "anchor1", "mark", "yahoo", "anchor2", "simon", "liveLink1", "liveLink2" ] );
- t( "Only Child", "#qunit-fixture a:only-child", ["simon1","anchor1","yahoo","anchor2","liveLink1","liveLink2"] );
+ t( "Only Child", "#qunit-fixture a:only-child", [ "simon1", "anchor1", "yahoo", "anchor2", "liveLink1", "liveLink2" ] );
- t( "First-of-type", "#qunit-fixture > p:first-of-type", ["firstp"] );
- t( "Last-of-type", "#qunit-fixture > p:last-of-type", ["first"] );
- t( "Only-of-type", "#qunit-fixture > :only-of-type", ["name+value", "firstUL", "empty", "floatTest", "iframe", "table", "last"] );
+ t( "First-of-type", "#qunit-fixture > p:first-of-type", [ "firstp" ] );
+ t( "Last-of-type", "#qunit-fixture > p:last-of-type", [ "first" ] );
+ t( "Only-of-type", "#qunit-fixture > :only-of-type", [ "name+value", "firstUL", "empty", "floatTest", "iframe", "table", "last" ] );
// Verify that the child position isn't being cached improperly
- var secondChildren = jQuery("p:nth-child(2)").before("");
+ var secondChildren = jQuery( "p:nth-child(2)" ).before( "" );
t( "No longer second child", "p:nth-child(2)", [] );
secondChildren.prev().remove();
- t( "Restored second child", "p:nth-child(2)", ["ap","en"] );
-});
+ t( "Restored second child", "p:nth-child(2)", [ "ap", "en" ] );
+} );
-QUnit.test("pseudo - nth-child", function( assert ) {
+QUnit.test( "pseudo - nth-child", function( assert ) {
assert.expect( 30 );
- t( "Nth-child", "p:nth-child(1)", ["firstp","sndp"] );
- t( "Nth-child (with whitespace)", "p:nth-child( 1 )", ["firstp","sndp"] );
- t( "Nth-child (case-insensitive)", "#form select:first option:NTH-child(3)", ["option1c"] );
- t( "Not nth-child", "#qunit-fixture p:not(:nth-child(1))", ["ap","en","sap","first"] );
+ t( "Nth-child", "p:nth-child(1)", [ "firstp", "sndp" ] );
+ t( "Nth-child (with whitespace)", "p:nth-child( 1 )", [ "firstp", "sndp" ] );
+ t( "Nth-child (case-insensitive)", "#form select:first option:NTH-child(3)", [ "option1c" ] );
+ t( "Not nth-child", "#qunit-fixture p:not(:nth-child(1))", [ "ap", "en", "sap", "first" ] );
- t( "Nth-child(2)", "#qunit-fixture form#form > *:nth-child(2)", ["text1"] );
- t( "Nth-child(2)", "#qunit-fixture form#form > :nth-child(2)", ["text1"] );
+ t( "Nth-child(2)", "#qunit-fixture form#form > *:nth-child(2)", [ "text1" ] );
+ t( "Nth-child(2)", "#qunit-fixture form#form > :nth-child(2)", [ "text1" ] );
t( "Nth-child(-1)", "#form select:first option:nth-child(-1)", [] );
- t( "Nth-child(3)", "#form select:first option:nth-child(3)", ["option1c"] );
- t( "Nth-child(0n+3)", "#form select:first option:nth-child(0n+3)", ["option1c"] );
- t( "Nth-child(1n+0)", "#form select:first option:nth-child(1n+0)", ["option1a", "option1b", "option1c", "option1d"] );
- t( "Nth-child(1n)", "#form select:first option:nth-child(1n)", ["option1a", "option1b", "option1c", "option1d"] );
- t( "Nth-child(n)", "#form select:first option:nth-child(n)", ["option1a", "option1b", "option1c", "option1d"] );
- t( "Nth-child(even)", "#form select:first option:nth-child(even)", ["option1b", "option1d"] );
- t( "Nth-child(odd)", "#form select:first option:nth-child(odd)", ["option1a", "option1c"] );
- t( "Nth-child(2n)", "#form select:first option:nth-child(2n)", ["option1b", "option1d"] );
- t( "Nth-child(2n+1)", "#form select:first option:nth-child(2n+1)", ["option1a", "option1c"] );
- t( "Nth-child(2n + 1)", "#form select:first option:nth-child(2n + 1)", ["option1a", "option1c"] );
- t( "Nth-child(+2n + 1)", "#form select:first option:nth-child(+2n + 1)", ["option1a", "option1c"] );
- t( "Nth-child(3n)", "#form select:first option:nth-child(3n)", ["option1c"] );
- t( "Nth-child(3n+1)", "#form select:first option:nth-child(3n+1)", ["option1a", "option1d"] );
- t( "Nth-child(3n+2)", "#form select:first option:nth-child(3n+2)", ["option1b"] );
- t( "Nth-child(3n+3)", "#form select:first option:nth-child(3n+3)", ["option1c"] );
- t( "Nth-child(3n-1)", "#form select:first option:nth-child(3n-1)", ["option1b"] );
- t( "Nth-child(3n-2)", "#form select:first option:nth-child(3n-2)", ["option1a", "option1d"] );
- t( "Nth-child(3n-3)", "#form select:first option:nth-child(3n-3)", ["option1c"] );
- t( "Nth-child(3n+0)", "#form select:first option:nth-child(3n+0)", ["option1c"] );
- t( "Nth-child(-1n+3)", "#form select:first option:nth-child(-1n+3)", ["option1a", "option1b", "option1c"] );
- t( "Nth-child(-n+3)", "#form select:first option:nth-child(-n+3)", ["option1a", "option1b", "option1c"] );
- t( "Nth-child(-1n + 3)", "#form select:first option:nth-child(-1n + 3)", ["option1a", "option1b", "option1c"] );
+ t( "Nth-child(3)", "#form select:first option:nth-child(3)", [ "option1c" ] );
+ t( "Nth-child(0n+3)", "#form select:first option:nth-child(0n+3)", [ "option1c" ] );
+ t( "Nth-child(1n+0)", "#form select:first option:nth-child(1n+0)", [ "option1a", "option1b", "option1c", "option1d" ] );
+ t( "Nth-child(1n)", "#form select:first option:nth-child(1n)", [ "option1a", "option1b", "option1c", "option1d" ] );
+ t( "Nth-child(n)", "#form select:first option:nth-child(n)", [ "option1a", "option1b", "option1c", "option1d" ] );
+ t( "Nth-child(even)", "#form select:first option:nth-child(even)", [ "option1b", "option1d" ] );
+ t( "Nth-child(odd)", "#form select:first option:nth-child(odd)", [ "option1a", "option1c" ] );
+ t( "Nth-child(2n)", "#form select:first option:nth-child(2n)", [ "option1b", "option1d" ] );
+ t( "Nth-child(2n+1)", "#form select:first option:nth-child(2n+1)", [ "option1a", "option1c" ] );
+ t( "Nth-child(2n + 1)", "#form select:first option:nth-child(2n + 1)", [ "option1a", "option1c" ] );
+ t( "Nth-child(+2n + 1)", "#form select:first option:nth-child(+2n + 1)", [ "option1a", "option1c" ] );
+ t( "Nth-child(3n)", "#form select:first option:nth-child(3n)", [ "option1c" ] );
+ t( "Nth-child(3n+1)", "#form select:first option:nth-child(3n+1)", [ "option1a", "option1d" ] );
+ t( "Nth-child(3n+2)", "#form select:first option:nth-child(3n+2)", [ "option1b" ] );
+ t( "Nth-child(3n+3)", "#form select:first option:nth-child(3n+3)", [ "option1c" ] );
+ t( "Nth-child(3n-1)", "#form select:first option:nth-child(3n-1)", [ "option1b" ] );
+ t( "Nth-child(3n-2)", "#form select:first option:nth-child(3n-2)", [ "option1a", "option1d" ] );
+ t( "Nth-child(3n-3)", "#form select:first option:nth-child(3n-3)", [ "option1c" ] );
+ t( "Nth-child(3n+0)", "#form select:first option:nth-child(3n+0)", [ "option1c" ] );
+ t( "Nth-child(-1n+3)", "#form select:first option:nth-child(-1n+3)", [ "option1a", "option1b", "option1c" ] );
+ t( "Nth-child(-n+3)", "#form select:first option:nth-child(-n+3)", [ "option1a", "option1b", "option1c" ] );
+ t( "Nth-child(-1n + 3)", "#form select:first option:nth-child(-1n + 3)", [ "option1a", "option1b", "option1c" ] );
assert.deepEqual(
- Sizzle( ":nth-child(n)", null, null, [ document.createElement("a") ].concat( q("ap") ) ),
- q("ap"),
+ Sizzle( ":nth-child(n)", null, null, [ document.createElement( "a" ) ].concat( q( "ap" ) ) ),
+ q( "ap" ),
"Seeded nth-child"
);
-});
+} );
-QUnit.test("pseudo - nth-last-child", function( assert ) {
+QUnit.test( "pseudo - nth-last-child", function( assert ) {
assert.expect( 30 );
jQuery( "#qunit-fixture" ).append( "" );
- t( "Nth-last-child", "form:nth-last-child(5)", ["nth-last-child-form"] );
- t( "Nth-last-child (with whitespace)", "form:nth-last-child( 5 )", ["nth-last-child-form"] );
+ t( "Nth-last-child", "form:nth-last-child(5)", [ "nth-last-child-form" ] );
+ t( "Nth-last-child (with whitespace)", "form:nth-last-child( 5 )", [ "nth-last-child-form" ] );
- t( "Nth-last-child (case-insensitive)", "#form select:first option:NTH-last-child(3)", ["option1b"] );
- t( "Not nth-last-child", "#qunit-fixture p:not(:nth-last-child(1))", ["firstp", "ap", "sndp", "en", "first"] );
+ t( "Nth-last-child (case-insensitive)", "#form select:first option:NTH-last-child(3)", [ "option1b" ] );
+ t( "Not nth-last-child", "#qunit-fixture p:not(:nth-last-child(1))", [ "firstp", "ap", "sndp", "en", "first" ] );
t( "Nth-last-child(-1)", "#form select:first option:nth-last-child(-1)", [] );
- t( "Nth-last-child(3)", "#form select:first :nth-last-child(3)", ["option1b"] );
- t( "Nth-last-child(3)", "#form select:first *:nth-last-child(3)", ["option1b"] );
- t( "Nth-last-child(3)", "#form select:first option:nth-last-child(3)", ["option1b"] );
- t( "Nth-last-child(0n+3)", "#form select:first option:nth-last-child(0n+3)", ["option1b"] );
- t( "Nth-last-child(1n+0)", "#form select:first option:nth-last-child(1n+0)", ["option1a", "option1b", "option1c", "option1d"] );
- t( "Nth-last-child(1n)", "#form select:first option:nth-last-child(1n)", ["option1a", "option1b", "option1c", "option1d"] );
- t( "Nth-last-child(n)", "#form select:first option:nth-last-child(n)", ["option1a", "option1b", "option1c", "option1d"] );
- t( "Nth-last-child(even)", "#form select:first option:nth-last-child(even)", ["option1a", "option1c"] );
- t( "Nth-last-child(odd)", "#form select:first option:nth-last-child(odd)", ["option1b", "option1d"] );
- t( "Nth-last-child(2n)", "#form select:first option:nth-last-child(2n)", ["option1a", "option1c"] );
- t( "Nth-last-child(2n+1)", "#form select:first option:nth-last-child(2n+1)", ["option1b", "option1d"] );
- t( "Nth-last-child(2n + 1)", "#form select:first option:nth-last-child(2n + 1)", ["option1b", "option1d"] );
- t( "Nth-last-child(+2n + 1)", "#form select:first option:nth-last-child(+2n + 1)", ["option1b", "option1d"] );
- t( "Nth-last-child(3n)", "#form select:first option:nth-last-child(3n)", ["option1b"] );
- t( "Nth-last-child(3n+1)", "#form select:first option:nth-last-child(3n+1)", ["option1a", "option1d"] );
- t( "Nth-last-child(3n+2)", "#form select:first option:nth-last-child(3n+2)", ["option1c"] );
- t( "Nth-last-child(3n+3)", "#form select:first option:nth-last-child(3n+3)", ["option1b"] );
- t( "Nth-last-child(3n-1)", "#form select:first option:nth-last-child(3n-1)", ["option1c"] );
- t( "Nth-last-child(3n-2)", "#form select:first option:nth-last-child(3n-2)", ["option1a", "option1d"] );
- t( "Nth-last-child(3n-3)", "#form select:first option:nth-last-child(3n-3)", ["option1b"] );
- t( "Nth-last-child(3n+0)", "#form select:first option:nth-last-child(3n+0)", ["option1b"] );
- t( "Nth-last-child(-1n+3)", "#form select:first option:nth-last-child(-1n+3)", ["option1b", "option1c", "option1d"] );
- t( "Nth-last-child(-n+3)", "#form select:first option:nth-last-child(-n+3)", ["option1b", "option1c", "option1d"] );
- t( "Nth-last-child(-1n + 3)", "#form select:first option:nth-last-child(-1n + 3)", ["option1b", "option1c", "option1d"] );
+ t( "Nth-last-child(3)", "#form select:first :nth-last-child(3)", [ "option1b" ] );
+ t( "Nth-last-child(3)", "#form select:first *:nth-last-child(3)", [ "option1b" ] );
+ t( "Nth-last-child(3)", "#form select:first option:nth-last-child(3)", [ "option1b" ] );
+ t( "Nth-last-child(0n+3)", "#form select:first option:nth-last-child(0n+3)", [ "option1b" ] );
+ t( "Nth-last-child(1n+0)", "#form select:first option:nth-last-child(1n+0)", [ "option1a", "option1b", "option1c", "option1d" ] );
+ t( "Nth-last-child(1n)", "#form select:first option:nth-last-child(1n)", [ "option1a", "option1b", "option1c", "option1d" ] );
+ t( "Nth-last-child(n)", "#form select:first option:nth-last-child(n)", [ "option1a", "option1b", "option1c", "option1d" ] );
+ t( "Nth-last-child(even)", "#form select:first option:nth-last-child(even)", [ "option1a", "option1c" ] );
+ t( "Nth-last-child(odd)", "#form select:first option:nth-last-child(odd)", [ "option1b", "option1d" ] );
+ t( "Nth-last-child(2n)", "#form select:first option:nth-last-child(2n)", [ "option1a", "option1c" ] );
+ t( "Nth-last-child(2n+1)", "#form select:first option:nth-last-child(2n+1)", [ "option1b", "option1d" ] );
+ t( "Nth-last-child(2n + 1)", "#form select:first option:nth-last-child(2n + 1)", [ "option1b", "option1d" ] );
+ t( "Nth-last-child(+2n + 1)", "#form select:first option:nth-last-child(+2n + 1)", [ "option1b", "option1d" ] );
+ t( "Nth-last-child(3n)", "#form select:first option:nth-last-child(3n)", [ "option1b" ] );
+ t( "Nth-last-child(3n+1)", "#form select:first option:nth-last-child(3n+1)", [ "option1a", "option1d" ] );
+ t( "Nth-last-child(3n+2)", "#form select:first option:nth-last-child(3n+2)", [ "option1c" ] );
+ t( "Nth-last-child(3n+3)", "#form select:first option:nth-last-child(3n+3)", [ "option1b" ] );
+ t( "Nth-last-child(3n-1)", "#form select:first option:nth-last-child(3n-1)", [ "option1c" ] );
+ t( "Nth-last-child(3n-2)", "#form select:first option:nth-last-child(3n-2)", [ "option1a", "option1d" ] );
+ t( "Nth-last-child(3n-3)", "#form select:first option:nth-last-child(3n-3)", [ "option1b" ] );
+ t( "Nth-last-child(3n+0)", "#form select:first option:nth-last-child(3n+0)", [ "option1b" ] );
+ t( "Nth-last-child(-1n+3)", "#form select:first option:nth-last-child(-1n+3)", [ "option1b", "option1c", "option1d" ] );
+ t( "Nth-last-child(-n+3)", "#form select:first option:nth-last-child(-n+3)", [ "option1b", "option1c", "option1d" ] );
+ t( "Nth-last-child(-1n + 3)", "#form select:first option:nth-last-child(-1n + 3)", [ "option1b", "option1c", "option1d" ] );
QUnit.deepEqual(
Sizzle(
":nth-last-child(n)",
null,
null,
- [ document.createElement("a") ].concat( q("ap") )
+ [ document.createElement( "a" ) ].concat( q( "ap" ) )
),
- q("ap"),
+ q( "ap" ),
"Seeded nth-last-child"
);
-});
+} );
-QUnit.test("pseudo - nth-of-type", function( assert ) {
+QUnit.test( "pseudo - nth-of-type", function( assert ) {
assert.expect( 9 );
t( "Nth-of-type(-1)", ":nth-of-type(-1)", [] );
- t( "Nth-of-type(3)", "#ap :nth-of-type(3)", ["mark"] );
- t( "Nth-of-type(n)", "#ap :nth-of-type(n)", ["google", "groups", "code1", "anchor1", "mark"] );
- t( "Nth-of-type(0n+3)", "#ap :nth-of-type(0n+3)", ["mark"] );
- t( "Nth-of-type(2n)", "#ap :nth-of-type(2n)", ["groups"] );
- t( "Nth-of-type(even)", "#ap :nth-of-type(even)", ["groups"] );
- t( "Nth-of-type(2n+1)", "#ap :nth-of-type(2n+1)", ["google", "code1", "anchor1", "mark"] );
- t( "Nth-of-type(odd)", "#ap :nth-of-type(odd)", ["google", "code1", "anchor1", "mark"] );
- t( "Nth-of-type(-n+2)", "#qunit-fixture > :nth-of-type(-n+2)", ["firstp", "ap", "foo", "nothiddendiv", "name+value", "firstUL", "empty", "form", "floatTest", "iframe", "lengthtest", "table", "last"] );
-});
-
-QUnit.test("pseudo - nth-last-of-type", function( assert ) {
+ t( "Nth-of-type(3)", "#ap :nth-of-type(3)", [ "mark" ] );
+ t( "Nth-of-type(n)", "#ap :nth-of-type(n)", [ "google", "groups", "code1", "anchor1", "mark" ] );
+ t( "Nth-of-type(0n+3)", "#ap :nth-of-type(0n+3)", [ "mark" ] );
+ t( "Nth-of-type(2n)", "#ap :nth-of-type(2n)", [ "groups" ] );
+ t( "Nth-of-type(even)", "#ap :nth-of-type(even)", [ "groups" ] );
+ t( "Nth-of-type(2n+1)", "#ap :nth-of-type(2n+1)", [ "google", "code1", "anchor1", "mark" ] );
+ t( "Nth-of-type(odd)", "#ap :nth-of-type(odd)", [ "google", "code1", "anchor1", "mark" ] );
+ t( "Nth-of-type(-n+2)", "#qunit-fixture > :nth-of-type(-n+2)", [ "firstp", "ap", "foo", "nothiddendiv", "name+value", "firstUL", "empty", "form", "floatTest", "iframe", "lengthtest", "table", "last" ] );
+} );
+
+QUnit.test( "pseudo - nth-last-of-type", function( assert ) {
assert.expect( 9 );
t( "Nth-last-of-type(-1)", ":nth-last-of-type(-1)", [] );
- t( "Nth-last-of-type(3)", "#ap :nth-last-of-type(3)", ["google"] );
- t( "Nth-last-of-type(n)", "#ap :nth-last-of-type(n)", ["google", "groups", "code1", "anchor1", "mark"] );
- t( "Nth-last-of-type(0n+3)", "#ap :nth-last-of-type(0n+3)", ["google"] );
- t( "Nth-last-of-type(2n)", "#ap :nth-last-of-type(2n)", ["groups"] );
- t( "Nth-last-of-type(even)", "#ap :nth-last-of-type(even)", ["groups"] );
- t( "Nth-last-of-type(2n+1)", "#ap :nth-last-of-type(2n+1)", ["google", "code1", "anchor1", "mark"] );
- t( "Nth-last-of-type(odd)", "#ap :nth-last-of-type(odd)", ["google", "code1", "anchor1", "mark"] );
- t( "Nth-last-of-type(-n+2)", "#qunit-fixture > :nth-last-of-type(-n+2)", ["ap", "name+value", "first", "firstUL", "empty", "floatTest", "iframe", "table", "testForm", "liveHandlerOrder", "disabled-tests", "siblingTest", "last"] );
-});
-
-QUnit.test("pseudo - has", function( assert ) {
+ t( "Nth-last-of-type(3)", "#ap :nth-last-of-type(3)", [ "google" ] );
+ t( "Nth-last-of-type(n)", "#ap :nth-last-of-type(n)", [ "google", "groups", "code1", "anchor1", "mark" ] );
+ t( "Nth-last-of-type(0n+3)", "#ap :nth-last-of-type(0n+3)", [ "google" ] );
+ t( "Nth-last-of-type(2n)", "#ap :nth-last-of-type(2n)", [ "groups" ] );
+ t( "Nth-last-of-type(even)", "#ap :nth-last-of-type(even)", [ "groups" ] );
+ t( "Nth-last-of-type(2n+1)", "#ap :nth-last-of-type(2n+1)", [ "google", "code1", "anchor1", "mark" ] );
+ t( "Nth-last-of-type(odd)", "#ap :nth-last-of-type(odd)", [ "google", "code1", "anchor1", "mark" ] );
+ t( "Nth-last-of-type(-n+2)", "#qunit-fixture > :nth-last-of-type(-n+2)", [ "ap", "name+value", "first", "firstUL", "empty", "floatTest", "iframe", "table", "testForm", "liveHandlerOrder", "disabled-tests", "siblingTest", "last" ] );
+} );
+
+QUnit.test( "pseudo - has", function( assert ) {
assert.expect( 3 );
- t( "Basic test", "p:has(a)", ["firstp","ap","en","sap"] );
- t( "Basic test (irrelevant whitespace)", "p:has( a )", ["firstp","ap","en","sap"] );
+ t( "Basic test", "p:has(a)", [ "firstp", "ap", "en", "sap" ] );
+ t( "Basic test (irrelevant whitespace)", "p:has( a )", [ "firstp", "ap", "en", "sap" ] );
t( "Nested with overlapping candidates", "#qunit-fixture div:has(div:has(div:not([id])))", [ "moretests", "t2037" ] );
-});
+} );
-QUnit.test("pseudo - contains", function( assert ) {
+QUnit.test( "pseudo - contains", function( assert ) {
assert.expect( 9 );
var gh335 = document.getElementById( "qunit-fixture" ).appendChild(
@@ -838,39 +838,39 @@ QUnit.test("pseudo - contains", function( assert ) {
gh335.id = "gh-335";
gh335.appendChild( document.createTextNode( "raw line 1\nline 2" ) );
- assert.ok( Sizzle("a:contains('')").length, "empty string" );
- t( "unquoted argument", "a:contains(Google)", ["google","groups"] );
- t( "unquoted argument with whitespace", "a:contains(Google Groups)", ["groups"] );
+ assert.ok( Sizzle( "a:contains('')" ).length, "empty string" );
+ t( "unquoted argument", "a:contains(Google)", [ "google", "groups" ] );
+ t( "unquoted argument with whitespace", "a:contains(Google Groups)", [ "groups" ] );
t( "quoted argument with whitespace and parentheses",
- "a:contains('Google Groups (Link)')", ["groups"] );
+ "a:contains('Google Groups (Link)')", [ "groups" ] );
t( "quoted argument with double quotes and parentheses",
- "a:contains(\"(Link)\")", ["groups"] );
+ "a:contains(\"(Link)\")", [ "groups" ] );
t( "unquoted argument with whitespace and paired parentheses",
- "a:contains(Google Groups (Link))", ["groups"] );
- t( "unquoted argument with paired parentheses", "a:contains((Link))", ["groups"] );
+ "a:contains(Google Groups (Link))", [ "groups" ] );
+ t( "unquoted argument with paired parentheses", "a:contains((Link))", [ "groups" ] );
t( "quoted argument with CSS escapes",
"span:contains(\"\\\"'\\53F0 \\5317 Ta\\301 ibe\\30C i\")",
- ["utf8class1"] );
+ [ "utf8class1" ] );
- t( "collapsed whitespace", "mark:contains('line 1\\A line')", ["gh-335"] );
-});
+ t( "collapsed whitespace", "mark:contains('line 1\\A line')", [ "gh-335" ] );
+} );
-QUnit.test("pseudo - misc", function( assert ) {
+QUnit.test( "pseudo - misc", function( assert ) {
assert.expect( 32 );
var select, tmp, input;
jQuery( "" ).prependTo( "#qunit-fixture" );
- t( "Headers", "#qunit-fixture :header", ["h1", "h2", "h2-2"] );
- t( "Headers(case-insensitive)", "#qunit-fixture :Header", ["h1", "h2", "h2-2"] );
- t( "Multiple matches with the same context (cache check)", "#form select:has(option:first-child:contains('o'))", ["select1", "select2", "select3", "select4"] );
+ t( "Headers", "#qunit-fixture :header", [ "h1", "h2", "h2-2" ] );
+ t( "Headers(case-insensitive)", "#qunit-fixture :Header", [ "h1", "h2", "h2-2" ] );
+ t( "Multiple matches with the same context (cache check)", "#form select:has(option:first-child:contains('o'))", [ "select1", "select2", "select3", "select4" ] );
- assert.ok( Sizzle("#qunit-fixture :not(:has(:has(*)))").length, "All not grandparents" );
+ assert.ok( Sizzle( "#qunit-fixture :not(:has(:has(*)))" ).length, "All not grandparents" );
- select = document.getElementById("select1");
+ select = document.getElementById( "select1" );
assert.ok( Sizzle.matchesSelector( select, ":has(option)" ), "Has Option Matches" );
- tmp = document.createElement("div");
+ tmp = document.createElement( "div" );
tmp.id = "tmp_input";
document.body.appendChild( tmp );
@@ -882,14 +882,14 @@ QUnit.test("pseudo - misc", function( assert ) {
t( "Input Buttons :" + type, "#tmp_input :" + type, [ "input_" + type, "button_" + type ] );
- assert.ok( Sizzle.matchesSelector( els[0], ":" + type ), "Input Matches :" + type );
- assert.ok( Sizzle.matchesSelector( els[1], ":" + type ), "Button Matches :" + type );
- });
+ assert.ok( Sizzle.matchesSelector( els[ 0 ], ":" + type ), "Input Matches :" + type );
+ assert.ok( Sizzle.matchesSelector( els[ 1 ], ":" + type ), "Button Matches :" + type );
+ } );
document.body.removeChild( tmp );
// Recreate tmp
- tmp = document.createElement("div");
+ tmp = document.createElement( "div" );
tmp.id = "tmp_input";
tmp.innerHTML = "Hello I am focusable.";
// Setting tabIndex should make the element focusable
@@ -897,8 +897,8 @@ QUnit.test("pseudo - misc", function( assert ) {
document.body.appendChild( tmp );
tmp.tabIndex = 0;
tmp.focus();
- if ( document.activeElement !== tmp || (document.hasFocus && !document.hasFocus()) ||
- (document.querySelectorAll && !document.querySelectorAll("div:focus").length) ) {
+ if ( document.activeElement !== tmp || ( document.hasFocus && !document.hasFocus() ) ||
+ ( document.querySelectorAll && !document.querySelectorAll( "div:focus" ).length ) ) {
assert.ok( true, "The div was not focused. Skip checking the :focus match." );
assert.ok( true, "The div was not focused. Skip checking the :focus match." );
} else {
@@ -913,7 +913,7 @@ QUnit.test("pseudo - misc", function( assert ) {
document.body.removeChild( tmp );
// Input focus/active
- input = document.createElement("input");
+ input = document.createElement( "input" );
input.type = "text";
input.id = "focus-input";
@@ -921,8 +921,8 @@ QUnit.test("pseudo - misc", function( assert ) {
input.focus();
// Inputs can't be focused unless the document has focus
- if ( document.activeElement !== input || (document.hasFocus && !document.hasFocus()) ||
- (document.querySelectorAll && !document.querySelectorAll("input:focus").length) ) {
+ if ( document.activeElement !== input || ( document.hasFocus && !document.hasFocus() ) ||
+ ( document.querySelectorAll && !document.querySelectorAll( "input:focus" ).length ) ) {
assert.ok( true, "The input was not focused. Skip checking the :focus match." );
assert.ok( true, "The input was not focused. Skip checking the :focus match." );
} else {
@@ -941,149 +941,148 @@ QUnit.test("pseudo - misc", function( assert ) {
document.body.removeChild( input );
-
assert.deepEqual(
- Sizzle( "[id='select1'] *:not(:last-child), [id='select2'] *:not(:last-child)", q("qunit-fixture")[0] ),
+ Sizzle( "[id='select1'] *:not(:last-child), [id='select2'] *:not(:last-child)", q( "qunit-fixture" )[ 0 ] ),
q( "option1a", "option1b", "option1c", "option2a", "option2b", "option2c" ),
"caching system tolerates recursive selection"
);
// Tokenization edge cases
- t( "Sequential pseudos", "#qunit-fixture p:has(:contains(mark)):has(code)", ["ap"] );
- t( "Sequential pseudos", "#qunit-fixture p:has(:contains(mark)):has(code):contains(This link)", ["ap"] );
+ t( "Sequential pseudos", "#qunit-fixture p:has(:contains(mark)):has(code)", [ "ap" ] );
+ t( "Sequential pseudos", "#qunit-fixture p:has(:contains(mark)):has(code):contains(This link)", [ "ap" ] );
- t( "Pseudo argument containing ')'", "p:has(>a.GROUPS[src!=')'])", ["ap"] );
- t( "Pseudo argument containing ')'", "p:has(>a.GROUPS[src!=')'])", ["ap"] );
- t( "Pseudo followed by token containing ')'", "p:contains(id=\"foo\")[id!=\\)]", ["sndp"] );
- t( "Pseudo followed by token containing ')'", "p:contains(id=\"foo\")[id!=')']", ["sndp"] );
+ t( "Pseudo argument containing ')'", "p:has(>a.GROUPS[src!=')'])", [ "ap" ] );
+ t( "Pseudo argument containing ')'", "p:has(>a.GROUPS[src!=')'])", [ "ap" ] );
+ t( "Pseudo followed by token containing ')'", "p:contains(id=\"foo\")[id!=\\)]", [ "sndp" ] );
+ t( "Pseudo followed by token containing ')'", "p:contains(id=\"foo\")[id!=')']", [ "sndp" ] );
- t( "Multi-pseudo", "#ap:has(*), #ap:has(*)", ["ap"] );
- t( "Multi-positional", "#ap:gt(0), #ap:lt(1)", ["ap"] );
- t( "Multi-pseudo with leading nonexistent id", "#nonexistent:has(*), #ap:has(*)", ["ap"] );
- t( "Multi-positional with leading nonexistent id", "#nonexistent:gt(0), #ap:lt(1)", ["ap"] );
+ t( "Multi-pseudo", "#ap:has(*), #ap:has(*)", [ "ap" ] );
+ t( "Multi-positional", "#ap:gt(0), #ap:lt(1)", [ "ap" ] );
+ t( "Multi-pseudo with leading nonexistent id", "#nonexistent:has(*), #ap:has(*)", [ "ap" ] );
+ t( "Multi-positional with leading nonexistent id", "#nonexistent:gt(0), #ap:lt(1)", [ "ap" ] );
- t( "Tokenization stressor", "a[class*=blog]:not(:has(*, :contains(!)), :contains(!)), br:contains(]), p:contains(]), :not(:empty):not(:parent)", ["ap", "mark","yahoo","simon"] );
-});
+ t( "Tokenization stressor", "a[class*=blog]:not(:has(*, :contains(!)), :contains(!)), br:contains(]), p:contains(]), :not(:empty):not(:parent)", [ "ap", "mark", "yahoo", "simon" ] );
+} );
-QUnit.test("pseudo - :not", function( assert ) {
+QUnit.test( "pseudo - :not", function( assert ) {
assert.expect( 43 );
- t( "Not", "a.blog:not(.link)", ["mark"] );
- t( ":not() with :first", "#foo p:not(:first) .link", ["simon"] );
+ t( "Not", "a.blog:not(.link)", [ "mark" ] );
+ t( ":not() with :first", "#foo p:not(:first) .link", [ "simon" ] );
- t( "Not - multiple", "#form option:not(:contains(Nothing),#option1b,:selected)", ["option1c", "option1d", "option2b", "option2c", "option3d", "option3e", "option4e", "option5b", "option5c"] );
- t( "Not - recursive", "#form option:not(:not(:selected))[id^='option3']", [ "option3b", "option3c"] );
+ t( "Not - multiple", "#form option:not(:contains(Nothing),#option1b,:selected)", [ "option1c", "option1d", "option2b", "option2c", "option3d", "option3e", "option4e", "option5b", "option5c" ] );
+ t( "Not - recursive", "#form option:not(:not(:selected))[id^='option3']", [ "option3b", "option3c" ] );
- t( ":not() failing interior", "#qunit-fixture p:not(.foo)", ["firstp","ap","sndp","en","sap","first"] );
- t( ":not() failing interior", "#qunit-fixture p:not(div.foo)", ["firstp","ap","sndp","en","sap","first"] );
- t( ":not() failing interior", "#qunit-fixture p:not(p.foo)", ["firstp","ap","sndp","en","sap","first"] );
- t( ":not() failing interior", "#qunit-fixture p:not(#blargh)", ["firstp","ap","sndp","en","sap","first"] );
- t( ":not() failing interior", "#qunit-fixture p:not(div#blargh)", ["firstp","ap","sndp","en","sap","first"] );
- t( ":not() failing interior", "#qunit-fixture p:not(p#blargh)", ["firstp","ap","sndp","en","sap","first"] );
+ t( ":not() failing interior", "#qunit-fixture p:not(.foo)", [ "firstp", "ap", "sndp", "en", "sap", "first" ] );
+ t( ":not() failing interior", "#qunit-fixture p:not(div.foo)", [ "firstp", "ap", "sndp", "en", "sap", "first" ] );
+ t( ":not() failing interior", "#qunit-fixture p:not(p.foo)", [ "firstp", "ap", "sndp", "en", "sap", "first" ] );
+ t( ":not() failing interior", "#qunit-fixture p:not(#blargh)", [ "firstp", "ap", "sndp", "en", "sap", "first" ] );
+ t( ":not() failing interior", "#qunit-fixture p:not(div#blargh)", [ "firstp", "ap", "sndp", "en", "sap", "first" ] );
+ t( ":not() failing interior", "#qunit-fixture p:not(p#blargh)", [ "firstp", "ap", "sndp", "en", "sap", "first" ] );
- t( ":not Multiple", "#qunit-fixture p:not(a)", ["firstp","ap","sndp","en","sap","first"] );
- t( ":not Multiple", "#qunit-fixture p:not( a )", ["firstp","ap","sndp","en","sap","first"] );
+ t( ":not Multiple", "#qunit-fixture p:not(a)", [ "firstp", "ap", "sndp", "en", "sap", "first" ] );
+ t( ":not Multiple", "#qunit-fixture p:not( a )", [ "firstp", "ap", "sndp", "en", "sap", "first" ] );
t( ":not Multiple", "#qunit-fixture p:not( p )", [] );
- t( ":not Multiple", "#qunit-fixture p:not(a, b)", ["firstp","ap","sndp","en","sap","first"] );
- t( ":not Multiple", "#qunit-fixture p:not(a, b, div)", ["firstp","ap","sndp","en","sap","first"] );
+ t( ":not Multiple", "#qunit-fixture p:not(a, b)", [ "firstp", "ap", "sndp", "en", "sap", "first" ] );
+ t( ":not Multiple", "#qunit-fixture p:not(a, b, div)", [ "firstp", "ap", "sndp", "en", "sap", "first" ] );
t( ":not Multiple", "p:not(p)", [] );
t( ":not Multiple", "p:not(a,p)", [] );
t( ":not Multiple", "p:not(p,a)", [] );
t( ":not Multiple", "p:not(a,p,b)", [] );
t( ":not Multiple", ":input:not(:image,:input,:submit)", [] );
- t( ":not Multiple", "#qunit-fixture p:not(:has(a), :nth-child(1))", ["first"] );
+ t( ":not Multiple", "#qunit-fixture p:not(:has(a), :nth-child(1))", [ "first" ] );
t( "No element not selector", ".container div:not(.excluded) div", [] );
- t( ":not() Existing attribute", "#form select:not([multiple])", ["select1", "select2", "select5"]);
- t( ":not() Equals attribute", "#form select:not([name=select1])", ["select2", "select3", "select4","select5"]);
- t( ":not() Equals quoted attribute", "#form select:not([name='select1'])", ["select2", "select3", "select4", "select5"]);
+ t( ":not() Existing attribute", "#form select:not([multiple])", [ "select1", "select2", "select5" ] );
+ t( ":not() Equals attribute", "#form select:not([name=select1])", [ "select2", "select3", "select4", "select5" ] );
+ t( ":not() Equals quoted attribute", "#form select:not([name='select1'])", [ "select2", "select3", "select4", "select5" ] );
- t( ":not() Multiple Class", "#foo a:not(.blog)", ["yahoo", "anchor2"] );
- t( ":not() Multiple Class", "#foo a:not(.link)", ["yahoo", "anchor2"] );
- t( ":not() Multiple Class", "#foo a:not(.blog.link)", ["yahoo", "anchor2"] );
+ t( ":not() Multiple Class", "#foo a:not(.blog)", [ "yahoo", "anchor2" ] );
+ t( ":not() Multiple Class", "#foo a:not(.link)", [ "yahoo", "anchor2" ] );
+ t( ":not() Multiple Class", "#foo a:not(.blog.link)", [ "yahoo", "anchor2" ] );
- t( ":not chaining (compound)", "#qunit-fixture div[id]:not(:has(div, span)):not(:has(*))", ["nothiddendivchild", "divWithNoTabIndex"] );
- t( ":not chaining (with attribute)", "#qunit-fixture form[id]:not([action$='formaction']):not(:button)", ["lengthtest", "name-tests", "testForm", "disabled-tests"] );
- t( ":not chaining (colon in attribute)", "#qunit-fixture form[id]:not([action='form:action']):not(:button)", ["form", "lengthtest", "name-tests", "testForm", "disabled-tests"] );
- t( ":not chaining (colon in attribute and nested chaining)", "#qunit-fixture form[id]:not([action='form:action']:button):not(:input)", ["form", "lengthtest", "name-tests", "testForm", "disabled-tests"] );
+ t( ":not chaining (compound)", "#qunit-fixture div[id]:not(:has(div, span)):not(:has(*))", [ "nothiddendivchild", "divWithNoTabIndex" ] );
+ t( ":not chaining (with attribute)", "#qunit-fixture form[id]:not([action$='formaction']):not(:button)", [ "lengthtest", "name-tests", "testForm", "disabled-tests" ] );
+ t( ":not chaining (colon in attribute)", "#qunit-fixture form[id]:not([action='form:action']):not(:button)", [ "form", "lengthtest", "name-tests", "testForm", "disabled-tests" ] );
+ t( ":not chaining (colon in attribute and nested chaining)", "#qunit-fixture form[id]:not([action='form:action']:button):not(:input)", [ "form", "lengthtest", "name-tests", "testForm", "disabled-tests" ] );
t( ":not chaining", "#form select:not(.select1):contains(Nothing) > option:not(option)", [] );
- t( "positional :not()", "#foo p:not(:last)", ["sndp", "en"] );
- t( "positional :not() prefix", "#foo p:not(:last) a", ["yahoo"] );
- t( "compound positional :not()", "#foo p:not(:first, :last)", ["en"] );
- t( "compound positional :not()", "#foo p:not(:first, :even)", ["en"] );
- t( "compound positional :not()", "#foo p:not(:first, :odd)", ["sap"] );
- t( "reordered compound positional :not()", "#foo p:not(:odd, :first)", ["sap"] );
-
- t( "positional :not() with pre-filter", "#foo p:not([id]:first)", ["en", "sap"] );
- t( "positional :not() with post-filter", "#foo p:not(:first[id])", ["en", "sap"] );
- t( "positional :not() with pre-filter", "#foo p:not([lang]:first)", ["sndp", "sap"] );
- t( "positional :not() with post-filter", "#foo p:not(:first[lang])", ["sndp", "en", "sap"] );
-});
+ t( "positional :not()", "#foo p:not(:last)", [ "sndp", "en" ] );
+ t( "positional :not() prefix", "#foo p:not(:last) a", [ "yahoo" ] );
+ t( "compound positional :not()", "#foo p:not(:first, :last)", [ "en" ] );
+ t( "compound positional :not()", "#foo p:not(:first, :even)", [ "en" ] );
+ t( "compound positional :not()", "#foo p:not(:first, :odd)", [ "sap" ] );
+ t( "reordered compound positional :not()", "#foo p:not(:odd, :first)", [ "sap" ] );
+
+ t( "positional :not() with pre-filter", "#foo p:not([id]:first)", [ "en", "sap" ] );
+ t( "positional :not() with post-filter", "#foo p:not(:first[id])", [ "en", "sap" ] );
+ t( "positional :not() with pre-filter", "#foo p:not([lang]:first)", [ "sndp", "sap" ] );
+ t( "positional :not() with post-filter", "#foo p:not(:first[lang])", [ "sndp", "en", "sap" ] );
+} );
-QUnit.test("pseudo - position", function( assert ) {
+QUnit.test( "pseudo - position", function( assert ) {
assert.expect( 34 );
- t( "First element", "#qunit-fixture p:first", ["firstp"] );
- t( "First element(case-insensitive)", "#qunit-fixture p:fiRst", ["firstp"] );
- t( "nth Element", "#qunit-fixture p:nth(1)", ["ap"] );
- t( "First Element", "#qunit-fixture p:first", ["firstp"] );
- t( "Last Element", "p:last", ["first"] );
- t( "Even Elements", "#qunit-fixture p:even", ["firstp","sndp","sap"] );
- t( "Odd Elements", "#qunit-fixture p:odd", ["ap","en","first"] );
- t( "Position Equals", "#qunit-fixture p:eq(1)", ["ap"] );
- t( "Position Equals (negative)", "#qunit-fixture p:eq(-1)", ["first"] );
- t( "Position Greater Than", "#qunit-fixture p:gt(0)", ["ap","sndp","en","sap","first"] );
- t( "Position Less Than", "#qunit-fixture p:lt(3)", ["firstp","ap","sndp"] );
- t( "Position Less Than Big Number", "#qunit-fixture p:lt(9007199254740991)", ["firstp","ap","sndp","en","sap","first"] );
-
- t( "Check position filtering", "div#nothiddendiv:eq(0)", ["nothiddendiv"] );
- t( "Check position filtering", "div#nothiddendiv:last", ["nothiddendiv"] );
- t( "Check position filtering", "div#nothiddendiv:not(:gt(0))", ["nothiddendiv"] );
- t( "Check position filtering", "#foo > :not(:first)", ["en", "sap"] );
- t( "Check position filtering", "#qunit-fixture select > :not(:gt(2))", ["option1a", "option1b", "option1c"] );
- t( "Check position filtering", "#qunit-fixture select:lt(2) :not(:first)", ["option1b", "option1c", "option1d", "option2a", "option2b", "option2c", "option2d"] );
- t( "Check position filtering", "div.nothiddendiv:eq(0)", ["nothiddendiv"] );
- t( "Check position filtering", "div.nothiddendiv:last", ["nothiddendiv"] );
- t( "Check position filtering", "div.nothiddendiv:not(:lt(0))", ["nothiddendiv"] );
-
- t( "Check element position", "#qunit-fixture div div:eq(0)", ["nothiddendivchild"] );
- t( "Check element position", "#select1 option:eq(3)", ["option1d"] );
- t( "Check element position", "#qunit-fixture div div:eq(10)", ["names-group"] );
- t( "Check element position", "#qunit-fixture div div:first", ["nothiddendivchild"] );
- t( "Check element position", "#qunit-fixture div > div:first", ["nothiddendivchild"] );
- t( "Check element position", "#qunit-fixture div:first a:first", ["yahoo"] );
- t( "Check element position", "#qunit-fixture div:first > p:first", ["sndp"] );
- t( "Check element position", "div#nothiddendiv:first > div:first", ["nothiddendivchild"] );
- t( "Chained pseudo after a pos pseudo", "#listWithTabIndex li:eq(0):contains(Rice)", ["foodWithNegativeTabIndex"] );
-
- t( "Check sort order with POS and comma", "#qunit-fixture em>em>em>em:first-child,div>em:first", ["siblingfirst", "siblinggreatgrandchild"] );
-
- t( "Isolated position", "#qunit-fixture :last", ["last"] );
-
- assert.deepEqual( Sizzle( "*:lt(2) + *", null, [], Sizzle("#qunit-fixture > p") ), q("ap"),
+ t( "First element", "#qunit-fixture p:first", [ "firstp" ] );
+ t( "First element(case-insensitive)", "#qunit-fixture p:fiRst", [ "firstp" ] );
+ t( "nth Element", "#qunit-fixture p:nth(1)", [ "ap" ] );
+ t( "First Element", "#qunit-fixture p:first", [ "firstp" ] );
+ t( "Last Element", "p:last", [ "first" ] );
+ t( "Even Elements", "#qunit-fixture p:even", [ "firstp", "sndp", "sap" ] );
+ t( "Odd Elements", "#qunit-fixture p:odd", [ "ap", "en", "first" ] );
+ t( "Position Equals", "#qunit-fixture p:eq(1)", [ "ap" ] );
+ t( "Position Equals (negative)", "#qunit-fixture p:eq(-1)", [ "first" ] );
+ t( "Position Greater Than", "#qunit-fixture p:gt(0)", [ "ap", "sndp", "en", "sap", "first" ] );
+ t( "Position Less Than", "#qunit-fixture p:lt(3)", [ "firstp", "ap", "sndp" ] );
+ t( "Position Less Than Big Number", "#qunit-fixture p:lt(9007199254740991)", [ "firstp", "ap", "sndp", "en", "sap", "first" ] );
+
+ t( "Check position filtering", "div#nothiddendiv:eq(0)", [ "nothiddendiv" ] );
+ t( "Check position filtering", "div#nothiddendiv:last", [ "nothiddendiv" ] );
+ t( "Check position filtering", "div#nothiddendiv:not(:gt(0))", [ "nothiddendiv" ] );
+ t( "Check position filtering", "#foo > :not(:first)", [ "en", "sap" ] );
+ t( "Check position filtering", "#qunit-fixture select > :not(:gt(2))", [ "option1a", "option1b", "option1c" ] );
+ t( "Check position filtering", "#qunit-fixture select:lt(2) :not(:first)", [ "option1b", "option1c", "option1d", "option2a", "option2b", "option2c", "option2d" ] );
+ t( "Check position filtering", "div.nothiddendiv:eq(0)", [ "nothiddendiv" ] );
+ t( "Check position filtering", "div.nothiddendiv:last", [ "nothiddendiv" ] );
+ t( "Check position filtering", "div.nothiddendiv:not(:lt(0))", [ "nothiddendiv" ] );
+
+ t( "Check element position", "#qunit-fixture div div:eq(0)", [ "nothiddendivchild" ] );
+ t( "Check element position", "#select1 option:eq(3)", [ "option1d" ] );
+ t( "Check element position", "#qunit-fixture div div:eq(10)", [ "names-group" ] );
+ t( "Check element position", "#qunit-fixture div div:first", [ "nothiddendivchild" ] );
+ t( "Check element position", "#qunit-fixture div > div:first", [ "nothiddendivchild" ] );
+ t( "Check element position", "#qunit-fixture div:first a:first", [ "yahoo" ] );
+ t( "Check element position", "#qunit-fixture div:first > p:first", [ "sndp" ] );
+ t( "Check element position", "div#nothiddendiv:first > div:first", [ "nothiddendivchild" ] );
+ t( "Chained pseudo after a pos pseudo", "#listWithTabIndex li:eq(0):contains(Rice)", [ "foodWithNegativeTabIndex" ] );
+
+ t( "Check sort order with POS and comma", "#qunit-fixture em>em>em>em:first-child,div>em:first", [ "siblingfirst", "siblinggreatgrandchild" ] );
+
+ t( "Isolated position", "#qunit-fixture :last", [ "last" ] );
+
+ assert.deepEqual( Sizzle( "*:lt(2) + *", null, [], Sizzle( "#qunit-fixture > p" ) ), q( "ap" ),
"Seeded pos with trailing relative" );
// jQuery #12526
- var context = jQuery("#qunit-fixture").append("")[0];
- assert.deepEqual( Sizzle( ":last", context ), q("jquery12526"),
+ var context = jQuery( "#qunit-fixture" ).append( "" )[ 0 ];
+ assert.deepEqual( Sizzle( ":last", context ), q( "jquery12526" ),
"Post-manipulation positional" );
-});
+} );
-QUnit.test("pseudo - form", function( assert ) {
+QUnit.test( "pseudo - form", function( assert ) {
assert.expect( 10 );
- var extraTexts = jQuery("").appendTo("#form");
+ var extraTexts = jQuery( "" ).appendTo( "#form" );
- t( "Form element :input", "#form :input", ["text1", "text2", "radio1", "radio2", "check1", "check2", "hidden1", "hidden2", "name", "search", "button", "area1", "select1", "select2", "select3", "select4", "select5", "impliedText", "capitalText"] );
- t( "Form element :radio", "#form :radio", ["radio1", "radio2"] );
- t( "Form element :checkbox", "#form :checkbox", ["check1", "check2"] );
- t( "Form element :text", "#form :text", ["text1", "text2", "hidden2", "name", "impliedText", "capitalText"] );
- t( "Form element :radio:checked", "#form :radio:checked", ["radio2"] );
- t( "Form element :checkbox:checked", "#form :checkbox:checked", ["check1"] );
- t( "Form element :radio:checked, :checkbox:checked", "#form :radio:checked, #form :checkbox:checked", ["radio2", "check1"] );
+ t( "Form element :input", "#form :input", [ "text1", "text2", "radio1", "radio2", "check1", "check2", "hidden1", "hidden2", "name", "search", "button", "area1", "select1", "select2", "select3", "select4", "select5", "impliedText", "capitalText" ] );
+ t( "Form element :radio", "#form :radio", [ "radio1", "radio2" ] );
+ t( "Form element :checkbox", "#form :checkbox", [ "check1", "check2" ] );
+ t( "Form element :text", "#form :text", [ "text1", "text2", "hidden2", "name", "impliedText", "capitalText" ] );
+ t( "Form element :radio:checked", "#form :radio:checked", [ "radio2" ] );
+ t( "Form element :checkbox:checked", "#form :checkbox:checked", [ "check1" ] );
+ t( "Form element :radio:checked, :checkbox:checked", "#form :radio:checked, #form :checkbox:checked", [ "radio2", "check1" ] );
t( "Selected option element",
"#form option:selected",
@@ -1097,9 +1096,9 @@ QUnit.test("pseudo - form", function( assert ) {
[ "hidden1" ] );
extraTexts.remove();
-});
+} );
-QUnit.test("pseudo - :(dis|en)abled, explicitly disabled", function( assert ) {
+QUnit.test( "pseudo - :(dis|en)abled, explicitly disabled", function( assert ) {
assert.expect( 2 );
// Set a meaningless disabled property on a common ancestor
@@ -1125,9 +1124,9 @@ QUnit.test("pseudo - :(dis|en)abled, explicitly disabled", function( assert ) {
[ "enabled-input", "enabled-textarea", "enabled-button",
"enabled-select", "enabled-optgroup", "enabled-option" ]
);
-});
+} );
-QUnit.test("pseudo - :(dis|en)abled, optgroup and option", function( assert ) {
+QUnit.test( "pseudo - :(dis|en)abled, optgroup and option", function( assert ) {
assert.expect( 2 );
t(
@@ -1142,17 +1141,17 @@ QUnit.test("pseudo - :(dis|en)abled, optgroup and option", function( assert ) {
"#disabled-select-inherit :enabled, #enabled-select-inherit :enabled",
[ "enabled-optgroup-inherit", "enabled-optgroup-option", "enabled-select-option" ]
);
-});
+} );
// Support: PhantomJS
// fieldsetElement.disabled is undefined
-if ( jQuery("")[0].disabled ) {
- QUnit.test("pseudo - fieldset:(dis|en)abled", function() {
+if ( jQuery( "" )[ 0 ].disabled ) {
+ QUnit.test( "pseudo - fieldset:(dis|en)abled", function() {
t( "Disabled fieldset", "fieldset:disabled", [ "disabled-fieldset" ] );
t( "Enabled fieldset", "fieldset:enabled", [ "enabled-fieldset" ] );
- });
+ } );
- QUnit.test("pseudo - :disabled by ancestry", function( assert ) {
+ QUnit.test( "pseudo - :disabled by ancestry", function( assert ) {
assert.expect( 1 );
// Don't test for presence of select
@@ -1163,39 +1162,39 @@ if ( jQuery("")[0].disabled ) {
[ "disabled-fieldset-input", "disabled-fieldset-textarea",
"disabled-fieldset-button" ]
);
- });
+ } );
}
-QUnit.test("pseudo - :target and :root", function( assert ) {
+QUnit.test( "pseudo - :target and :root", function( assert ) {
assert.expect( 2 );
// Target
var oldHash,
- $link = jQuery("").attr({
+ $link = jQuery( "" ).attr( {
href: "#",
id: "new-link"
- }).appendTo("#qunit-fixture");
+ } ).appendTo( "#qunit-fixture" );
oldHash = window.location.hash;
window.location.hash = "new-link";
- t( ":target", ":target", ["new-link"] );
+ t( ":target", ":target", [ "new-link" ] );
$link.remove();
window.location.hash = oldHash;
// Root
- assert.equal( Sizzle(":root")[0], document.documentElement, ":root selector" );
-});
+ assert.equal( Sizzle( ":root" )[ 0 ], document.documentElement, ":root selector" );
+} );
-QUnit.test("pseudo - :lang", function( assert ) {
+QUnit.test( "pseudo - :lang", function( assert ) {
assert.expect( 105 );
var docElem = document.documentElement,
- docXmlLang = docElem.getAttribute("xml:lang"),
+ docXmlLang = docElem.getAttribute( "xml:lang" ),
docLang = docElem.lang,
- foo = document.getElementById("foo"),
- anchor = document.getElementById("anchor2"),
+ foo = document.getElementById( "foo" ),
+ anchor = document.getElementById( "anchor2" ),
xml = createWithFriesXML(),
testLang = function( text, elem, container, lang, extra ) {
var message,
@@ -1204,9 +1203,9 @@ QUnit.test("pseudo - :lang", function( assert ) {
message = "lang=" + lang + " " + text;
container.setAttribute( container.ownerDocument.documentElement.nodeName === "HTML" ? "lang" : "xml:lang", lang );
assertMatch( message, elem, ":lang(" + lang + ")" );
- assertMatch( message, elem, ":lang(" + mixCase(lang) + ")" );
+ assertMatch( message, elem, ":lang(" + mixCase( lang ) + ")" );
assertNoMatch( message, elem, ":lang(" + full + ")" );
- assertNoMatch( message, elem, ":lang(" + mixCase(full) + ")" );
+ assertNoMatch( message, elem, ":lang(" + mixCase( full ) + ")" );
assertNoMatch( message, elem, ":lang(" + lang + "-)" );
assertNoMatch( message, elem, ":lang(" + full + "-)" );
assertNoMatch( message, elem, ":lang(" + lang + "glish)" );
@@ -1215,23 +1214,23 @@ QUnit.test("pseudo - :lang", function( assert ) {
message = "lang=" + full + " " + text;
container.setAttribute( container.ownerDocument.documentElement.nodeName === "HTML" ? "lang" : "xml:lang", full );
assertMatch( message, elem, ":lang(" + lang + ")" );
- assertMatch( message, elem, ":lang(" + mixCase(lang) + ")" );
+ assertMatch( message, elem, ":lang(" + mixCase( lang ) + ")" );
assertMatch( message, elem, ":lang(" + full + ")" );
- assertMatch( message, elem, ":lang(" + mixCase(full) + ")" );
+ assertMatch( message, elem, ":lang(" + mixCase( full ) + ")" );
assertNoMatch( message, elem, ":lang(" + lang + "-)" );
assertNoMatch( message, elem, ":lang(" + full + "-)" );
assertNoMatch( message, elem, ":lang(" + lang + "glish)" );
assertNoMatch( message, elem, ":lang(" + full + "glish)" );
},
mixCase = function( str ) {
- var ret = str.split(""),
+ var ret = str.split( "" ),
i = ret.length;
while ( i-- ) {
if ( i & 1 ) {
- ret[i] = ret[i].toUpperCase();
+ ret[ i ] = ret[ i ].toUpperCase();
}
}
- return ret.join("");
+ return ret.join( "" );
},
assertMatch = function( text, elem, selector ) {
assert.ok( Sizzle.matchesSelector( elem, selector ), text + " match " + selector );
@@ -1264,15 +1263,15 @@ QUnit.test("pseudo - :lang", function( assert ) {
assert.deepEqual( Sizzle( ":lang(ara\\b)", foo ), [], ":lang respects backslashes" );
assert.deepEqual( Sizzle( ":lang(ara\\\\b)", foo ), [ anchor ],
":lang respects escaped backslashes" );
- assert.throws(function() {
+ assert.throws( function() {
Sizzle.call( null, "#qunit-fixture:lang(c++)" );
}, function( e ) {
- return e.message.indexOf("Syntax error") >= 0;
+ return e.message.indexOf( "Syntax error" ) >= 0;
}, ":lang value must be a valid identifier" );
// XML
- foo = jQuery( "response", xml )[0];
- anchor = jQuery( "#seite1", xml )[0];
+ foo = jQuery( "response", xml )[ 0 ];
+ anchor = jQuery( "#seite1", xml )[ 0 ];
testLang( "XML document", anchor, xml.documentElement, "en", "us" );
testLang( "XML grandparent", anchor, foo, "yue", "hk" );
assert.ok( !Sizzle.matchesSelector( anchor, ":lang(en), :lang(en-us)" ),
@@ -1284,14 +1283,14 @@ QUnit.test("pseudo - :lang", function( assert ) {
// Cleanup
if ( docXmlLang == null ) {
- docElem.removeAttribute("xml:lang");
+ docElem.removeAttribute( "xml:lang" );
} else {
docElem.setAttribute( "xml:lang", docXmlLang );
}
docElem.lang = docLang;
-});
+} );
-QUnit.test("context", function( assert ) {
+QUnit.test( "context", function( assert ) {
assert.expect( 21 );
var context,
@@ -1310,13 +1309,13 @@ QUnit.test("context", function( assert ) {
iframeDoc.write( "bar
" );
iframeDoc.close();
expected = [ iframeDoc.getElementById( "foo" ) ];
- assert.deepEqual( Sizzle( "p", iframeDoc ), expected, "Other document context (simple)");
+ assert.deepEqual( Sizzle( "p", iframeDoc ), expected, "Other document context (simple)" );
assert.deepEqual( Sizzle( "p:contains(ar)", iframeDoc ), expected,
- "Other document context (complex)");
+ "Other document context (complex)" );
assert.deepEqual( Sizzle( "span", iframeDoc ), [],
- "Other document context (simple, no results)");
+ "Other document context (simple, no results)" );
assert.deepEqual( Sizzle( "* span", iframeDoc ), [],
- "Other document context (complex, no results)");
+ "Other document context (complex, no results)" );
context = document.getElementById( "nothiddendiv" );
assert.deepEqual( Sizzle( "*", context ), q( "nothiddendivchild" ), " context" );
@@ -1331,14 +1330,14 @@ QUnit.test("context", function( assert ) {
assert.strictEqual( context.getAttribute( "id" ) || "", "", "id not added by no-id selection" );
context = document.getElementById( "lengthtest" );
- assert.deepEqual( Sizzle( "input", context ), q( "length", "idTest" ), "" );
iframeDoc.close();
-});
+} );
-QUnit.test("matchesSelector", function( assert ) {
+QUnit.test( "matchesSelector", function( assert ) {
assert.expect( 15 );
var link = document.getElementById( "simon1" ),
@@ -1456,9 +1455,9 @@ QUnit.test("matchesSelector", function( assert ) {
assert.ok( Sizzle.matchesSelector( disconnected, "div" ), "disconnected element" );
assert.ok( Sizzle.matchesSelector( link, "* > *" ), "child combinator matches in document" );
assert.ok( !Sizzle.matchesSelector( disconnected, "* > *" ), "child combinator fails in fragment" );
-});
+} );
-QUnit.test("matches", function( assert ) {
+QUnit.test( "matches", function( assert ) {
assert.expect( 4 );
var iframeChild,
@@ -1489,22 +1488,22 @@ QUnit.test("matches", function( assert ) {
[ iframeChild, input ],
"Sizzle.matches infers context from each seed element"
);
-});
+} );
-QUnit.test("select() with pre-compiled function", function( assert ) {
+QUnit.test( "select() with pre-compiled function", function( assert ) {
assert.expect( 6 );
- jQuery.each([ "#qunit-fixture #first", "ol#listWithTabIndex > li[tabindex]", "#liveSpan1" ],
+ jQuery.each( [ "#qunit-fixture #first", "ol#listWithTabIndex > li[tabindex]", "#liveSpan1" ],
function( i, selector ) {
var compiled = Sizzle.compile( selector );
assert.equal( Sizzle.select( compiled, document ).length, 1,
"Should match using a compiled selector function" );
- assert.equal( Sizzle.select( compiled, Sizzle( "#first")[0] ).length, 0,
+ assert.equal( Sizzle.select( compiled, Sizzle( "#first" )[ 0 ] ).length, 0,
"Should not match with different context" );
- });
-});
+ } );
+} );
-QUnit.test("Sizzle supports shadow DOM nodes as root", function( assert ) {
+QUnit.test( "Sizzle supports shadow DOM nodes as root", function( assert ) {
if ( !document.documentElement.createShadowRoot ) {
assert.ok( true, "Shadow DOM not supported in this browser" );
return;
diff --git a/test/unit/utilities.js b/test/unit/utilities.js
index 45bec649..597f3079 100644
--- a/test/unit/utilities.js
+++ b/test/unit/utilities.js
@@ -11,7 +11,7 @@ function testAttr( doc, assert ) {
} else {
// Set checked on creation by creating with a fragment
// See https://jsfiddle.net/8sVgA/1/show/light in oldIE
- el = jQuery( "" )[0];
+ el = jQuery( "" )[ 0 ];
}
// Set it again for good measure
@@ -36,21 +36,21 @@ function testAttr( doc, assert ) {
"Gecko Object.prototype property \"watch\"" );
}
-QUnit.test("Sizzle.attr (HTML)", function( assert ) {
+QUnit.test( "Sizzle.attr (HTML)", function( assert ) {
testAttr( null, assert );
-});
+} );
-QUnit.test("Sizzle.attr (XML)", function( assert ) {
+QUnit.test( "Sizzle.attr (XML)", function( assert ) {
testAttr( jQuery.parseXML( "" ), assert );
-});
+} );
-QUnit.test("Sizzle.escape", function( assert ) {
+QUnit.test( "Sizzle.escape", function( assert ) {
// Edge cases
assert.equal( Sizzle.escape(), "undefined", "Converts undefined to string" );
- assert.equal( Sizzle.escape("-"), "\\-", "Escapes standalone dash" );
- assert.equal( Sizzle.escape("-a"), "-a", "Doesn't escape leading dash followed by non-number" );
- assert.equal( Sizzle.escape("--"), "--", "Doesn't escape standalone double dash" );
+ assert.equal( Sizzle.escape( "-" ), "\\-", "Escapes standalone dash" );
+ assert.equal( Sizzle.escape( "-a" ), "-a", "Doesn't escape leading dash followed by non-number" );
+ assert.equal( Sizzle.escape( "--" ), "--", "Doesn't escape standalone double dash" );
assert.equal( Sizzle.escape( "\uFFFD" ), "\uFFFD",
"Doesn't escape standalone replacement character" );
assert.equal( Sizzle.escape( "a\uFFFD" ), "a\uFFFD",
@@ -148,55 +148,55 @@ QUnit.test("Sizzle.escape", function( assert ) {
// Lone surrogates
assert.equal( Sizzle.escape( "\uDF06" ), "\uDF06", "Doesn't escape lone low surrogate" );
assert.equal( Sizzle.escape( "\uD834" ), "\uD834", "Doesn't escape lone high surrogate" );
-});
+} );
-QUnit.test("Sizzle.contains", function( assert ) {
+QUnit.test( "Sizzle.contains", function( assert ) {
assert.expect( 16 );
- var container = document.getElementById("nonnodes"),
+ var container = document.getElementById( "nonnodes" ),
element = container.firstChild,
text = element.nextSibling,
nonContained = container.nextSibling,
- detached = document.createElement("a");
+ detached = document.createElement( "a" );
assert.ok( element && element.nodeType === 1, "preliminary: found element" );
assert.ok( text && text.nodeType === 3, "preliminary: found text" );
assert.ok( nonContained, "preliminary: found non-descendant" );
- assert.ok( Sizzle.contains(container, element), "child" );
- assert.ok( Sizzle.contains(container.parentNode, element), "grandchild" );
- assert.ok( Sizzle.contains(container, text), "text child" );
- assert.ok( Sizzle.contains(container.parentNode, text), "text grandchild" );
- assert.ok( !Sizzle.contains(container, container), "self" );
- assert.ok( !Sizzle.contains(element, container), "parent" );
- assert.ok( !Sizzle.contains(container, nonContained), "non-descendant" );
- assert.ok( !Sizzle.contains(container, document), "document" );
- assert.ok( !Sizzle.contains(container, document.documentElement), "documentElement (negative)" );
- assert.ok( !Sizzle.contains(container, null), "Passing null does not throw an error" );
- assert.ok( Sizzle.contains(document, document.documentElement), "documentElement (positive)" );
- assert.ok( Sizzle.contains(document, element), "document container (positive)" );
- assert.ok( !Sizzle.contains(document, detached), "document container (negative)" );
-});
+ assert.ok( Sizzle.contains( container, element ), "child" );
+ assert.ok( Sizzle.contains( container.parentNode, element ), "grandchild" );
+ assert.ok( Sizzle.contains( container, text ), "text child" );
+ assert.ok( Sizzle.contains( container.parentNode, text ), "text grandchild" );
+ assert.ok( !Sizzle.contains( container, container ), "self" );
+ assert.ok( !Sizzle.contains( element, container ), "parent" );
+ assert.ok( !Sizzle.contains( container, nonContained ), "non-descendant" );
+ assert.ok( !Sizzle.contains( container, document ), "document" );
+ assert.ok( !Sizzle.contains( container, document.documentElement ), "documentElement (negative)" );
+ assert.ok( !Sizzle.contains( container, null ), "Passing null does not throw an error" );
+ assert.ok( Sizzle.contains( document, document.documentElement ), "documentElement (positive)" );
+ assert.ok( Sizzle.contains( document, element ), "document container (positive)" );
+ assert.ok( !Sizzle.contains( document, detached ), "document container (negative)" );
+} );
if ( jQuery( ""
)[ 0 ].firstChild ) {
- QUnit.test("Sizzle.contains in SVG (jQuery #10832)", function( assert ) {
+ QUnit.test( "Sizzle.contains in SVG (jQuery #10832)", function( assert ) {
assert.expect( 4 );
var svg = jQuery(
""
- ).appendTo("#qunit-fixture")[0];
+ ).appendTo( "#qunit-fixture" )[ 0 ];
assert.ok( Sizzle.contains( svg, svg.firstChild ), "root child" );
assert.ok( Sizzle.contains( svg.firstChild, svg.firstChild.firstChild ), "element child" );
assert.ok( Sizzle.contains( svg, svg.firstChild.firstChild ), "root granchild" );
assert.ok( !Sizzle.contains( svg.firstChild.firstChild, svg.firstChild ),
"parent (negative)" );
- });
+ } );
}
-QUnit.test("Sizzle.isXML", function( assert ) {
+QUnit.test( "Sizzle.isXML", function( assert ) {
assert.expect( 10 );
var svgTree,
@@ -255,9 +255,9 @@ QUnit.test("Sizzle.isXML", function( assert ) {
} else {
assert.ok( true, "Cannot test an incomplete DOM" );
}
-});
+} );
-QUnit.test("Sizzle.uniqueSort", function( assert ) {
+QUnit.test( "Sizzle.uniqueSort", function( assert ) {
assert.expect( 14 );
function Arrayish( arr ) {
@@ -275,16 +275,16 @@ QUnit.test("Sizzle.uniqueSort", function( assert ) {
var i, tests,
detached = [],
body = document.body,
- fixture = document.getElementById("qunit-fixture"),
- detached1 = document.createElement("p"),
- detached2 = document.createElement("ul"),
- detachedChild = detached1.appendChild( document.createElement("a") ),
- detachedGrandchild = detachedChild.appendChild( document.createElement("b") );
+ fixture = document.getElementById( "qunit-fixture" ),
+ detached1 = document.createElement( "p" ),
+ detached2 = document.createElement( "ul" ),
+ detachedChild = detached1.appendChild( document.createElement( "a" ) ),
+ detachedGrandchild = detachedChild.appendChild( document.createElement( "b" ) );
for ( i = 0; i < 12; i++ ) {
- detached.push( document.createElement("li") );
- detached[i].id = "detached" + i;
- detached2.appendChild( document.createElement("li") ).id = "detachedChild" + i;
+ detached.push( document.createElement( "li" ) );
+ detached[ i ].id = "detached" + i;
+ detached2.appendChild( document.createElement( "li" ) ).id = "detachedChild" + i;
}
tests = {
@@ -310,16 +310,16 @@ QUnit.test("Sizzle.uniqueSort", function( assert ) {
},
"Detached children": {
input: [
- detached2.childNodes[3],
- detached2.childNodes[0],
- detached2.childNodes[2],
- detached2.childNodes[1]
+ detached2.childNodes[ 3 ],
+ detached2.childNodes[ 0 ],
+ detached2.childNodes[ 2 ],
+ detached2.childNodes[ 1 ]
],
expected: [
- detached2.childNodes[0],
- detached2.childNodes[1],
- detached2.childNodes[2],
- detached2.childNodes[3]
+ detached2.childNodes[ 0 ],
+ detached2.childNodes[ 1 ],
+ detached2.childNodes[ 2 ],
+ detached2.childNodes[ 3 ]
]
},
"Attached/detached mixture": {
@@ -341,8 +341,8 @@ QUnit.test("Sizzle.uniqueSort", function( assert ) {
test.expected,
label + " (quasi-array)"
);
- });
-});
+ } );
+} );
testIframeWithCallback( "Sizzle.uniqueSort works cross-window (jQuery #14381)", "mixed_sort.html",
function( actual, expected, message ) {