mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Core: Support non-browser environments
Fixes gh-2133
Fixes gh-2501
Closes gh-2504
Refs gh-1950
Refs gh-1949
Refs gh-2397
Refs gh-1537
Refs gh-2504
Refs 842958e7ae
This commit is contained in:
parent
9b04201ff2
commit
04ec688e80
2
.gitignore
vendored
2
.gitignore
vendored
@ -10,3 +10,5 @@
|
|||||||
|
|
||||||
/dist
|
/dist
|
||||||
/node_modules
|
/node_modules
|
||||||
|
|
||||||
|
/test/node_smoke_tests/lib/ensure_iterability.js
|
||||||
|
3
.jscsrc
3
.jscsrc
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"preset": "jquery",
|
"preset": "jquery",
|
||||||
|
|
||||||
"excludeFiles": [ "external", "src/intro.js", "src/outro.js" ]
|
"excludeFiles": [ "external", "src/intro.js", "src/outro.js",
|
||||||
|
"test/node_smoke_tests/lib/ensure_iterability.js" ]
|
||||||
}
|
}
|
||||||
|
@ -9,3 +9,4 @@ test/data/readywaitasset.js
|
|||||||
test/data/readywaitloader.js
|
test/data/readywaitloader.js
|
||||||
test/data/support/csp.js
|
test/data/support/csp.js
|
||||||
test/data/support/getComputedSupport.js
|
test/data/support/getComputedSupport.js
|
||||||
|
test/node_smoke_tests/lib/ensure_iterability.js
|
||||||
|
18
Gruntfile.js
18
Gruntfile.js
@ -34,6 +34,18 @@ module.exports = function( grunt ) {
|
|||||||
cache: "build/.sizecache.json"
|
cache: "build/.sizecache.json"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
babel: {
|
||||||
|
options: {
|
||||||
|
sourceMap: "inline",
|
||||||
|
retainLines: true
|
||||||
|
},
|
||||||
|
nodeSmokeTests: {
|
||||||
|
files: {
|
||||||
|
"test/node_smoke_tests/lib/ensure_iterability.js":
|
||||||
|
"test/node_smoke_tests/lib/ensure_iterability_es6.js"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
build: {
|
build: {
|
||||||
all: {
|
all: {
|
||||||
dest: "dist/jquery.js",
|
dest: "dist/jquery.js",
|
||||||
@ -159,11 +171,9 @@ module.exports = function( grunt ) {
|
|||||||
|
|
||||||
grunt.registerTask( "lint", [ "jsonlint", "jshint", "jscs" ] );
|
grunt.registerTask( "lint", [ "jsonlint", "jshint", "jscs" ] );
|
||||||
|
|
||||||
// Only defined for master at this time, but kept for cross-branch consistency
|
grunt.registerTask( "test_fast", [ "node_smoke_tests" ] );
|
||||||
grunt.registerTask( "test_fast", [] );
|
|
||||||
|
|
||||||
// gh-2133 TODO: cherry-pick 76df9e4e389d80bff410a9e5f08b848de1d21a2f for promises-aplus-tests
|
grunt.registerTask( "test", [ "test_fast", "promises_aplus_tests" ] );
|
||||||
grunt.registerTask( "test", [ "test_fast"/*, "promises-aplus-tests"*/ ] );
|
|
||||||
|
|
||||||
// Short list as a high frequency watch task
|
// Short list as a high frequency watch task
|
||||||
grunt.registerTask( "dev", [ "build:*:*", "lint", "uglify", "remove_map_comment", "dist:*" ] );
|
grunt.registerTask( "dev", [ "build:*:*", "lint", "uglify", "remove_map_comment", "dist:*" ] );
|
||||||
|
27
build/tasks/install_jsdom.js
Normal file
27
build/tasks/install_jsdom.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
module.exports = function( grunt ) {
|
||||||
|
grunt.registerTask( "jsdom", function() {
|
||||||
|
var current,
|
||||||
|
pkg = grunt.config( "pkg" ),
|
||||||
|
version = pkg.jsdomVersions[
|
||||||
|
|
||||||
|
// Unfortunately, this is currently the only
|
||||||
|
// way to tell the difference between Node and iojs
|
||||||
|
/^v0/.test( process.version ) ? "node" : "iojs"
|
||||||
|
];
|
||||||
|
|
||||||
|
try {
|
||||||
|
current = require( "jsdom/package.json" ).version;
|
||||||
|
if ( current === version ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch ( e ) {}
|
||||||
|
|
||||||
|
// Use npm on the command-line
|
||||||
|
// There is no local npm
|
||||||
|
grunt.util.spawn( {
|
||||||
|
cmd: "npm",
|
||||||
|
args: [ "install", "jsdom@" + version ],
|
||||||
|
opts: { stdio: "inherit" }
|
||||||
|
}, this.async() );
|
||||||
|
});
|
||||||
|
};
|
16
build/tasks/lib/spawn_test.js
Normal file
16
build/tasks/lib/spawn_test.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
/* jshint node: true */
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
// Run Node with provided parameters: the first one being the Grunt
|
||||||
|
// done function and latter ones being files to be tested.
|
||||||
|
// See the comment in ../node_smoke_tests.js for more information.
|
||||||
|
module.exports = function spawnTest( done ) {
|
||||||
|
var testPaths = [].slice.call( arguments, 1 ),
|
||||||
|
spawn = require( "win-spawn" );
|
||||||
|
|
||||||
|
spawn( "node", testPaths, { stdio: "inherit" } )
|
||||||
|
.on( "close", function( code ) {
|
||||||
|
done( code === 0 );
|
||||||
|
} );
|
||||||
|
} ;
|
32
build/tasks/node_smoke_tests.js
Normal file
32
build/tasks/node_smoke_tests.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
module.exports = function( grunt ) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var fs = require( "fs" ),
|
||||||
|
spawnTest = require( "./lib/spawn_test.js" ),
|
||||||
|
testsDir = "./test/node_smoke_tests/",
|
||||||
|
nodeSmokeTests = [ "jsdom", "babel:nodeSmokeTests" ];
|
||||||
|
|
||||||
|
// Fire up all tests defined in test/node_smoke_tests/*.js in spawned sub-processes.
|
||||||
|
// All the files under test/node_smoke_tests/*.js are supposed to exit with 0 code
|
||||||
|
// on success or another one on failure. Spawning in sub-processes is
|
||||||
|
// important so that the tests & the main process don't interfere with
|
||||||
|
// each other, e.g. so that they don't share the require cache.
|
||||||
|
|
||||||
|
fs.readdirSync( testsDir )
|
||||||
|
.filter( function( testFilePath ) {
|
||||||
|
return fs.statSync( testsDir + testFilePath ).isFile() &&
|
||||||
|
/\.js$/.test( testFilePath );
|
||||||
|
} )
|
||||||
|
.forEach( function( testFilePath ) {
|
||||||
|
var taskName = "node_" + testFilePath.replace( /\.js$/, "" );
|
||||||
|
|
||||||
|
grunt.registerTask( taskName, function() {
|
||||||
|
spawnTest( this.async(), "test/node_smoke_tests/" + testFilePath );
|
||||||
|
} );
|
||||||
|
|
||||||
|
nodeSmokeTests.push( taskName );
|
||||||
|
} );
|
||||||
|
|
||||||
|
grunt.registerTask( "node_smoke_tests", nodeSmokeTests );
|
||||||
|
};
|
13
build/tasks/promises_aplus_tests.js
Normal file
13
build/tasks/promises_aplus_tests.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
module.exports = function( grunt ) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var spawnTest = require( "./lib/spawn_test.js" );
|
||||||
|
|
||||||
|
grunt.registerTask( "promises_aplus_tests", function() {
|
||||||
|
spawnTest( this.async(),
|
||||||
|
"./node_modules/.bin/promises-aplus-tests",
|
||||||
|
"test/promises_aplus_adapter.js"
|
||||||
|
);
|
||||||
|
} );
|
||||||
|
};
|
@ -26,7 +26,9 @@
|
|||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"commitplease": "2.0.0",
|
"commitplease": "2.0.0",
|
||||||
|
"core-js": "0.9.17",
|
||||||
"grunt": "0.4.5",
|
"grunt": "0.4.5",
|
||||||
|
"grunt-babel": "5.0.1",
|
||||||
"grunt-cli": "0.1.13",
|
"grunt-cli": "0.1.13",
|
||||||
"grunt-compare-size": "0.4.0",
|
"grunt-compare-size": "0.4.0",
|
||||||
"grunt-contrib-jshint": "0.11.2",
|
"grunt-contrib-jshint": "0.11.2",
|
||||||
@ -46,7 +48,12 @@
|
|||||||
"sinon": "1.12.2",
|
"sinon": "1.12.2",
|
||||||
"sizzle": "2.2.0",
|
"sizzle": "2.2.0",
|
||||||
"strip-json-comments": "1.0.3",
|
"strip-json-comments": "1.0.3",
|
||||||
"testswarm": "1.1.0"
|
"testswarm": "1.1.0",
|
||||||
|
"win-spawn": "2.0.0"
|
||||||
|
},
|
||||||
|
"jsdomVersions": {
|
||||||
|
"node": "3.1.2",
|
||||||
|
"iojs": "5.3.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "npm install && grunt",
|
"build": "npm install && grunt",
|
||||||
|
@ -16,11 +16,11 @@
|
|||||||
// The above browsers are failing a lot of tests in the ES5
|
// The above browsers are failing a lot of tests in the ES5
|
||||||
// test suite at http://test262.ecmascript.org.
|
// test suite at http://test262.ecmascript.org.
|
||||||
"es3": true,
|
"es3": true,
|
||||||
"browser": true,
|
|
||||||
"wsh": true,
|
|
||||||
|
|
||||||
"globals": {
|
"globals": {
|
||||||
|
"window": true,
|
||||||
"JSON": false,
|
"JSON": false,
|
||||||
|
|
||||||
"jQuery": true,
|
"jQuery": true,
|
||||||
"define": false,
|
"define": false,
|
||||||
"module": false,
|
"module": false,
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
define([
|
define([
|
||||||
"./core",
|
"./core",
|
||||||
|
"./var/document",
|
||||||
"./var/rnotwhite",
|
"./var/rnotwhite",
|
||||||
|
"./ajax/var/location",
|
||||||
"./ajax/var/nonce",
|
"./ajax/var/nonce",
|
||||||
"./ajax/var/rquery",
|
"./ajax/var/rquery",
|
||||||
"./core/init",
|
"./core/init",
|
||||||
"./ajax/parseJSON",
|
"./ajax/parseJSON",
|
||||||
"./ajax/parseXML",
|
"./ajax/parseXML",
|
||||||
"./deferred"
|
"./deferred"
|
||||||
], function( jQuery, rnotwhite, nonce, rquery ) {
|
], function( jQuery, document, rnotwhite, location, nonce, rquery ) {
|
||||||
|
|
||||||
var
|
var
|
||||||
rhash = /#.*$/,
|
rhash = /#.*$/,
|
||||||
@ -643,7 +645,7 @@ jQuery.extend({
|
|||||||
|
|
||||||
// Timeout
|
// Timeout
|
||||||
if ( s.async && s.timeout > 0 ) {
|
if ( s.async && s.timeout > 0 ) {
|
||||||
timeoutTimer = setTimeout(function() {
|
timeoutTimer = window.setTimeout(function() {
|
||||||
jqXHR.abort("timeout");
|
jqXHR.abort("timeout");
|
||||||
}, s.timeout );
|
}, s.timeout );
|
||||||
}
|
}
|
||||||
@ -677,7 +679,7 @@ jQuery.extend({
|
|||||||
|
|
||||||
// Clear timeout if it exists
|
// Clear timeout if it exists
|
||||||
if ( timeoutTimer ) {
|
if ( timeoutTimer ) {
|
||||||
clearTimeout( timeoutTimer );
|
window.clearTimeout( timeoutTimer );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dereference transport for early garbage collection
|
// Dereference transport for early garbage collection
|
||||||
|
@ -10,10 +10,10 @@ jQuery.parseXML = function( data ) {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if ( window.DOMParser ) { // Standard
|
if ( window.DOMParser ) { // Standard
|
||||||
tmp = new DOMParser();
|
tmp = new window.DOMParser();
|
||||||
xml = tmp.parseFromString( data, "text/xml" );
|
xml = tmp.parseFromString( data, "text/xml" );
|
||||||
} else { // IE
|
} else { // IE
|
||||||
xml = new ActiveXObject( "Microsoft.XMLDOM" );
|
xml = new window.ActiveXObject( "Microsoft.XMLDOM" );
|
||||||
xml.async = "false";
|
xml.async = "false";
|
||||||
xml.loadXML( data );
|
xml.loadXML( data );
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
define([
|
define([
|
||||||
"../core",
|
"../core",
|
||||||
|
"../var/document",
|
||||||
"../ajax"
|
"../ajax"
|
||||||
], function( jQuery ) {
|
], function( jQuery, document ) {
|
||||||
|
|
||||||
// Install script dataType
|
// Install script dataType
|
||||||
jQuery.ajaxSetup({
|
jQuery.ajaxSetup({
|
||||||
|
3
src/ajax/var/location.js
Normal file
3
src/ajax/var/location.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
define(function() {
|
||||||
|
return window.location;
|
||||||
|
});
|
@ -1,8 +1,9 @@
|
|||||||
define([
|
define([
|
||||||
"../core",
|
"../core",
|
||||||
|
"../var/document",
|
||||||
"../var/support",
|
"../var/support",
|
||||||
"../ajax"
|
"../ajax"
|
||||||
], function( jQuery, support ) {
|
], function( jQuery, document, support ) {
|
||||||
|
|
||||||
// Create the request object
|
// Create the request object
|
||||||
// (This is still attached to ajaxSettings for backward compatibility)
|
// (This is still attached to ajaxSettings for backward compatibility)
|
||||||
|
@ -1,21 +1,25 @@
|
|||||||
define([
|
define([
|
||||||
|
"../var/document",
|
||||||
"../var/support"
|
"../var/support"
|
||||||
], function( support ) {
|
], function( document, support ) {
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
// Minified: var a,b,c,d,e
|
var a,
|
||||||
var input, div, select, a, opt;
|
input = document.createElement( "input" ),
|
||||||
|
div = document.createElement( "div" ),
|
||||||
|
select = document.createElement( "select" ),
|
||||||
|
opt = select.appendChild( document.createElement( "option" ) );
|
||||||
|
|
||||||
// Setup
|
// Setup
|
||||||
div = document.createElement( "div" );
|
div.innerHTML = " <link/><a href='/a'>a</a>";
|
||||||
div.innerHTML = " <link/><a href='/a'>a</a><input type='checkbox'/>";
|
// Support: Windows Web Apps (WWA)
|
||||||
a = div.getElementsByTagName("a")[ 0 ];
|
// `type` must use .setAttribute for WWA (#14901)
|
||||||
|
input.setAttribute( "type", "checkbox" );
|
||||||
|
div.appendChild( input );
|
||||||
|
|
||||||
|
a = div.getElementsByTagName( "a" )[ 0 ];
|
||||||
|
|
||||||
// First batch of tests.
|
// First batch of tests.
|
||||||
select = document.createElement("select");
|
|
||||||
opt = select.appendChild( document.createElement("option") );
|
|
||||||
input = div.getElementsByTagName("input")[ 0 ];
|
|
||||||
|
|
||||||
a.style.cssText = "top:1px";
|
a.style.cssText = "top:1px";
|
||||||
|
|
||||||
// Get the style information from getAttribute
|
// Get the style information from getAttribute
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
define([
|
define([
|
||||||
"./var/deletedIds",
|
"./var/deletedIds",
|
||||||
|
"./var/document",
|
||||||
"./var/slice",
|
"./var/slice",
|
||||||
"./var/concat",
|
"./var/concat",
|
||||||
"./var/push",
|
"./var/push",
|
||||||
@ -8,7 +9,8 @@ define([
|
|||||||
"./var/toString",
|
"./var/toString",
|
||||||
"./var/hasOwn",
|
"./var/hasOwn",
|
||||||
"./var/support"
|
"./var/support"
|
||||||
], function( deletedIds, slice, concat, push, indexOf, class2type, toString, hasOwn, support ) {
|
], function( deletedIds, document, slice, concat, push, indexOf,
|
||||||
|
class2type, toString, hasOwn, support ) {
|
||||||
|
|
||||||
var
|
var
|
||||||
version = "@VERSION+compat",
|
version = "@VERSION+compat",
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
// Initialize a jQuery object
|
// Initialize a jQuery object
|
||||||
define([
|
define([
|
||||||
"../core",
|
"../core",
|
||||||
|
"../var/document",
|
||||||
"./var/rsingleTag",
|
"./var/rsingleTag",
|
||||||
"../traversing/findFilter"
|
"../traversing/findFilter"
|
||||||
], function( jQuery, rsingleTag ) {
|
], function( jQuery, document, rsingleTag ) {
|
||||||
|
|
||||||
// A central reference to the root jQuery(document)
|
// A central reference to the root jQuery(document)
|
||||||
var rootjQuery,
|
var rootjQuery,
|
||||||
|
|
||||||
// Use the correct document accordingly with window argument (sandbox)
|
|
||||||
document = window.document,
|
|
||||||
|
|
||||||
// A simple way to check for HTML strings
|
// A simple way to check for HTML strings
|
||||||
// Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
|
// Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
|
||||||
// Strict HTML recognition (#11290: must start with <)
|
// Strict HTML recognition (#11290: must start with <)
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
define([
|
define([
|
||||||
"../core",
|
"../core",
|
||||||
|
"../var/document",
|
||||||
"./var/rsingleTag",
|
"./var/rsingleTag",
|
||||||
"../manipulation/buildFragment",
|
"../manipulation/buildFragment",
|
||||||
|
|
||||||
// This is the only module that needs core/support
|
// This is the only module that needs core/support
|
||||||
"./support"
|
"./support"
|
||||||
], function( jQuery, rsingleTag, buildFragment, support ) {
|
], function( jQuery, document, rsingleTag, buildFragment, support ) {
|
||||||
|
|
||||||
// data: string of html
|
// data: string of html
|
||||||
// context (optional): If specified, the fragment will be created in this context,
|
// context (optional): If specified, the fragment will be created in this context,
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
define([
|
define([
|
||||||
"../core",
|
"../core",
|
||||||
|
"../var/document",
|
||||||
"../deferred"
|
"../deferred"
|
||||||
], function( jQuery ) {
|
], function( jQuery, document ) {
|
||||||
|
|
||||||
// The deferred used on DOM ready
|
// The deferred used on DOM ready
|
||||||
var readyList;
|
var readyList;
|
||||||
@ -72,7 +73,7 @@ function detach() {
|
|||||||
function completed() {
|
function completed() {
|
||||||
// readyState === "complete" is good enough for us to call the dom ready in oldIE
|
// readyState === "complete" is good enough for us to call the dom ready in oldIE
|
||||||
if ( document.addEventListener ||
|
if ( document.addEventListener ||
|
||||||
event.type === "load" ||
|
window.event.type === "load" ||
|
||||||
document.readyState === "complete" ) {
|
document.readyState === "complete" ) {
|
||||||
|
|
||||||
detach();
|
detach();
|
||||||
@ -93,7 +94,7 @@ jQuery.ready.promise = function( obj ) {
|
|||||||
// http://bugs.jquery.com/ticket/12282#comment:15
|
// http://bugs.jquery.com/ticket/12282#comment:15
|
||||||
if ( document.readyState === "complete" ) {
|
if ( document.readyState === "complete" ) {
|
||||||
// Handle it asynchronously to allow scripts the opportunity to delay ready
|
// Handle it asynchronously to allow scripts the opportunity to delay ready
|
||||||
setTimeout( jQuery.ready );
|
window.setTimeout( jQuery.ready );
|
||||||
|
|
||||||
// Standards-based browsers support DOMContentLoaded
|
// Standards-based browsers support DOMContentLoaded
|
||||||
} else if ( document.addEventListener ) {
|
} else if ( document.addEventListener ) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
define([
|
define([
|
||||||
|
"../var/document",
|
||||||
"../var/support"
|
"../var/support"
|
||||||
], function( support ) {
|
], function( document, support ) {
|
||||||
|
|
||||||
// Support: Safari 8+
|
// Support: Safari 8+
|
||||||
// In Safari 8 documents created via document.implementation.createHTMLDocument
|
// In Safari 8 documents created via document.implementation.createHTMLDocument
|
||||||
|
@ -3,12 +3,13 @@ define([
|
|||||||
"./var/pnum",
|
"./var/pnum",
|
||||||
"./core/access",
|
"./core/access",
|
||||||
"./css/var/rmargin",
|
"./css/var/rmargin",
|
||||||
|
"./var/document",
|
||||||
"./var/rcssNum",
|
"./var/rcssNum",
|
||||||
"./css/var/rnumnonpx",
|
"./css/var/rnumnonpx",
|
||||||
"./css/var/cssExpand",
|
"./css/var/cssExpand",
|
||||||
"./css/var/isHidden",
|
"./css/var/isHidden",
|
||||||
"./css/curCSS",
|
|
||||||
"./css/var/swap",
|
"./css/var/swap",
|
||||||
|
"./css/curCSS",
|
||||||
"./css/adjustCSS",
|
"./css/adjustCSS",
|
||||||
"./css/addGetHookIf",
|
"./css/addGetHookIf",
|
||||||
"./css/support",
|
"./css/support",
|
||||||
@ -17,8 +18,8 @@ define([
|
|||||||
"./core/init",
|
"./core/init",
|
||||||
"./core/ready",
|
"./core/ready",
|
||||||
"./selector" // contains
|
"./selector" // contains
|
||||||
], function( jQuery, pnum, access, rmargin, rcssNum, rnumnonpx, cssExpand, isHidden,
|
], function( jQuery, pnum, access, rmargin, document, rcssNum, rnumnonpx, cssExpand,
|
||||||
curCSS, swap, adjustCSS, addGetHookIf, support, showHide ) {
|
isHidden, swap, curCSS, adjustCSS, addGetHookIf, support, showHide ) {
|
||||||
|
|
||||||
var
|
var
|
||||||
// BuildExclude
|
// BuildExclude
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
define([
|
define([
|
||||||
"exports",
|
"exports",
|
||||||
"../core",
|
"../core",
|
||||||
|
"../var/documentElement",
|
||||||
"./var/rnumnonpx",
|
"./var/rnumnonpx",
|
||||||
"./var/rmargin",
|
"./var/rmargin",
|
||||||
"./support",
|
"./support",
|
||||||
"../selector" // contains
|
"../selector" // contains
|
||||||
], function( exports, jQuery, rnumnonpx, rmargin, support ) {
|
], function( exports, jQuery, documentElement, rnumnonpx, rmargin, support ) {
|
||||||
|
|
||||||
var getStyles, curCSS,
|
var getStyles, curCSS,
|
||||||
rposition = /^(top|right|bottom|left)$/;
|
rposition = /^(top|right|bottom|left)$/;
|
||||||
@ -68,7 +69,7 @@ if ( window.getComputedStyle ) {
|
|||||||
ret :
|
ret :
|
||||||
ret + "";
|
ret + "";
|
||||||
};
|
};
|
||||||
} else if ( document.documentElement.currentStyle ) {
|
} else if ( documentElement.currentStyle ) {
|
||||||
getStyles = function( elem ) {
|
getStyles = function( elem ) {
|
||||||
return elem.currentStyle;
|
return elem.currentStyle;
|
||||||
};
|
};
|
||||||
|
@ -1,32 +1,30 @@
|
|||||||
define([
|
define([
|
||||||
"../core",
|
"../core",
|
||||||
|
"../var/document",
|
||||||
|
"../var/documentElement",
|
||||||
"../var/support"
|
"../var/support"
|
||||||
], function( jQuery, support ) {
|
], function( jQuery, document, documentElement, support ) {
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var div, container, style, a, pixelPositionVal, boxSizingReliableVal, gBCRDimensionsVal,
|
var pixelPositionVal, boxSizingReliableVal, gBCRDimensionsVal,
|
||||||
pixelMarginRightVal, reliableHiddenOffsetsVal, reliableMarginRightVal;
|
pixelMarginRightVal, reliableHiddenOffsetsVal, reliableMarginRightVal,
|
||||||
|
container = document.createElement( "div" ),
|
||||||
// Setup
|
div = document.createElement( "div" );
|
||||||
div = document.createElement( "div" );
|
|
||||||
div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
|
|
||||||
a = div.getElementsByTagName( "a" )[ 0 ];
|
|
||||||
style = a && a.style;
|
|
||||||
|
|
||||||
// Finish early in limited (non-browser) environments
|
// Finish early in limited (non-browser) environments
|
||||||
if ( !style ) {
|
if ( !div.style ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
style.cssText = "float:left;opacity:.5";
|
div.style.cssText = "float:left;opacity:.5";
|
||||||
|
|
||||||
// Support: IE<9
|
// Support: IE<9
|
||||||
// Make sure that element opacity exists (as opposed to filter)
|
// Make sure that element opacity exists (as opposed to filter)
|
||||||
support.opacity = style.opacity === "0.5";
|
support.opacity = div.style.opacity === "0.5";
|
||||||
|
|
||||||
// Verify style float existence
|
// Verify style float existence
|
||||||
// (IE uses styleFloat instead of cssFloat)
|
// (IE uses styleFloat instead of cssFloat)
|
||||||
support.cssFloat = !!style.cssFloat;
|
support.cssFloat = !!div.style.cssFloat;
|
||||||
|
|
||||||
div.style.backgroundClip = "content-box";
|
div.style.backgroundClip = "content-box";
|
||||||
div.cloneNode( true ).style.backgroundClip = "";
|
div.cloneNode( true ).style.backgroundClip = "";
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
define([
|
define([
|
||||||
|
"../var/document",
|
||||||
"../var/support"
|
"../var/support"
|
||||||
], function( support ) {
|
], function( document, support ) {
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var div = document.createElement( "div" );
|
var div = document.createElement( "div" );
|
||||||
|
@ -176,7 +176,7 @@ jQuery.extend({
|
|||||||
if ( depth ) {
|
if ( depth ) {
|
||||||
process();
|
process();
|
||||||
} else {
|
} else {
|
||||||
setTimeout( process );
|
window.setTimeout( process );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
10
src/effects.js
vendored
10
src/effects.js
vendored
@ -1,5 +1,6 @@
|
|||||||
define([
|
define([
|
||||||
"./core",
|
"./core",
|
||||||
|
"./var/document",
|
||||||
"./var/rcssNum",
|
"./var/rcssNum",
|
||||||
"./var/rnotwhite",
|
"./var/rnotwhite",
|
||||||
"./css/var/cssExpand",
|
"./css/var/cssExpand",
|
||||||
@ -15,7 +16,8 @@ define([
|
|||||||
"./manipulation",
|
"./manipulation",
|
||||||
"./css",
|
"./css",
|
||||||
"./effects/Tween"
|
"./effects/Tween"
|
||||||
], function( jQuery, rcssNum, rnotwhite, cssExpand, isHidden, swap, adjustCSS, showHide ) {
|
], function( jQuery, document, rcssNum, rnotwhite, cssExpand, isHidden, swap,
|
||||||
|
adjustCSS, showHide ) {
|
||||||
|
|
||||||
var
|
var
|
||||||
fxNow, timerId,
|
fxNow, timerId,
|
||||||
@ -31,7 +33,7 @@ function raf() {
|
|||||||
|
|
||||||
// Animations created synchronously will run synchronously
|
// Animations created synchronously will run synchronously
|
||||||
function createFxNow() {
|
function createFxNow() {
|
||||||
setTimeout(function() {
|
window.setTimeout(function() {
|
||||||
fxNow = undefined;
|
fxNow = undefined;
|
||||||
});
|
});
|
||||||
return ( fxNow = jQuery.now() );
|
return ( fxNow = jQuery.now() );
|
||||||
@ -640,14 +642,14 @@ jQuery.fx.interval = 13;
|
|||||||
jQuery.fx.start = function() {
|
jQuery.fx.start = function() {
|
||||||
timerId = window.requestAnimationFrame ?
|
timerId = window.requestAnimationFrame ?
|
||||||
window.requestAnimationFrame( raf ) :
|
window.requestAnimationFrame( raf ) :
|
||||||
setInterval( jQuery.fx.tick, jQuery.fx.interval );
|
window.setInterval( jQuery.fx.tick, jQuery.fx.interval );
|
||||||
};
|
};
|
||||||
|
|
||||||
jQuery.fx.stop = function() {
|
jQuery.fx.stop = function() {
|
||||||
if ( window.cancelAnimationFrame ) {
|
if ( window.cancelAnimationFrame ) {
|
||||||
window.cancelAnimationFrame( timerId );
|
window.cancelAnimationFrame( timerId );
|
||||||
} else {
|
} else {
|
||||||
clearInterval( timerId );
|
window.clearInterval( timerId );
|
||||||
}
|
}
|
||||||
|
|
||||||
timerId = null;
|
timerId = null;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
define([
|
define([
|
||||||
"./core",
|
"./core",
|
||||||
|
"./var/document",
|
||||||
"./var/rnotwhite",
|
"./var/rnotwhite",
|
||||||
"./var/hasOwn",
|
"./var/hasOwn",
|
||||||
"./var/slice",
|
"./var/slice",
|
||||||
@ -8,7 +9,7 @@ define([
|
|||||||
"./core/init",
|
"./core/init",
|
||||||
"./data",
|
"./data",
|
||||||
"./selector"
|
"./selector"
|
||||||
], function( jQuery, rnotwhite, hasOwn, slice, support ) {
|
], function( jQuery, document, rnotwhite, hasOwn, slice, support ) {
|
||||||
|
|
||||||
var rformElems = /^(?:input|select|textarea)$/i,
|
var rformElems = /^(?:input|select|textarea)$/i,
|
||||||
rkeyEvent = /^key/,
|
rkeyEvent = /^key/,
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
define([
|
define([
|
||||||
|
"../var/document",
|
||||||
"../var/support"
|
"../var/support"
|
||||||
], function( support ) {
|
], function( document, support ) {
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var i, eventName,
|
var i, eventName,
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
define([
|
define([
|
||||||
"./core",
|
"./core",
|
||||||
|
"./var/document",
|
||||||
"./var/concat",
|
"./var/concat",
|
||||||
"./var/push",
|
"./var/push",
|
||||||
"./var/deletedIds",
|
"./var/deletedIds",
|
||||||
@ -22,7 +23,7 @@ define([
|
|||||||
"./traversing",
|
"./traversing",
|
||||||
"./selector",
|
"./selector",
|
||||||
"./event"
|
"./event"
|
||||||
], function( jQuery, concat, push, deletedIds, access,
|
], function( jQuery, document, concat, push, deletedIds, access,
|
||||||
rcheckableType, rtagName, rscriptType, rleadingWhitespace, nodeNames,
|
rcheckableType, rtagName, rscriptType, rleadingWhitespace, nodeNames,
|
||||||
createSafeFragment, wrapMap, getAll, setGlobalEval,
|
createSafeFragment, wrapMap, getAll, setGlobalEval,
|
||||||
buildFragment, support ) {
|
buildFragment, support ) {
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
define([
|
define([
|
||||||
"../core",
|
"../core",
|
||||||
|
"../var/document",
|
||||||
"../var/support"
|
"../var/support"
|
||||||
], function( jQuery, support ) {
|
], function( jQuery, document, support ) {
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var div = document.createElement( "div" ),
|
var div = document.createElement( "div" ),
|
||||||
fragment = document.createDocumentFragment();
|
fragment = document.createDocumentFragment(),
|
||||||
|
input = document.createElement( "input" );
|
||||||
|
|
||||||
// Setup
|
// Setup
|
||||||
div.innerHTML = " <link/><a href='/a'></a>";
|
div.innerHTML = " <link/><a href='/a'></a>";
|
||||||
@ -29,7 +31,13 @@ define([
|
|||||||
|
|
||||||
// #11217 - WebKit loses check when the name is after the checked attribute
|
// #11217 - WebKit loses check when the name is after the checked attribute
|
||||||
fragment.appendChild( div );
|
fragment.appendChild( div );
|
||||||
div.innerHTML = "<input type='radio' checked='checked' name='t'/>";
|
// Support: Windows Web Apps (WWA)
|
||||||
|
// `name` and `type` must use .setAttribute for WWA (#14901)
|
||||||
|
input.setAttribute( "type", "radio" );
|
||||||
|
input.setAttribute( "checked", "checked" );
|
||||||
|
input.setAttribute( "name", "t" );
|
||||||
|
|
||||||
|
div.appendChild( input );
|
||||||
|
|
||||||
// Support: Android<4.2
|
// Support: Android<4.2
|
||||||
// Older WebKit doesn't clone checked state correctly in fragments
|
// Older WebKit doesn't clone checked state correctly in fragments
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
define([
|
define([
|
||||||
"./core",
|
"./core",
|
||||||
"./core/access",
|
"./core/access",
|
||||||
|
"./var/document",
|
||||||
|
"./var/documentElement",
|
||||||
"./css/var/rnumnonpx",
|
"./css/var/rnumnonpx",
|
||||||
"./css/curCSS",
|
"./css/curCSS",
|
||||||
"./css/addGetHookIf",
|
"./css/addGetHookIf",
|
||||||
@ -9,7 +11,7 @@ define([
|
|||||||
"./core/init",
|
"./core/init",
|
||||||
"./css",
|
"./css",
|
||||||
"./selector" // contains
|
"./selector" // contains
|
||||||
], function( jQuery, access, rnumnonpx, curCSS, addGetHookIf, support ) {
|
], function( jQuery, access, document, documentElement, rnumnonpx, curCSS, addGetHookIf, support ) {
|
||||||
|
|
||||||
// BuildExclude
|
// BuildExclude
|
||||||
curCSS = curCSS.curCSS;
|
curCSS = curCSS.curCSS;
|
||||||
|
@ -11,9 +11,9 @@ jQuery.fn.delay = function( time, type ) {
|
|||||||
type = type || "fx";
|
type = type || "fx";
|
||||||
|
|
||||||
return this.queue( type, function( next, hooks ) {
|
return this.queue( type, function( next, hooks ) {
|
||||||
var timeout = setTimeout( next, time );
|
var timeout = window.setTimeout( next, time );
|
||||||
hooks.stop = function() {
|
hooks.stop = function() {
|
||||||
clearTimeout( timeout );
|
window.clearTimeout( timeout );
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
3
src/var/document.js
Normal file
3
src/var/document.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
define(function() {
|
||||||
|
return window.document;
|
||||||
|
});
|
5
src/var/documentElement.js
Normal file
5
src/var/documentElement.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
define([
|
||||||
|
"./document"
|
||||||
|
], function( document ) {
|
||||||
|
return document.documentElement;
|
||||||
|
});
|
14
test/node_smoke_tests/.jshintrc
Normal file
14
test/node_smoke_tests/.jshintrc
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"boss": true,
|
||||||
|
"curly": true,
|
||||||
|
"eqeqeq": true,
|
||||||
|
"eqnull": true,
|
||||||
|
"expr": true,
|
||||||
|
"immed": true,
|
||||||
|
"noarg": true,
|
||||||
|
"quotmark": "double",
|
||||||
|
"undef": true,
|
||||||
|
"unused": true,
|
||||||
|
|
||||||
|
"node": true
|
||||||
|
}
|
11
test/node_smoke_tests/document_missing.js
Normal file
11
test/node_smoke_tests/document_missing.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
var assert = require( "assert" ),
|
||||||
|
ensureGlobalNotCreated = require( "./lib/ensure_global_not_created" ),
|
||||||
|
jQueryFactory = require( "../../dist/jquery.js" );
|
||||||
|
|
||||||
|
assert.throws( function () {
|
||||||
|
jQueryFactory( {} );
|
||||||
|
}, /jQuery requires a window with a document/ );
|
||||||
|
|
||||||
|
ensureGlobalNotCreated( module.exports );
|
14
test/node_smoke_tests/document_passed.js
Normal file
14
test/node_smoke_tests/document_passed.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
var assert = require( "assert" );
|
||||||
|
|
||||||
|
require( "jsdom" ).env( "", function( errors, window ) {
|
||||||
|
assert.ifError( errors );
|
||||||
|
|
||||||
|
var ensureJQuery = require( "./lib/ensure_jquery" ),
|
||||||
|
ensureGlobalNotCreated = require( "./lib/ensure_global_not_created" ),
|
||||||
|
jQuery = require( "../../dist/jquery.js" )( window );
|
||||||
|
|
||||||
|
ensureJQuery( jQuery );
|
||||||
|
ensureGlobalNotCreated( module.exports );
|
||||||
|
} );
|
17
test/node_smoke_tests/document_present_originally.js
Normal file
17
test/node_smoke_tests/document_present_originally.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
var assert = require( "assert" );
|
||||||
|
|
||||||
|
require( "jsdom" ).env( "", function( errors, window ) {
|
||||||
|
assert.ifError( errors );
|
||||||
|
|
||||||
|
// Pretend the window is a global.
|
||||||
|
global.window = window;
|
||||||
|
|
||||||
|
var ensureJQuery = require( "./lib/ensure_jquery" ),
|
||||||
|
ensureGlobalNotCreated = require( "./lib/ensure_global_not_created" ),
|
||||||
|
jQuery = require( "../../dist/jquery.js" );
|
||||||
|
|
||||||
|
ensureJQuery( jQuery );
|
||||||
|
ensureGlobalNotCreated( module.exports, window );
|
||||||
|
} );
|
8
test/node_smoke_tests/iterable_with_native_symbol.js
Normal file
8
test/node_smoke_tests/iterable_with_native_symbol.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
if ( typeof Symbol === "undefined" ) {
|
||||||
|
console.log( "Symbols not supported, skipping the test..." );
|
||||||
|
process.exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
require( "./lib/ensure_iterability_es6" )();
|
13
test/node_smoke_tests/iterable_with_symbol_polyfill.js
Normal file
13
test/node_smoke_tests/iterable_with_symbol_polyfill.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
/* jshint esnext: true */
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var assert = require( "assert" );
|
||||||
|
|
||||||
|
delete global.Symbol;
|
||||||
|
require( "core-js" );
|
||||||
|
|
||||||
|
assert.strictEqual( typeof Symbol, "function", "Expected Symbol to be a function" );
|
||||||
|
assert.notEqual( typeof Symbol.iterator, "symbol", "Expected Symbol.iterator to be polyfilled" );
|
||||||
|
|
||||||
|
require( "./lib/ensure_iterability" )();
|
15
test/node_smoke_tests/lib/ensure_global_not_created.js
Normal file
15
test/node_smoke_tests/lib/ensure_global_not_created.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
var assert = require( "assert" );
|
||||||
|
|
||||||
|
// Ensure the jQuery property on global/window/module.exports/etc. was not
|
||||||
|
// created in a CommonJS environment.
|
||||||
|
// `global` is always checked in addition to passed parameters.
|
||||||
|
module.exports = function ensureGlobalNotCreated() {
|
||||||
|
var args = [].slice.call( arguments ).concat( global );
|
||||||
|
|
||||||
|
args.forEach( function( object ) {
|
||||||
|
assert.strictEqual( object.jQuery, undefined,
|
||||||
|
"A jQuery global was created in a CommonJS environment." );
|
||||||
|
} );
|
||||||
|
};
|
25
test/node_smoke_tests/lib/ensure_iterability_es6.js
Normal file
25
test/node_smoke_tests/lib/ensure_iterability_es6.js
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/* jshint esnext: true */
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var assert = require( "assert" );
|
||||||
|
|
||||||
|
module.exports = function ensureIterability() {
|
||||||
|
require( "jsdom" ).env( "", function( errors, window ) {
|
||||||
|
assert.ifError( errors );
|
||||||
|
|
||||||
|
var i,
|
||||||
|
ensureJQuery = require( "./ensure_jquery" ),
|
||||||
|
jQuery = require( "../../../dist/jquery.js" )( window ),
|
||||||
|
elem = jQuery( "<div></div><span></span><a></a>" ),
|
||||||
|
result = "";
|
||||||
|
|
||||||
|
ensureJQuery( jQuery );
|
||||||
|
|
||||||
|
for ( i of elem ) {
|
||||||
|
result += i.nodeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.strictEqual( result, "DIVSPANA", "for-of doesn't work on jQuery objects" );
|
||||||
|
} );
|
||||||
|
};
|
9
test/node_smoke_tests/lib/ensure_jquery.js
Normal file
9
test/node_smoke_tests/lib/ensure_jquery.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
var assert = require( "assert" );
|
||||||
|
|
||||||
|
// Check if the object we got is the jQuery object by invoking a basic API.
|
||||||
|
module.exports = function ensureJQuery( jQuery ) {
|
||||||
|
assert( /^jQuery/.test( jQuery.expando ),
|
||||||
|
"jQuery.expando was not detected, the jQuery bootstrap process has failed" );
|
||||||
|
};
|
22
test/promises_aplus_adapter.js
Normal file
22
test/promises_aplus_adapter.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
/* jshint node: true */
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
require( "jsdom" ).env( "", function ( errors, window ) {
|
||||||
|
if ( errors ) {
|
||||||
|
console.error( errors );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var jQuery = require( ".." )( window );
|
||||||
|
|
||||||
|
exports.deferred = function () {
|
||||||
|
var deferred = jQuery.Deferred();
|
||||||
|
|
||||||
|
return {
|
||||||
|
promise: deferred.promise(),
|
||||||
|
resolve: deferred.resolve.bind( deferred ),
|
||||||
|
reject: deferred.reject.bind( deferred )
|
||||||
|
};
|
||||||
|
};
|
||||||
|
} );
|
Loading…
Reference in New Issue
Block a user