├── .bowerrc ├── .editorconfig ├── .gitattributes ├── .gitignore ├── .jscsrc ├── .jshintignore ├── .jshintrc ├── .mailmap ├── .npmignore ├── .travis.yml ├── AUTHORS.txt ├── CONTRIBUTING.md ├── Gruntfile.js ├── MIT-LICENSE.txt ├── README.md ├── bower.json ├── build ├── release-notes.js ├── release.js └── tasks │ ├── build.js │ ├── dist.js │ └── testswarm.js ├── dist ├── jquery.js ├── jquery.min.js └── jquery.min.map ├── html ├── index.html └── index2.html ├── package.json ├── src ├── .jshintrc ├── ajax.js ├── ajax │ ├── jsonp.js │ ├── load.js │ ├── parseJSON.js │ ├── parseXML.js │ ├── script.js │ ├── var │ │ ├── nonce.js │ │ └── rquery.js │ └── xhr.js ├── attributes.js ├── attributes │ ├── attr.js │ ├── classes.js │ ├── prop.js │ ├── support.js │ └── val.js ├── callbacks.js ├── core.js ├── core │ ├── access.js │ ├── init.js │ ├── parseHTML.js │ ├── ready.js │ └── var │ │ └── rsingleTag.js ├── css.js ├── css │ ├── addGetHookIf.js │ ├── curCSS.js │ ├── defaultDisplay.js │ ├── hiddenVisibleSelectors.js │ ├── support.js │ ├── swap.js │ └── var │ │ ├── cssExpand.js │ │ ├── isHidden.js │ │ ├── rmargin.js │ │ └── rnumnonpx.js ├── data.js ├── data │ ├── accepts.js │ └── support.js ├── deferred.js ├── deprecated.js ├── dimensions.js ├── effects.js ├── effects │ ├── Tween.js │ ├── animatedSelector.js │ └── support.js ├── event.js ├── event │ ├── ajax.js │ ├── alias.js │ └── support.js ├── exports │ ├── amd.js │ └── global.js ├── intro.js ├── jquery.js ├── manipulation.js ├── manipulation │ ├── _evalUrl.js │ ├── support.js │ └── var │ │ └── rcheckableType.js ├── offset.js ├── outro.js ├── queue.js ├── queue │ └── delay.js ├── selector-sizzle.js ├── selector.js ├── serialize.js ├── sizzle │ ├── dist │ │ ├── sizzle.js │ │ ├── sizzle.min.js │ │ └── sizzle.min.map │ └── test │ │ ├── data │ │ ├── empty.js │ │ ├── mixed_sort.html │ │ └── testinit.js │ │ ├── index.html │ │ ├── jquery.js │ │ └── unit │ │ ├── extending.js │ │ ├── selector.js │ │ └── utilities.js ├── support.js ├── traversing.js ├── traversing │ ├── findFilter.js │ └── var │ │ └── rneedsContext.js ├── var │ ├── class2type.js │ ├── concat.js │ ├── deletedIds.js │ ├── hasOwn.js │ ├── indexOf.js │ ├── pnum.js │ ├── push.js │ ├── rnotwhite.js │ ├── slice.js │ ├── strundefined.js │ ├── support.js │ └── toString.js └── wrap.js └── test ├── .jshintrc ├── data ├── 1x1.jpg ├── ajax │ ├── onunload.html │ └── unreleasedXHR.html ├── atom+xml.php ├── badcall.js ├── badjson.js ├── cleanScript.html ├── core │ ├── aliased.html │ ├── cc_on.html │ ├── dont_return.php │ ├── dynamic_ready.html │ └── onready.html ├── css │ └── cssWidthBeforeDocReady.html ├── dashboard.xml ├── data │ └── dataAttrs.html ├── dimensions │ ├── documentLarge.html │ └── documentSmall.html ├── echoData.php ├── echoQuery.php ├── errorWithJSON.php ├── errorWithText.php ├── etag.php ├── evalScript.php ├── event │ ├── focusElem.html │ ├── focusinCrossFrame.html │ ├── longLoadScript.php │ ├── promiseReady.html │ ├── syncReady.html │ └── triggerunload.html ├── headers.php ├── if_modified_since.php ├── iframe.html ├── jquery-1.9.1.js ├── json.php ├── json_obj.js ├── jsonp.php ├── manipulation │ └── iframe-denied.html ├── name.html ├── name.php ├── nocontent.php ├── offset │ ├── absolute.html │ ├── body.html │ ├── fixed.html │ ├── relative.html │ ├── scroll.html │ ├── static.html │ └── table.html ├── params_html.php ├── readywaitasset.js ├── readywaitloader.js ├── script.php ├── selector │ ├── html5_selector.html │ └── sizzle_cache.html ├── statusText.php ├── support │ ├── bodyBackground.html │ ├── csp-clean.php │ ├── csp-log.php │ ├── csp.js │ ├── csp.log │ ├── csp.php │ ├── getComputedSupport.js │ ├── shrinkWrapBlocks.html │ └── testElementCrash.html ├── test.html ├── test.php ├── test2.html ├── test3.html ├── testbar.php ├── testinit.js ├── testrunner.js ├── testsuite.css ├── text.php ├── ua.txt ├── with_fries.xml └── with_fries_over_jsonp.php ├── delegatetest.html ├── hovertest.html ├── index.html ├── jquery.js ├── libs ├── qunit │ ├── qunit.css │ └── qunit.js ├── require.js └── sinon │ ├── fake_timers.js │ └── timers_ie.js ├── localfile.html ├── networkerror.html ├── readywait.html ├── unit ├── ajax.js ├── attributes.js ├── callbacks.js ├── core.js ├── css.js ├── data.js ├── deferred.js ├── deprecated.js ├── dimensions.js ├── effects.js ├── event.js ├── exports.js ├── manipulation.js ├── offset.js ├── queue.js ├── ready.js ├── selector.js ├── serialize.js ├── support.js ├── traversing.js └── wrap.js └── xhtml.php /.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "bower_components" 3 | } -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # This file is for unifying the coding style for different editors and IDEs 2 | # editorconfig.org 3 | 4 | root = true 5 | 6 | 7 | [*] 8 | end_of_line = lf 9 | charset = utf-8 10 | trim_trailing_whitespace = true 11 | insert_final_newline = true 12 | 13 | # Tabs in JS unless otherwise specified 14 | [**.js] 15 | indent_style = tab 16 | 17 | [Makefile] 18 | indent_style = tab 19 | 20 | 21 | [speed/**.html] 22 | indent_style = tab 23 | 24 | [speed/**.css] 25 | indent_style = tab 26 | 27 | [speed/benchmarker.js] 28 | indent_style = space 29 | indent_size = 2 30 | 31 | 32 | [test/**.xml] 33 | indent_style = tab 34 | 35 | [test/**.php] 36 | indent_style = tab 37 | 38 | [test/**.html] 39 | indent_style = tab 40 | 41 | [test/**.css] 42 | indent_style = space 43 | indent_size = 8 44 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # JS files must always use LF for tools to work 5 | *.js eol=lf 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .project 2 | .settings 3 | *~ 4 | *.diff 5 | *.patch 6 | /*.html 7 | .DS_Store 8 | .bower.json 9 | .sizecache.json 10 | 11 | /dist 12 | /bower_components 13 | /node_modules 14 | -------------------------------------------------------------------------------- /.jscsrc: -------------------------------------------------------------------------------- 1 | { 2 | "preset": "jquery", 3 | 4 | "excludeFiles": [ "src/intro.js", "src/outro.js", "src/sizzle/**/*" ] 5 | } 6 | -------------------------------------------------------------------------------- /.jshintignore: -------------------------------------------------------------------------------- 1 | src/intro.js 2 | src/outro.js 3 | src/sizzle/**/* 4 | test/libs/**/* 5 | test/data/jquery-1.9.1.js 6 | test/data/badcall.js 7 | test/data/badjson.js 8 | test/data/json_obj.js 9 | test/data/readywaitasset.js 10 | test/data/readywaitloader.js 11 | test/data/support/csp.js 12 | test/data/support/getComputedSupport.js 13 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "boss": true, 3 | "curly": true, 4 | "eqeqeq": true, 5 | "eqnull": true, 6 | "expr": true, 7 | "immed": true, 8 | "noarg": true, 9 | "onevar": true, 10 | "quotmark": "double", 11 | "smarttabs": true, 12 | "trailing": true, 13 | "undef": true, 14 | "unused": true, 15 | 16 | "node": true 17 | } -------------------------------------------------------------------------------- /.mailmap: -------------------------------------------------------------------------------- 1 | Adam Coulombe 2 | Adam J. Sontag 3 | Alexander Farkas 4 | Alexander Farkas 5 | Alexis Abril 6 | Andrew E Monat 7 | Anton Matzneller 8 | Anton Matzneller 9 | Batiste Bieler 10 | Benjamin Truyman 11 | Brandon Aaron 12 | Carl Danley 13 | Carl Fürstenberg 14 | Carl Fürstenberg 15 | Charles McNulty 16 | Christopher Jones 17 | Colin Snover 18 | Corey Frang 19 | Dan Heberden 20 | Daniel Chatfield 21 | Daniel Gálvez 22 | Danil Somsikov 23 | Dave Methvin 24 | Dave Reed 25 | David Fox 26 | David Hong 27 | Devin Cooper 28 | Dmitry Gusev 29 | Earle Castledine 30 | Erick Ruiz de Chávez 31 | Gianni Alessandro Chiappetta 32 | Heungsub Lee 33 | Iraê Carvalho 34 | Isaac Z. Schlueter 35 | Ismail Khair 36 | James Burke 37 | James Padolsey 38 | Jason Bedard 39 | Jay Merrifield 40 | Jay Merrifield 41 | Jean Boussier 42 | Jephte Clain 43 | Jess Thrysoee 44 | Joao Henrique de Andrade Bruni 45 | Joe Presbrey 46 | John Resig 47 | John Resig 48 | Jordan Boesch 49 | Josh Varner 50 | Julian Aubourg 51 | Julian Aubourg 52 | Julian Aubourg 53 | Jörn Zaefferer 54 | Jörn Zaefferer 55 | Jörn Zaefferer 56 | Karl Swedberg 57 | Kris Borchers 58 | Lee Carpenter 59 | Li Xudong 60 | Louis-Rémi Babé 61 | Louis-Rémi Babé 62 | Louis-Rémi Babé 63 | Louis-Rémi Babé 64 | Marcel Greter 65 | Matthias Jäggli 66 | Michael Murray 67 | Michał Gołębiowski 68 | Michał Gołębiowski 69 | Mike Alsup 70 | Noah Hamann 71 | David Hong 72 | Nguyen Phuc Lam 73 | Oleg Gaidarenko 74 | Rafaël Blais Masson 75 | Richard D. Worth 76 | Rick Waldron 77 | Rick Waldron 78 | Robert Katić 79 | Roman Reiß 80 | Ron Otten 81 | Sai Lung Wong 82 | Scott González 83 | Scott Jehl 84 | Sebastian Burkhard 85 | Timmy Willison 86 | Timmy Willison 87 | Timo Tijhof 88 | TJ Holowaychuk 89 | Tom H Fuertes 90 | Tom H Fuertes Tom H Fuertes 91 | Tom Viner 92 | Xavi Ramirez 93 | Xavier Montillet 94 | Yehuda Katz 95 | Yehuda Katz 96 | Yehuda Katz 97 | Yehuda Katz 98 | Yiming He 99 | Terry Jones 100 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .jshintignore 2 | .jshintrc 3 | 4 | /.editorconfig 5 | /.gitattributes 6 | /.jscs.json 7 | /.mailmap 8 | /.travis.yml 9 | 10 | /build 11 | /dist/cdn 12 | /speed 13 | /test 14 | /Gruntfile.js 15 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - '0.10' 4 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | module.exports = function( grunt ) { 2 | "use strict"; 3 | 4 | function readOptionalJSON( filepath ) { 5 | var data = {}; 6 | try { 7 | data = grunt.file.readJSON( filepath ); 8 | } catch ( e ) {} 9 | return data; 10 | } 11 | 12 | var gzip = require( "gzip-js" ), 13 | srcHintOptions = readOptionalJSON( "src/.jshintrc" ); 14 | 15 | // The concatenated file won't pass onevar 16 | // But our modules can 17 | delete srcHintOptions.onevar; 18 | 19 | grunt.initConfig({ 20 | pkg: grunt.file.readJSON( "package.json" ), 21 | dst: readOptionalJSON( "dist/.destination.json" ), 22 | compare_size: { 23 | files: [ "dist/jquery.js", "dist/jquery.min.js" ], 24 | options: { 25 | compress: { 26 | gz: function( contents ) { 27 | return gzip.zip( contents, {} ).length; 28 | } 29 | }, 30 | cache: "build/.sizecache.json" 31 | } 32 | }, 33 | build: { 34 | all: { 35 | dest: "dist/jquery.js", 36 | minimum: [ 37 | "core", 38 | "selector" 39 | ], 40 | removeWith: { 41 | ajax: [ "manipulation/_evalUrl", "event/ajax" ], 42 | callbacks: [ "deferred" ], 43 | css: [ "effects", "dimensions", "offset" ] 44 | } 45 | } 46 | }, 47 | bowercopy: { 48 | options: { 49 | clean: true 50 | }, 51 | src: { 52 | files: { 53 | "src/sizzle/dist": "sizzle/dist", 54 | "src/sizzle/test/data": "sizzle/test/data", 55 | "src/sizzle/test/unit": "sizzle/test/unit", 56 | "src/sizzle/test/index.html": "sizzle/test/index.html", 57 | "src/sizzle/test/jquery.js": "sizzle/test/jquery.js" 58 | } 59 | }, 60 | tests: { 61 | options: { 62 | destPrefix: "test/libs" 63 | }, 64 | files: { 65 | "qunit": "qunit/qunit", 66 | "require.js": "requirejs/require.js", 67 | "sinon/fake_timers.js": "sinon/lib/sinon/util/fake_timers.js", 68 | "sinon/timers_ie.js": "sinon/lib/sinon/util/timers_ie.js" 69 | } 70 | } 71 | }, 72 | jsonlint: { 73 | pkg: { 74 | src: [ "package.json" ] 75 | }, 76 | 77 | bower: { 78 | src: [ "bower.json" ] 79 | } 80 | }, 81 | jshint: { 82 | all: { 83 | src: [ 84 | "src/**/*.js", "Gruntfile.js", "test/**/*.js", "build/**/*.js" 85 | ], 86 | options: { 87 | jshintrc: true 88 | } 89 | }, 90 | dist: { 91 | src: "dist/jquery.js", 92 | options: srcHintOptions 93 | } 94 | }, 95 | jscs: { 96 | src: "src/**/*.js", 97 | gruntfile: "Gruntfile.js", 98 | 99 | // Right know, check only test helpers 100 | test: [ "test/data/testrunner.js", "test/data/testinit.js" ], 101 | release: "build/*.js", 102 | tasks: "build/tasks/*.js" 103 | }, 104 | testswarm: { 105 | tests: "ajax attributes callbacks core css data deferred dimensions effects event manipulation offset queue selector serialize support traversing".split( " " ) 106 | }, 107 | watch: { 108 | files: [ "<%= jshint.all.src %>" ], 109 | tasks: "dev" 110 | }, 111 | uglify: { 112 | all: { 113 | files: { 114 | "dist/jquery.min.js": [ "dist/jquery.js" ] 115 | }, 116 | options: { 117 | preserveComments: false, 118 | sourceMap: "dist/jquery.min.map", 119 | sourceMappingURL: "jquery.min.map", 120 | report: "min", 121 | beautify: { 122 | ascii_only: true 123 | }, 124 | banner: "/*! jQuery v<%= pkg.version %> | " + 125 | "(c) 2005, <%= grunt.template.today('yyyy') %> jQuery Foundation, Inc. | " + 126 | "jquery.org/license */", 127 | compress: { 128 | hoist_funs: false, 129 | loops: false, 130 | unused: false 131 | } 132 | } 133 | } 134 | } 135 | }); 136 | 137 | // Load grunt tasks from NPM packages 138 | require( "load-grunt-tasks" )( grunt ); 139 | 140 | // Integrate jQuery specific tasks 141 | grunt.loadTasks( "build/tasks" ); 142 | 143 | grunt.registerTask( "bower", "bowercopy" ); 144 | grunt.registerTask( "lint", [ "jshint", "jscs" ] ); 145 | 146 | // Short list as a high frequency watch task 147 | grunt.registerTask( "dev", [ "build:*:*", "lint" ] ); 148 | 149 | // Default grunt 150 | grunt.registerTask( "default", [ "jsonlint", "dev", "uglify", "dist:*", "compare_size" ] ); 151 | }; 152 | -------------------------------------------------------------------------------- /MIT-LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2014 jQuery Foundation and other contributors 2 | http://jquery.com/ 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining 5 | a copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, subject to 10 | the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # What is this? 2 | 3 | This is a fork of jQuery 1.11.3 that only breaks when built with 4 | a particular version of the minifier (uglify-js@2.4.23, possibly earlier 5 | versions though I haven't checked). It was used to make the PoC described in 6 | [this blog post](https://zyan.scripts.mit.edu/blog/backdooring-js/). 7 | 8 | `./html` includes HTML files that behave differently in "interesting" ways depending on whether the included jquery script is minified. 9 | 10 | ## Building a non-broken build 11 | 12 | ``` 13 | $ npm install 14 | $ grunt 15 | ``` 16 | 17 | ## Building a broken build 18 | 19 | ``` 20 | $ npm install 21 | ``` 22 | 23 | Open `node_modules/grunt-contrib-uglify/package.json` and set `"uglify-js": "2.4.23"` in the "dependencies" field. Then to force `grunt-contrib-uglify` to install this particular version of `uglify-js`: 24 | 25 | ``` 26 | $ cd node_modules/grunt-contrib-uglify 27 | $ rm -r node_modules 28 | $ npm install 29 | $ cd ../.. 30 | $ grunt 31 | ``` 32 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery", 3 | "version": "1.11.3", 4 | "main": "dist/jquery.js", 5 | "license": "MIT", 6 | "ignore": [ 7 | "**/.*", 8 | "build", 9 | "dist/cdn", 10 | "speed", 11 | "test", 12 | "*.md", 13 | "AUTHORS.txt", 14 | "Gruntfile.js", 15 | "package.json" 16 | ], 17 | "devDependencies": { 18 | "sizzle": "2.1.1-jquery.2.1.2", 19 | "requirejs": "2.1.10", 20 | "qunit": "1.14.0", 21 | "sinon": "1.8.1" 22 | }, 23 | "keywords": [ 24 | "jquery", 25 | "javascript", 26 | "library" 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /build/release-notes.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | /* 3 | * jQuery Release Note Generator 4 | */ 5 | 6 | var http = require("http"), 7 | extract = /(.*?)<[^"]+"component">\s*(\S+)/g, 8 | version = process.argv[2]; 9 | 10 | if ( !/^\d+\.\d+/.test( version ) ) { 11 | console.error( "Invalid version number: " + version ); 12 | process.exit( 1 ); 13 | } 14 | 15 | http.request({ 16 | host: "bugs.jquery.com", 17 | port: 80, 18 | method: "GET", 19 | path: "/query?status=closed&resolution=fixed&max=400&component=!web&order=component&milestone=" + version 20 | }, function( res ) { 21 | var data = []; 22 | 23 | res.on( "data", function( chunk ) { 24 | data.push( chunk ); 25 | }); 26 | 27 | res.on( "end", function() { 28 | var match, cur, cat, 29 | file = data.join(""); 30 | 31 | while ( (match = extract.exec( file )) ) { 32 | if ( "#" + match[1] !== match[2] ) { 33 | cat = match[3]; 34 | 35 | if ( !cur || cur !== cat ) { 36 | if ( cur ) { 37 | console.log(""); 38 | } 39 | cur = cat; 40 | console.log( "

" + cat.charAt(0).toUpperCase() + cat.slice(1) + "

" ); 41 | console.log("
"); 52 | } 53 | 54 | }); 55 | }).end(); 56 | -------------------------------------------------------------------------------- /build/release.js: -------------------------------------------------------------------------------- 1 | module.exports = function( Release ) { 2 | 3 | var 4 | fs = require( "fs" ), 5 | shell = require( "shelljs" ), 6 | 7 | devFile = "dist/jquery.js", 8 | minFile = "dist/jquery.min.js", 9 | mapFile = "dist/jquery.min.map", 10 | 11 | cdnFolder = "dist/cdn", 12 | 13 | releaseFiles = { 14 | "jquery-VER.js": devFile, 15 | "jquery-VER.min.js": minFile, 16 | "jquery-VER.min.map": mapFile 17 | }, 18 | 19 | googleFilesCDN = [ 20 | "jquery.js", "jquery.min.js", "jquery.min.map" 21 | ], 22 | 23 | msFilesCDN = [ 24 | "jquery-VER.js", "jquery-VER.min.js", "jquery-VER.min.map" 25 | ], 26 | 27 | _complete = Release.complete; 28 | 29 | /** 30 | * Generates copies for the CDNs 31 | */ 32 | function makeReleaseCopies() { 33 | shell.mkdir( "-p", cdnFolder ); 34 | 35 | Object.keys( releaseFiles ).forEach(function( key ) { 36 | var text, 37 | builtFile = releaseFiles[ key ], 38 | unpathedFile = key.replace( /VER/g, Release.newVersion ), 39 | releaseFile = cdnFolder + "/" + unpathedFile; 40 | 41 | if ( /\.map$/.test( releaseFile ) ) { 42 | // Map files need to reference the new uncompressed name; 43 | // assume that all files reside in the same directory. 44 | // "file":"jquery.min.js","sources":["jquery.js"] 45 | text = fs.readFileSync( builtFile, "utf8" ) 46 | .replace( /"file":"([^"]+)","sources":\["([^"]+)"\]/, 47 | "\"file\":\"" + unpathedFile.replace( /\.min\.map/, ".min.js" ) + 48 | "\",\"sources\":[\"" + unpathedFile.replace( /\.min\.map/, ".js" ) + "\"]" ); 49 | fs.writeFileSync( releaseFile, text ); 50 | } else if ( /\.min\.js$/.test( releaseFile ) ) { 51 | // Remove the source map comment; it causes way too many problems. 52 | // Keep the map file in case DevTools allow manual association. 53 | text = fs.readFileSync( builtFile, "utf8" ) 54 | .replace( /\/\/# sourceMappingURL=\S+/, "" ); 55 | fs.writeFileSync( releaseFile, text ); 56 | } else if ( builtFile !== releaseFile ) { 57 | shell.cp( "-f", builtFile, releaseFile ); 58 | } 59 | }); 60 | } 61 | 62 | function buildGoogleCDN() { 63 | makeArchive( "googlecdn", googleFilesCDN ); 64 | } 65 | 66 | function buildMicrosoftCDN() { 67 | makeArchive( "mscdn", msFilesCDN ); 68 | } 69 | 70 | function makeArchive( cdn, files ) { 71 | if ( Release.preRelease ) { 72 | console.log( "Skipping archive creation for " + cdn + "; this is a beta release." ); 73 | return; 74 | } 75 | 76 | console.log( "Creating production archive for " + cdn ); 77 | 78 | var archiver = require( "archiver" )( "zip" ), 79 | md5file = cdnFolder + "/" + cdn + "-md5.txt", 80 | output = fs.createWriteStream( cdnFolder + "/" + cdn + "-jquery-" + Release.newVersion + ".zip" ); 81 | 82 | output.on( "error", function( err ) { 83 | throw err; 84 | }); 85 | 86 | archiver.pipe( output ); 87 | 88 | files = files.map(function( item ) { 89 | return cdnFolder + "/" + item.replace( /VER/g, Release.newVersion ); 90 | }); 91 | 92 | shell.exec( "md5sum", files, function( code, stdout ) { 93 | fs.writeFileSync( md5file, stdout ); 94 | files.push( md5file ); 95 | 96 | files.forEach(function( file ) { 97 | archiver.append( fs.createReadStream( file ), { name: file } ); 98 | }); 99 | 100 | archiver.finalize(); 101 | }); 102 | } 103 | 104 | Release.define({ 105 | npmPublish: true, 106 | npmTags: function() { 107 | return [ "1.x" ]; 108 | }, 109 | issueTracker: "trac", 110 | contributorReportId: 508, 111 | /** 112 | * Generates any release artifacts that should be included in the release. 113 | * The callback must be invoked with an array of files that should be 114 | * committed before creating the tag. 115 | * @param {Function} callback 116 | */ 117 | generateArtifacts: function( callback ) { 118 | Release.exec( "grunt", "Grunt command failed" ); 119 | makeReleaseCopies(); 120 | callback([ "dist/jquery.js", "dist/jquery.min.js", "dist/jquery.min.map" ]); 121 | }, 122 | /** 123 | * Release completion 124 | */ 125 | complete: function() { 126 | // Build CDN archives async 127 | buildGoogleCDN(); 128 | buildMicrosoftCDN(); 129 | _complete(); 130 | }, 131 | /** 132 | * Our trac milestones are different than the new version 133 | * @example 134 | * 135 | * // For Release.newVersion equal to 2.1.0 or 1.11.0 136 | * Release._tracMilestone(); 137 | * // => 1.11/2.1 138 | * 139 | * // For Release.newVersion equal to 2.1.1 or 1.11.1 140 | * Release._tracMilestone(); 141 | * // => 1.11.1/2.1.1 142 | */ 143 | tracMilestone: function() { 144 | var otherVersion, 145 | m = Release.newVersion.split( "." ), 146 | major = m[0] | 0, 147 | minor = m[1] | 0, 148 | patch = m[2] | 0 ? "." + m[2] : "", 149 | version = major + "." + minor + patch; 150 | if ( major === 1) { 151 | otherVersion = "2." + ( minor - 10 ) + patch; 152 | return version + "/" + otherVersion; 153 | } 154 | otherVersion = "1." + ( minor + 10 ) + patch; 155 | return otherVersion + "/" + version; 156 | } 157 | }); 158 | }; 159 | 160 | module.exports.dependencies = [ 161 | "archiver@0.5.2", 162 | "shelljs@0.2.6" 163 | ]; 164 | -------------------------------------------------------------------------------- /build/tasks/dist.js: -------------------------------------------------------------------------------- 1 | module.exports = function( grunt ) { 2 | 3 | "use strict"; 4 | 5 | var fs = require( "fs" ), 6 | distpaths = [ 7 | "dist/jquery.js", 8 | "dist/jquery.min.map", 9 | "dist/jquery.min.js" 10 | ]; 11 | 12 | // Process files for distribution 13 | grunt.registerTask( "dist", function() { 14 | var stored, flags, paths, nonascii; 15 | 16 | // Check for stored destination paths 17 | // ( set in dist/.destination.json ) 18 | stored = Object.keys( grunt.config( "dst" ) ); 19 | 20 | // Allow command line input as well 21 | flags = Object.keys( this.flags ); 22 | 23 | // Combine all output target paths 24 | paths = [].concat( stored, flags ).filter(function( path ) { 25 | return path !== "*"; 26 | }); 27 | 28 | // Ensure the dist files are pure ASCII 29 | nonascii = false; 30 | 31 | distpaths.forEach(function( filename ) { 32 | var i, c, 33 | text = fs.readFileSync( filename, "utf8" ); 34 | 35 | // Ensure files use only \n for line endings, not \r\n 36 | if ( /\x0d\x0a/.test( text ) ) { 37 | grunt.log.writeln( filename + ": Incorrect line endings (\\r\\n)" ); 38 | nonascii = true; 39 | } 40 | 41 | // Ensure only ASCII chars so script tags don't need a charset attribute 42 | if ( text.length !== Buffer.byteLength( text, "utf8" ) ) { 43 | grunt.log.writeln( filename + ": Non-ASCII characters detected:" ); 44 | for ( i = 0; i < text.length; i++ ) { 45 | c = text.charCodeAt( i ); 46 | if ( c > 127 ) { 47 | grunt.log.writeln( "- position " + i + ": " + c ); 48 | grunt.log.writeln( "-- " + text.substring( i - 20, i + 20 ) ); 49 | break; 50 | } 51 | } 52 | nonascii = true; 53 | } 54 | 55 | // Optionally copy dist files to other locations 56 | paths.forEach(function( path ) { 57 | var created; 58 | 59 | if ( !/\/$/.test( path ) ) { 60 | path += "/"; 61 | } 62 | 63 | created = path + filename.replace( "dist/", "" ); 64 | grunt.file.write( created, text ); 65 | grunt.log.writeln( "File '" + created + "' created." ); 66 | }); 67 | }); 68 | 69 | return !nonascii; 70 | }); 71 | }; 72 | -------------------------------------------------------------------------------- /build/tasks/testswarm.js: -------------------------------------------------------------------------------- 1 | module.exports = function( grunt ) { 2 | 3 | "use strict"; 4 | 5 | grunt.registerTask( "testswarm", function( commit, configFile, projectName, browserSets, 6 | timeout ) { 7 | var jobName, config, tests, 8 | testswarm = require( "testswarm" ), 9 | runs = {}, 10 | done = this.async(), 11 | pull = /PR-(\d+)/.exec( commit ); 12 | 13 | projectName = projectName || "jquery"; 14 | config = grunt.file.readJSON( configFile )[ projectName ]; 15 | browserSets = browserSets || config.browserSets; 16 | if ( browserSets[ 0 ] === "[" ) { 17 | // We got an array, parse it 18 | browserSets = JSON.parse( browserSets ); 19 | } 20 | timeout = timeout || 1000 * 60 * 15; 21 | tests = grunt.config([ this.name, "tests" ]); 22 | 23 | if ( pull ) { 24 | jobName = "Pull #" + pull[ 1 ] + ""; 26 | } else { 27 | jobName = "Commit " + commit.substr( 0, 10 ) + ""; 29 | } 30 | 31 | tests.forEach(function( test ) { 32 | runs[ test ] = config.testUrl + commit + "/test/index.html?module=" + test; 33 | }); 34 | 35 | testswarm.createClient({ 36 | url: config.swarmUrl 37 | } ) 38 | .addReporter( testswarm.reporters.cli ) 39 | .auth( { 40 | id: config.authUsername, 41 | token: config.authToken 42 | }) 43 | .addjob( 44 | { 45 | name: jobName, 46 | runs: runs, 47 | runMax: config.runMax, 48 | browserSets: browserSets, 49 | timeout: timeout 50 | }, function( err, passed ) { 51 | if ( err ) { 52 | grunt.log.error( err ); 53 | } 54 | done( passed ); 55 | } 56 | ); 57 | }); 58 | }; 59 | -------------------------------------------------------------------------------- /html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 |
10 | 11 | -------------------------------------------------------------------------------- /html/index2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
FAIL
5 | 17 | 18 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery", 3 | "title": "jQuery", 4 | "description": "JavaScript library for DOM operations", 5 | "version": "1.11.3", 6 | "main": "dist/jquery.js", 7 | "homepage": "http://jquery.com", 8 | "author": { 9 | "name": "jQuery Foundation and other contributors", 10 | "url": "https://github.com/jquery/jquery/blob/1.11.3/AUTHORS.txt" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "https://github.com/jquery/jquery.git" 15 | }, 16 | "keywords": [ 17 | "jquery", 18 | "javascript", 19 | "browser", 20 | "library" 21 | ], 22 | "bugs": { 23 | "url": "http://bugs.jquery.com" 24 | }, 25 | "licenses": [ 26 | { 27 | "type": "MIT", 28 | "url": "https://github.com/jquery/jquery/blob/1.11.3/MIT-LICENSE.txt" 29 | } 30 | ], 31 | "dependencies": {}, 32 | "devDependencies": { 33 | "commitplease": "2.0.0", 34 | "grunt": "0.4.2", 35 | "grunt-bowercopy": "0.7.1", 36 | "grunt-cli": "0.1.13", 37 | "grunt-compare-size": "0.4.0", 38 | "grunt-contrib-jshint": "0.8.0", 39 | "grunt-contrib-uglify": "0.3.2", 40 | "grunt-contrib-watch": "0.5.3", 41 | "grunt-git-authors": "1.2.0", 42 | "grunt-jscs-checker": "0.4.1", 43 | "grunt-jsonlint": "1.0.4", 44 | "gzip-js": "0.3.2", 45 | "load-grunt-tasks": "0.3.0", 46 | "requirejs": "2.1.10", 47 | "testswarm": "1.1.0" 48 | }, 49 | "scripts": { 50 | "build": "npm install && grunt", 51 | "start": "grunt watch", 52 | "test": "grunt" 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "boss": true, 3 | "curly": true, 4 | "eqeqeq": true, 5 | "eqnull": true, 6 | "expr": true, 7 | "immed": true, 8 | "noarg": true, 9 | "onevar": true, 10 | "quotmark": "double", 11 | "smarttabs": true, 12 | "trailing": true, 13 | "undef": true, 14 | "unused": true, 15 | 16 | "evil": true, 17 | "sub": true, 18 | 19 | "es3": true, 20 | "browser": true, 21 | "wsh": true, 22 | 23 | "globals": { 24 | "jQuery": true, 25 | "define": true, 26 | "module": true 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/ajax/jsonp.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../core", 3 | "./var/nonce", 4 | "./var/rquery", 5 | "../ajax" 6 | ], function( jQuery, nonce, rquery ) { 7 | 8 | var oldCallbacks = [], 9 | rjsonp = /(=)\?(?=&|$)|\?\?/; 10 | 11 | // Default jsonp settings 12 | jQuery.ajaxSetup({ 13 | jsonp: "callback", 14 | jsonpCallback: function() { 15 | var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) ); 16 | this[ callback ] = true; 17 | return callback; 18 | } 19 | }); 20 | 21 | // Detect, normalize options and install callbacks for jsonp requests 22 | jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { 23 | 24 | var callbackName, overwritten, responseContainer, 25 | jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ? 26 | "url" : 27 | typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data" 28 | ); 29 | 30 | // Handle iff the expected data type is "jsonp" or we have a parameter to set 31 | if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) { 32 | 33 | // Get callback name, remembering preexisting value associated with it 34 | callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ? 35 | s.jsonpCallback() : 36 | s.jsonpCallback; 37 | 38 | // Insert callback into url or form data 39 | if ( jsonProp ) { 40 | s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName ); 41 | } else if ( s.jsonp !== false ) { 42 | s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName; 43 | } 44 | 45 | // Use data converter to retrieve json after script execution 46 | s.converters["script json"] = function() { 47 | if ( !responseContainer ) { 48 | jQuery.error( callbackName + " was not called" ); 49 | } 50 | return responseContainer[ 0 ]; 51 | }; 52 | 53 | // force json dataType 54 | s.dataTypes[ 0 ] = "json"; 55 | 56 | // Install callback 57 | overwritten = window[ callbackName ]; 58 | window[ callbackName ] = function() { 59 | responseContainer = arguments; 60 | }; 61 | 62 | // Clean-up function (fires after converters) 63 | jqXHR.always(function() { 64 | // Restore preexisting value 65 | window[ callbackName ] = overwritten; 66 | 67 | // Save back as free 68 | if ( s[ callbackName ] ) { 69 | // make sure that re-using the options doesn't screw things around 70 | s.jsonpCallback = originalSettings.jsonpCallback; 71 | 72 | // save the callback name for future use 73 | oldCallbacks.push( callbackName ); 74 | } 75 | 76 | // Call if it was a function and we have a response 77 | if ( responseContainer && jQuery.isFunction( overwritten ) ) { 78 | overwritten( responseContainer[ 0 ] ); 79 | } 80 | 81 | responseContainer = overwritten = undefined; 82 | }); 83 | 84 | // Delegate to script 85 | return "script"; 86 | } 87 | }); 88 | 89 | }); 90 | -------------------------------------------------------------------------------- /src/ajax/load.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../core", 3 | "../core/parseHTML", 4 | "../ajax", 5 | "../traversing", 6 | "../manipulation", 7 | "../selector", 8 | // Optional event/alias dependency 9 | "../event/alias" 10 | ], function( jQuery ) { 11 | 12 | // Keep a copy of the old load method 13 | var _load = jQuery.fn.load; 14 | 15 | /** 16 | * Load a url into a page 17 | */ 18 | jQuery.fn.load = function( url, params, callback ) { 19 | if ( typeof url !== "string" && _load ) { 20 | return _load.apply( this, arguments ); 21 | } 22 | 23 | var selector, response, type, 24 | self = this, 25 | off = url.indexOf(" "); 26 | 27 | if ( off >= 0 ) { 28 | selector = jQuery.trim( url.slice( off, url.length ) ); 29 | url = url.slice( 0, off ); 30 | } 31 | 32 | // If it's a function 33 | if ( jQuery.isFunction( params ) ) { 34 | 35 | // We assume that it's the callback 36 | callback = params; 37 | params = undefined; 38 | 39 | // Otherwise, build a param string 40 | } else if ( params && typeof params === "object" ) { 41 | type = "POST"; 42 | } 43 | 44 | // If we have elements to modify, make the request 45 | if ( self.length > 0 ) { 46 | jQuery.ajax({ 47 | url: url, 48 | 49 | // if "type" variable is undefined, then "GET" method will be used 50 | type: type, 51 | dataType: "html", 52 | data: params 53 | }).done(function( responseText ) { 54 | 55 | // Save response for use in complete callback 56 | response = arguments; 57 | 58 | self.html( selector ? 59 | 60 | // If a selector was specified, locate the right elements in a dummy div 61 | // Exclude scripts to avoid IE 'Permission Denied' errors 62 | jQuery("
").append( jQuery.parseHTML( responseText ) ).find( selector ) : 63 | 64 | // Otherwise use the full result 65 | responseText ); 66 | 67 | }).complete( callback && function( jqXHR, status ) { 68 | self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] ); 69 | }); 70 | } 71 | 72 | return this; 73 | }; 74 | 75 | }); 76 | -------------------------------------------------------------------------------- /src/ajax/parseJSON.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../core" 3 | ], function( jQuery ) { 4 | 5 | var rvalidtokens = /(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g; 6 | 7 | jQuery.parseJSON = function( data ) { 8 | // Attempt to parse using the native JSON parser first 9 | if ( window.JSON && window.JSON.parse ) { 10 | // Support: Android 2.3 11 | // Workaround failure to string-cast null input 12 | return window.JSON.parse( data + "" ); 13 | } 14 | 15 | var requireNonComma, 16 | depth = null, 17 | str = jQuery.trim( data + "" ); 18 | 19 | // Guard against invalid (and possibly dangerous) input by ensuring that nothing remains 20 | // after removing valid tokens 21 | return str && !jQuery.trim( str.replace( rvalidtokens, function( token, comma, open, close ) { 22 | 23 | // Force termination if we see a misplaced comma 24 | if ( requireNonComma && comma ) { 25 | depth = 0; 26 | } 27 | 28 | // Perform no more replacements after returning to outermost depth 29 | if ( depth === 0 ) { 30 | return token; 31 | } 32 | 33 | // Commas must not follow "[", "{", or "," 34 | requireNonComma = open || comma; 35 | 36 | // Determine new depth 37 | // array/object open ("[" or "{"): depth += true - false (increment) 38 | // array/object close ("]" or "}"): depth += false - true (decrement) 39 | // other cases ("," or primitive): depth += true - true (numeric cast) 40 | depth += !close - !open; 41 | 42 | // Remove this token 43 | return ""; 44 | }) ) ? 45 | ( Function( "return " + str ) )() : 46 | jQuery.error( "Invalid JSON: " + data ); 47 | }; 48 | 49 | return jQuery.parseJSON; 50 | 51 | }); 52 | -------------------------------------------------------------------------------- /src/ajax/parseXML.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../core" 3 | ], function( jQuery ) { 4 | 5 | // Cross-browser xml parsing 6 | jQuery.parseXML = function( data ) { 7 | var xml, tmp; 8 | if ( !data || typeof data !== "string" ) { 9 | return null; 10 | } 11 | try { 12 | if ( window.DOMParser ) { // Standard 13 | tmp = new DOMParser(); 14 | xml = tmp.parseFromString( data, "text/xml" ); 15 | } else { // IE 16 | xml = new ActiveXObject( "Microsoft.XMLDOM" ); 17 | xml.async = "false"; 18 | xml.loadXML( data ); 19 | } 20 | } catch( e ) { 21 | xml = undefined; 22 | } 23 | if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) { 24 | jQuery.error( "Invalid XML: " + data ); 25 | } 26 | return xml; 27 | }; 28 | 29 | return jQuery.parseXML; 30 | 31 | }); 32 | -------------------------------------------------------------------------------- /src/ajax/script.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../core", 3 | "../ajax" 4 | ], function( jQuery ) { 5 | 6 | // Install script dataType 7 | jQuery.ajaxSetup({ 8 | accepts: { 9 | script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript" 10 | }, 11 | contents: { 12 | script: /(?:java|ecma)script/ 13 | }, 14 | converters: { 15 | "text script": function( text ) { 16 | jQuery.globalEval( text ); 17 | return text; 18 | } 19 | } 20 | }); 21 | 22 | // Handle cache's special case and global 23 | jQuery.ajaxPrefilter( "script", function( s ) { 24 | if ( s.cache === undefined ) { 25 | s.cache = false; 26 | } 27 | if ( s.crossDomain ) { 28 | s.type = "GET"; 29 | s.global = false; 30 | } 31 | }); 32 | 33 | // Bind script tag hack transport 34 | jQuery.ajaxTransport( "script", function(s) { 35 | 36 | // This transport only deals with cross domain requests 37 | if ( s.crossDomain ) { 38 | 39 | var script, 40 | head = document.head || jQuery("head")[0] || document.documentElement; 41 | 42 | return { 43 | 44 | send: function( _, callback ) { 45 | 46 | script = document.createElement("script"); 47 | 48 | script.async = true; 49 | 50 | if ( s.scriptCharset ) { 51 | script.charset = s.scriptCharset; 52 | } 53 | 54 | script.src = s.url; 55 | 56 | // Attach handlers for all browsers 57 | script.onload = script.onreadystatechange = function( _, isAbort ) { 58 | 59 | if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) { 60 | 61 | // Handle memory leak in IE 62 | script.onload = script.onreadystatechange = null; 63 | 64 | // Remove the script 65 | if ( script.parentNode ) { 66 | script.parentNode.removeChild( script ); 67 | } 68 | 69 | // Dereference the script 70 | script = null; 71 | 72 | // Callback if not abort 73 | if ( !isAbort ) { 74 | callback( 200, "success" ); 75 | } 76 | } 77 | }; 78 | 79 | // Circumvent IE6 bugs with base elements (#2709 and #4378) by prepending 80 | // Use native DOM manipulation to avoid our domManip AJAX trickery 81 | head.insertBefore( script, head.firstChild ); 82 | }, 83 | 84 | abort: function() { 85 | if ( script ) { 86 | script.onload( undefined, true ); 87 | } 88 | } 89 | }; 90 | } 91 | }); 92 | 93 | }); 94 | -------------------------------------------------------------------------------- /src/ajax/var/nonce.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../../core" 3 | ], function( jQuery ) { 4 | return jQuery.now(); 5 | }); 6 | -------------------------------------------------------------------------------- /src/ajax/var/rquery.js: -------------------------------------------------------------------------------- 1 | define(function() { 2 | return (/\?/); 3 | }); 4 | -------------------------------------------------------------------------------- /src/attributes.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "./core", 3 | "./attributes/val", 4 | "./attributes/attr", 5 | "./attributes/prop", 6 | "./attributes/classes" 7 | ], function( jQuery ) { 8 | 9 | // Return jQuery for attributes-only inclusion 10 | return jQuery; 11 | }); 12 | -------------------------------------------------------------------------------- /src/attributes/classes.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../core", 3 | "../var/rnotwhite", 4 | "../var/strundefined", 5 | "../core/init" 6 | ], function( jQuery, rnotwhite, strundefined ) { 7 | 8 | var rclass = /[\t\r\n\f]/g; 9 | 10 | jQuery.fn.extend({ 11 | addClass: function( value ) { 12 | var classes, elem, cur, clazz, j, finalValue, 13 | i = 0, 14 | len = this.length, 15 | proceed = typeof value === "string" && value; 16 | 17 | if ( jQuery.isFunction( value ) ) { 18 | return this.each(function( j ) { 19 | jQuery( this ).addClass( value.call( this, j, this.className ) ); 20 | }); 21 | } 22 | 23 | if ( proceed ) { 24 | // The disjunction here is for better compressibility (see removeClass) 25 | classes = ( value || "" ).match( rnotwhite ) || []; 26 | 27 | for ( ; i < len; i++ ) { 28 | elem = this[ i ]; 29 | cur = elem.nodeType === 1 && ( elem.className ? 30 | ( " " + elem.className + " " ).replace( rclass, " " ) : 31 | " " 32 | ); 33 | 34 | if ( cur ) { 35 | j = 0; 36 | while ( (clazz = classes[j++]) ) { 37 | if ( cur.indexOf( " " + clazz + " " ) < 0 ) { 38 | cur += clazz + " "; 39 | } 40 | } 41 | 42 | // only assign if different to avoid unneeded rendering. 43 | finalValue = jQuery.trim( cur ); 44 | if ( elem.className !== finalValue ) { 45 | elem.className = finalValue; 46 | } 47 | } 48 | } 49 | } 50 | 51 | return this; 52 | }, 53 | 54 | removeClass: function( value ) { 55 | var classes, elem, cur, clazz, j, finalValue, 56 | i = 0, 57 | len = this.length, 58 | proceed = arguments.length === 0 || typeof value === "string" && value; 59 | 60 | if ( jQuery.isFunction( value ) ) { 61 | return this.each(function( j ) { 62 | jQuery( this ).removeClass( value.call( this, j, this.className ) ); 63 | }); 64 | } 65 | if ( proceed ) { 66 | classes = ( value || "" ).match( rnotwhite ) || []; 67 | 68 | for ( ; i < len; i++ ) { 69 | elem = this[ i ]; 70 | // This expression is here for better compressibility (see addClass) 71 | cur = elem.nodeType === 1 && ( elem.className ? 72 | ( " " + elem.className + " " ).replace( rclass, " " ) : 73 | "" 74 | ); 75 | 76 | if ( cur ) { 77 | j = 0; 78 | while ( (clazz = classes[j++]) ) { 79 | // Remove *all* instances 80 | while ( cur.indexOf( " " + clazz + " " ) >= 0 ) { 81 | cur = cur.replace( " " + clazz + " ", " " ); 82 | } 83 | } 84 | 85 | // only assign if different to avoid unneeded rendering. 86 | finalValue = value ? jQuery.trim( cur ) : ""; 87 | if ( elem.className !== finalValue ) { 88 | elem.className = finalValue; 89 | } 90 | } 91 | } 92 | } 93 | 94 | return this; 95 | }, 96 | 97 | toggleClass: function( value, stateVal ) { 98 | var type = typeof value; 99 | 100 | if ( typeof stateVal === "boolean" && type === "string" ) { 101 | return stateVal ? this.addClass( value ) : this.removeClass( value ); 102 | } 103 | 104 | if ( jQuery.isFunction( value ) ) { 105 | return this.each(function( i ) { 106 | jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal ); 107 | }); 108 | } 109 | 110 | return this.each(function() { 111 | if ( type === "string" ) { 112 | // toggle individual class names 113 | var className, 114 | i = 0, 115 | self = jQuery( this ), 116 | classNames = value.match( rnotwhite ) || []; 117 | 118 | while ( (className = classNames[ i++ ]) ) { 119 | // check each className given, space separated list 120 | if ( self.hasClass( className ) ) { 121 | self.removeClass( className ); 122 | } else { 123 | self.addClass( className ); 124 | } 125 | } 126 | 127 | // Toggle whole class name 128 | } else if ( type === strundefined || type === "boolean" ) { 129 | if ( this.className ) { 130 | // store className if set 131 | jQuery._data( this, "__className__", this.className ); 132 | } 133 | 134 | // If the element has a class name or if we're passed "false", 135 | // then remove the whole classname (if there was one, the above saved it). 136 | // Otherwise bring back whatever was previously saved (if anything), 137 | // falling back to the empty string if nothing was stored. 138 | this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || ""; 139 | } 140 | }); 141 | }, 142 | 143 | hasClass: function( selector ) { 144 | var className = " " + selector + " ", 145 | i = 0, 146 | l = this.length; 147 | for ( ; i < l; i++ ) { 148 | if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) { 149 | return true; 150 | } 151 | } 152 | 153 | return false; 154 | } 155 | }); 156 | 157 | }); 158 | -------------------------------------------------------------------------------- /src/attributes/prop.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../core", 3 | "../core/access", 4 | "./support" 5 | ], function( jQuery, access, support ) { 6 | 7 | var rfocusable = /^(?:input|select|textarea|button|object)$/i, 8 | rclickable = /^(?:a|area)$/i; 9 | 10 | jQuery.fn.extend({ 11 | prop: function( name, value ) { 12 | return access( this, jQuery.prop, name, value, arguments.length > 1 ); 13 | }, 14 | 15 | removeProp: function( name ) { 16 | name = jQuery.propFix[ name ] || name; 17 | return this.each(function() { 18 | // try/catch handles cases where IE balks (such as removing a property on window) 19 | try { 20 | this[ name ] = undefined; 21 | delete this[ name ]; 22 | } catch( e ) {} 23 | }); 24 | } 25 | }); 26 | 27 | jQuery.extend({ 28 | propFix: { 29 | "for": "htmlFor", 30 | "class": "className" 31 | }, 32 | 33 | prop: function( elem, name, value ) { 34 | var ret, hooks, notxml, 35 | nType = elem.nodeType; 36 | 37 | // don't get/set properties on text, comment and attribute nodes 38 | if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { 39 | return; 40 | } 41 | 42 | notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); 43 | 44 | if ( notxml ) { 45 | // Fix name and attach hooks 46 | name = jQuery.propFix[ name ] || name; 47 | hooks = jQuery.propHooks[ name ]; 48 | } 49 | 50 | if ( value !== undefined ) { 51 | return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ? 52 | ret : 53 | ( elem[ name ] = value ); 54 | 55 | } else { 56 | return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ? 57 | ret : 58 | elem[ name ]; 59 | } 60 | }, 61 | 62 | propHooks: { 63 | tabIndex: { 64 | get: function( elem ) { 65 | // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set 66 | // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ 67 | // Use proper attribute retrieval(#12072) 68 | var tabindex = jQuery.find.attr( elem, "tabindex" ); 69 | 70 | return tabindex ? 71 | parseInt( tabindex, 10 ) : 72 | rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? 73 | 0 : 74 | -1; 75 | } 76 | } 77 | } 78 | }); 79 | 80 | // Some attributes require a special call on IE 81 | // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx 82 | if ( !support.hrefNormalized ) { 83 | // href/src property should get the full normalized URL (#10299/#12915) 84 | jQuery.each([ "href", "src" ], function( i, name ) { 85 | jQuery.propHooks[ name ] = { 86 | get: function( elem ) { 87 | return elem.getAttribute( name, 4 ); 88 | } 89 | }; 90 | }); 91 | } 92 | 93 | // Support: Safari, IE9+ 94 | // mis-reports the default selected property of an option 95 | // Accessing the parent's selectedIndex property fixes it 96 | if ( !support.optSelected ) { 97 | jQuery.propHooks.selected = { 98 | get: function( elem ) { 99 | var parent = elem.parentNode; 100 | 101 | if ( parent ) { 102 | parent.selectedIndex; 103 | 104 | // Make sure that it also works with optgroups, see #5701 105 | if ( parent.parentNode ) { 106 | parent.parentNode.selectedIndex; 107 | } 108 | } 109 | return null; 110 | } 111 | }; 112 | } 113 | 114 | jQuery.each([ 115 | "tabIndex", 116 | "readOnly", 117 | "maxLength", 118 | "cellSpacing", 119 | "cellPadding", 120 | "rowSpan", 121 | "colSpan", 122 | "useMap", 123 | "frameBorder", 124 | "contentEditable" 125 | ], function() { 126 | jQuery.propFix[ this.toLowerCase() ] = this; 127 | }); 128 | 129 | // IE6/7 call enctype encoding 130 | if ( !support.enctype ) { 131 | jQuery.propFix.enctype = "encoding"; 132 | } 133 | 134 | }); 135 | -------------------------------------------------------------------------------- /src/attributes/support.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../var/support" 3 | ], function( support ) { 4 | 5 | (function() { 6 | // Minified: var a,b,c,d,e 7 | var input, div, select, a, opt; 8 | 9 | // Setup 10 | div = document.createElement( "div" ); 11 | div.setAttribute( "className", "t" ); 12 | div.innerHTML = "
a"; 13 | a = div.getElementsByTagName("a")[ 0 ]; 14 | 15 | // First batch of tests. 16 | select = document.createElement("select"); 17 | opt = select.appendChild( document.createElement("option") ); 18 | input = div.getElementsByTagName("input")[ 0 ]; 19 | 20 | a.style.cssText = "top:1px"; 21 | 22 | // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7) 23 | support.getSetAttribute = div.className !== "t"; 24 | 25 | // Get the style information from getAttribute 26 | // (IE uses .cssText instead) 27 | support.style = /top/.test( a.getAttribute("style") ); 28 | 29 | // Make sure that URLs aren't manipulated 30 | // (IE normalizes it by default) 31 | support.hrefNormalized = a.getAttribute("href") === "/a"; 32 | 33 | // Check the default checkbox/radio value ("" on WebKit; "on" elsewhere) 34 | support.checkOn = !!input.value; 35 | 36 | // Make sure that a selected-by-default option has a working selected property. 37 | // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) 38 | support.optSelected = opt.selected; 39 | 40 | // Tests for enctype support on a form (#6743) 41 | support.enctype = !!document.createElement("form").enctype; 42 | 43 | // Make sure that the options inside disabled selects aren't marked as disabled 44 | // (WebKit marks them as disabled) 45 | select.disabled = true; 46 | support.optDisabled = !opt.disabled; 47 | 48 | // Support: IE8 only 49 | // Check if we can trust getAttribute("value") 50 | input = document.createElement( "input" ); 51 | input.setAttribute( "value", "" ); 52 | support.input = input.getAttribute( "value" ) === ""; 53 | 54 | // Check if an input maintains its value after becoming a radio 55 | input.value = "t"; 56 | input.setAttribute( "type", "radio" ); 57 | support.radioValue = input.value === "t"; 58 | })(); 59 | 60 | return support; 61 | 62 | }); 63 | -------------------------------------------------------------------------------- /src/attributes/val.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../core", 3 | "./support", 4 | "../core/init" 5 | ], function( jQuery, support ) { 6 | 7 | var rreturn = /\r/g; 8 | 9 | jQuery.fn.extend({ 10 | val: function( value ) { 11 | var hooks, ret, isFunction, 12 | elem = this[0]; 13 | 14 | if ( !arguments.length ) { 15 | if ( elem ) { 16 | hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ]; 17 | 18 | if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { 19 | return ret; 20 | } 21 | 22 | ret = elem.value; 23 | 24 | return typeof ret === "string" ? 25 | // handle most common string cases 26 | ret.replace(rreturn, "") : 27 | // handle cases where value is null/undef or number 28 | ret == null ? "" : ret; 29 | } 30 | 31 | return; 32 | } 33 | 34 | isFunction = jQuery.isFunction( value ); 35 | 36 | return this.each(function( i ) { 37 | var val; 38 | 39 | if ( this.nodeType !== 1 ) { 40 | return; 41 | } 42 | 43 | if ( isFunction ) { 44 | val = value.call( this, i, jQuery( this ).val() ); 45 | } else { 46 | val = value; 47 | } 48 | 49 | // Treat null/undefined as ""; convert numbers to string 50 | if ( val == null ) { 51 | val = ""; 52 | } else if ( typeof val === "number" ) { 53 | val += ""; 54 | } else if ( jQuery.isArray( val ) ) { 55 | val = jQuery.map( val, function( value ) { 56 | return value == null ? "" : value + ""; 57 | }); 58 | } 59 | 60 | hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; 61 | 62 | // If set returns undefined, fall back to normal setting 63 | if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) { 64 | this.value = val; 65 | } 66 | }); 67 | } 68 | }); 69 | 70 | jQuery.extend({ 71 | valHooks: { 72 | option: { 73 | get: function( elem ) { 74 | var val = jQuery.find.attr( elem, "value" ); 75 | return val != null ? 76 | val : 77 | // Support: IE10-11+ 78 | // option.text throws exceptions (#14686, #14858) 79 | jQuery.trim( jQuery.text( elem ) ); 80 | } 81 | }, 82 | select: { 83 | get: function( elem ) { 84 | var value, option, 85 | options = elem.options, 86 | index = elem.selectedIndex, 87 | one = elem.type === "select-one" || index < 0, 88 | values = one ? null : [], 89 | max = one ? index + 1 : options.length, 90 | i = index < 0 ? 91 | max : 92 | one ? index : 0; 93 | 94 | // Loop through all the selected options 95 | for ( ; i < max; i++ ) { 96 | option = options[ i ]; 97 | 98 | // oldIE doesn't update selected after form reset (#2551) 99 | if ( ( option.selected || i === index ) && 100 | // Don't return options that are disabled or in a disabled optgroup 101 | ( support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) && 102 | ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) { 103 | 104 | // Get the specific value for the option 105 | value = jQuery( option ).val(); 106 | 107 | // We don't need an array for one selects 108 | if ( one ) { 109 | return value; 110 | } 111 | 112 | // Multi-Selects return an array 113 | values.push( value ); 114 | } 115 | } 116 | 117 | return values; 118 | }, 119 | 120 | set: function( elem, value ) { 121 | var optionSet, option, 122 | options = elem.options, 123 | values = jQuery.makeArray( value ), 124 | i = options.length; 125 | 126 | while ( i-- ) { 127 | option = options[ i ]; 128 | 129 | if ( jQuery.inArray( jQuery.valHooks.option.get( option ), values ) >= 0 ) { 130 | 131 | // Support: IE6 132 | // When new option element is added to select box we need to 133 | // force reflow of newly added node in order to workaround delay 134 | // of initialization properties 135 | try { 136 | option.selected = optionSet = true; 137 | 138 | } catch ( _ ) { 139 | 140 | // Will be executed only in IE6 141 | option.scrollHeight; 142 | } 143 | 144 | } else { 145 | option.selected = false; 146 | } 147 | } 148 | 149 | // Force browsers to behave consistently when non-matching value is set 150 | if ( !optionSet ) { 151 | elem.selectedIndex = -1; 152 | } 153 | 154 | return options; 155 | } 156 | } 157 | } 158 | }); 159 | 160 | // Radios and checkboxes getter/setter 161 | jQuery.each([ "radio", "checkbox" ], function() { 162 | jQuery.valHooks[ this ] = { 163 | set: function( elem, value ) { 164 | if ( jQuery.isArray( value ) ) { 165 | return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 ); 166 | } 167 | } 168 | }; 169 | if ( !support.checkOn ) { 170 | jQuery.valHooks[ this ].get = function( elem ) { 171 | // Support: Webkit 172 | // "" is returned instead of "on" if a value isn't specified 173 | return elem.getAttribute("value") === null ? "on" : elem.value; 174 | }; 175 | } 176 | }); 177 | 178 | }); 179 | -------------------------------------------------------------------------------- /src/callbacks.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "./core", 3 | "./var/rnotwhite" 4 | ], function( jQuery, rnotwhite ) { 5 | 6 | // String to Object options format cache 7 | var optionsCache = {}; 8 | 9 | // Convert String-formatted options into Object-formatted ones and store in cache 10 | function createOptions( options ) { 11 | var object = optionsCache[ options ] = {}; 12 | jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) { 13 | object[ flag ] = true; 14 | }); 15 | return object; 16 | } 17 | 18 | /* 19 | * Create a callback list using the following parameters: 20 | * 21 | * options: an optional list of space-separated options that will change how 22 | * the callback list behaves or a more traditional option object 23 | * 24 | * By default a callback list will act like an event callback list and can be 25 | * "fired" multiple times. 26 | * 27 | * Possible options: 28 | * 29 | * once: will ensure the callback list can only be fired once (like a Deferred) 30 | * 31 | * memory: will keep track of previous values and will call any callback added 32 | * after the list has been fired right away with the latest "memorized" 33 | * values (like a Deferred) 34 | * 35 | * unique: will ensure a callback can only be added once (no duplicate in the list) 36 | * 37 | * stopOnFalse: interrupt callings when a callback returns false 38 | * 39 | */ 40 | jQuery.Callbacks = function( options ) { 41 | 42 | // Convert options from String-formatted to Object-formatted if needed 43 | // (we check in cache first) 44 | options = typeof options === "string" ? 45 | ( optionsCache[ options ] || createOptions( options ) ) : 46 | jQuery.extend( {}, options ); 47 | 48 | var // Flag to know if list is currently firing 49 | firing, 50 | // Last fire value (for non-forgettable lists) 51 | memory, 52 | // Flag to know if list was already fired 53 | fired, 54 | // End of the loop when firing 55 | firingLength, 56 | // Index of currently firing callback (modified by remove if needed) 57 | firingIndex, 58 | // First callback to fire (used internally by add and fireWith) 59 | firingStart, 60 | // Actual callback list 61 | list = [], 62 | // Stack of fire calls for repeatable lists 63 | stack = !options.once && [], 64 | // Fire callbacks 65 | fire = function( data ) { 66 | memory = options.memory && data; 67 | fired = true; 68 | firingIndex = firingStart || 0; 69 | firingStart = 0; 70 | firingLength = list.length; 71 | firing = true; 72 | for ( ; list && firingIndex < firingLength; firingIndex++ ) { 73 | if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) { 74 | memory = false; // To prevent further calls using add 75 | break; 76 | } 77 | } 78 | firing = false; 79 | if ( list ) { 80 | if ( stack ) { 81 | if ( stack.length ) { 82 | fire( stack.shift() ); 83 | } 84 | } else if ( memory ) { 85 | list = []; 86 | } else { 87 | self.disable(); 88 | } 89 | } 90 | }, 91 | // Actual Callbacks object 92 | self = { 93 | // Add a callback or a collection of callbacks to the list 94 | add: function() { 95 | if ( list ) { 96 | // First, we save the current length 97 | var start = list.length; 98 | (function add( args ) { 99 | jQuery.each( args, function( _, arg ) { 100 | var type = jQuery.type( arg ); 101 | if ( type === "function" ) { 102 | if ( !options.unique || !self.has( arg ) ) { 103 | list.push( arg ); 104 | } 105 | } else if ( arg && arg.length && type !== "string" ) { 106 | // Inspect recursively 107 | add( arg ); 108 | } 109 | }); 110 | })( arguments ); 111 | // Do we need to add the callbacks to the 112 | // current firing batch? 113 | if ( firing ) { 114 | firingLength = list.length; 115 | // With memory, if we're not firing then 116 | // we should call right away 117 | } else if ( memory ) { 118 | firingStart = start; 119 | fire( memory ); 120 | } 121 | } 122 | return this; 123 | }, 124 | // Remove a callback from the list 125 | remove: function() { 126 | if ( list ) { 127 | jQuery.each( arguments, function( _, arg ) { 128 | var index; 129 | while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { 130 | list.splice( index, 1 ); 131 | // Handle firing indexes 132 | if ( firing ) { 133 | if ( index <= firingLength ) { 134 | firingLength--; 135 | } 136 | if ( index <= firingIndex ) { 137 | firingIndex--; 138 | } 139 | } 140 | } 141 | }); 142 | } 143 | return this; 144 | }, 145 | // Check if a given callback is in the list. 146 | // If no argument is given, return whether or not list has callbacks attached. 147 | has: function( fn ) { 148 | return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length ); 149 | }, 150 | // Remove all callbacks from the list 151 | empty: function() { 152 | list = []; 153 | firingLength = 0; 154 | return this; 155 | }, 156 | // Have the list do nothing anymore 157 | disable: function() { 158 | list = stack = memory = undefined; 159 | return this; 160 | }, 161 | // Is it disabled? 162 | disabled: function() { 163 | return !list; 164 | }, 165 | // Lock the list in its current state 166 | lock: function() { 167 | stack = undefined; 168 | if ( !memory ) { 169 | self.disable(); 170 | } 171 | return this; 172 | }, 173 | // Is it locked? 174 | locked: function() { 175 | return !stack; 176 | }, 177 | // Call all callbacks with the given context and arguments 178 | fireWith: function( context, args ) { 179 | if ( list && ( !fired || stack ) ) { 180 | args = args || []; 181 | args = [ context, args.slice ? args.slice() : args ]; 182 | if ( firing ) { 183 | stack.push( args ); 184 | } else { 185 | fire( args ); 186 | } 187 | } 188 | return this; 189 | }, 190 | // Call all the callbacks with the given arguments 191 | fire: function() { 192 | self.fireWith( this, arguments ); 193 | return this; 194 | }, 195 | // To know if the callbacks have already been called at least once 196 | fired: function() { 197 | return !!fired; 198 | } 199 | }; 200 | 201 | return self; 202 | }; 203 | 204 | return jQuery; 205 | }); 206 | -------------------------------------------------------------------------------- /src/core/access.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../core" 3 | ], function( jQuery ) { 4 | 5 | // Multifunctional method to get and set values of a collection 6 | // The value/s can optionally be executed if it's a function 7 | var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) { 8 | var i = 0, 9 | length = elems.length, 10 | bulk = key == null; 11 | 12 | // Sets many values 13 | if ( jQuery.type( key ) === "object" ) { 14 | chainable = true; 15 | for ( i in key ) { 16 | jQuery.access( elems, fn, i, key[i], true, emptyGet, raw ); 17 | } 18 | 19 | // Sets one value 20 | } else if ( value !== undefined ) { 21 | chainable = true; 22 | 23 | if ( !jQuery.isFunction( value ) ) { 24 | raw = true; 25 | } 26 | 27 | if ( bulk ) { 28 | // Bulk operations run against the entire set 29 | if ( raw ) { 30 | fn.call( elems, value ); 31 | fn = null; 32 | 33 | // ...except when executing function values 34 | } else { 35 | bulk = fn; 36 | fn = function( elem, key, value ) { 37 | return bulk.call( jQuery( elem ), value ); 38 | }; 39 | } 40 | } 41 | 42 | if ( fn ) { 43 | for ( ; i < length; i++ ) { 44 | fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) ); 45 | } 46 | } 47 | } 48 | 49 | return chainable ? 50 | elems : 51 | 52 | // Gets 53 | bulk ? 54 | fn.call( elems ) : 55 | length ? fn( elems[0], key ) : emptyGet; 56 | }; 57 | 58 | return access; 59 | 60 | }); 61 | -------------------------------------------------------------------------------- /src/core/init.js: -------------------------------------------------------------------------------- 1 | // Initialize a jQuery object 2 | define([ 3 | "../core", 4 | "./var/rsingleTag", 5 | "../traversing/findFilter" 6 | ], function( jQuery, rsingleTag ) { 7 | 8 | // A central reference to the root jQuery(document) 9 | var rootjQuery, 10 | 11 | // Use the correct document accordingly with window argument (sandbox) 12 | document = window.document, 13 | 14 | // A simple way to check for HTML strings 15 | // Prioritize #id over to avoid XSS via location.hash (#9521) 16 | // Strict HTML recognition (#11290: must start with <) 17 | rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/, 18 | 19 | init = jQuery.fn.init = function( selector, context ) { 20 | var match, elem; 21 | 22 | // HANDLE: $(""), $(null), $(undefined), $(false) 23 | if ( !selector ) { 24 | return this; 25 | } 26 | 27 | // Handle HTML strings 28 | if ( typeof selector === "string" ) { 29 | if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) { 30 | // Assume that strings that start and end with <> are HTML and skip the regex check 31 | match = [ null, selector, null ]; 32 | 33 | } else { 34 | match = rquickExpr.exec( selector ); 35 | } 36 | 37 | // Match html or make sure no context is specified for #id 38 | if ( match && (match[1] || !context) ) { 39 | 40 | // HANDLE: $(html) -> $(array) 41 | if ( match[1] ) { 42 | context = context instanceof jQuery ? context[0] : context; 43 | 44 | // scripts is true for back-compat 45 | // Intentionally let the error be thrown if parseHTML is not present 46 | jQuery.merge( this, jQuery.parseHTML( 47 | match[1], 48 | context && context.nodeType ? context.ownerDocument || context : document, 49 | true 50 | ) ); 51 | 52 | // HANDLE: $(html, props) 53 | if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) { 54 | for ( match in context ) { 55 | // Properties of context are called as methods if possible 56 | if ( jQuery.isFunction( this[ match ] ) ) { 57 | this[ match ]( context[ match ] ); 58 | 59 | // ...and otherwise set as attributes 60 | } else { 61 | this.attr( match, context[ match ] ); 62 | } 63 | } 64 | } 65 | 66 | return this; 67 | 68 | // HANDLE: $(#id) 69 | } else { 70 | elem = document.getElementById( match[2] ); 71 | 72 | // Check parentNode to catch when Blackberry 4.6 returns 73 | // nodes that are no longer in the document #6963 74 | if ( elem && elem.parentNode ) { 75 | // Handle the case where IE and Opera return items 76 | // by name instead of ID 77 | if ( elem.id !== match[2] ) { 78 | return rootjQuery.find( selector ); 79 | } 80 | 81 | // Otherwise, we inject the element directly into the jQuery object 82 | this.length = 1; 83 | this[0] = elem; 84 | } 85 | 86 | this.context = document; 87 | this.selector = selector; 88 | return this; 89 | } 90 | 91 | // HANDLE: $(expr, $(...)) 92 | } else if ( !context || context.jquery ) { 93 | return ( context || rootjQuery ).find( selector ); 94 | 95 | // HANDLE: $(expr, context) 96 | // (which is just equivalent to: $(context).find(expr) 97 | } else { 98 | return this.constructor( context ).find( selector ); 99 | } 100 | 101 | // HANDLE: $(DOMElement) 102 | } else if ( selector.nodeType ) { 103 | this.context = this[0] = selector; 104 | this.length = 1; 105 | return this; 106 | 107 | // HANDLE: $(function) 108 | // Shortcut for document ready 109 | } else if ( jQuery.isFunction( selector ) ) { 110 | return typeof rootjQuery.ready !== "undefined" ? 111 | rootjQuery.ready( selector ) : 112 | // Execute immediately if ready is not present 113 | selector( jQuery ); 114 | } 115 | 116 | if ( selector.selector !== undefined ) { 117 | this.selector = selector.selector; 118 | this.context = selector.context; 119 | } 120 | 121 | return jQuery.makeArray( selector, this ); 122 | }; 123 | 124 | // Give the init function the jQuery prototype for later instantiation 125 | init.prototype = jQuery.fn; 126 | 127 | // Initialize central reference 128 | rootjQuery = jQuery( document ); 129 | 130 | return init; 131 | 132 | }); 133 | -------------------------------------------------------------------------------- /src/core/parseHTML.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../core", 3 | "./var/rsingleTag", 4 | "../manipulation" // buildFragment 5 | ], function( jQuery, rsingleTag ) { 6 | 7 | // data: string of html 8 | // context (optional): If specified, the fragment will be created in this context, defaults to document 9 | // keepScripts (optional): If true, will include scripts passed in the html string 10 | jQuery.parseHTML = function( data, context, keepScripts ) { 11 | if ( !data || typeof data !== "string" ) { 12 | return null; 13 | } 14 | if ( typeof context === "boolean" ) { 15 | keepScripts = context; 16 | context = false; 17 | } 18 | context = context || document; 19 | 20 | var parsed = rsingleTag.exec( data ), 21 | scripts = !keepScripts && []; 22 | 23 | // Single tag 24 | if ( parsed ) { 25 | return [ context.createElement( parsed[1] ) ]; 26 | } 27 | 28 | parsed = jQuery.buildFragment( [ data ], context, scripts ); 29 | 30 | if ( scripts && scripts.length ) { 31 | jQuery( scripts ).remove(); 32 | } 33 | 34 | return jQuery.merge( [], parsed.childNodes ); 35 | }; 36 | 37 | return jQuery.parseHTML; 38 | 39 | }); 40 | -------------------------------------------------------------------------------- /src/core/ready.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../core", 3 | "../core/init", 4 | "../deferred" 5 | ], function( jQuery ) { 6 | 7 | // The deferred used on DOM ready 8 | var readyList; 9 | 10 | jQuery.fn.ready = function( fn ) { 11 | // Add the callback 12 | jQuery.ready.promise().done( fn ); 13 | 14 | return this; 15 | }; 16 | 17 | jQuery.extend({ 18 | // Is the DOM ready to be used? Set to true once it occurs. 19 | isReady: false, 20 | 21 | // A counter to track how many items to wait for before 22 | // the ready event fires. See #6781 23 | readyWait: 1, 24 | 25 | // Hold (or release) the ready event 26 | holdReady: function( hold ) { 27 | if ( hold ) { 28 | jQuery.readyWait++; 29 | } else { 30 | jQuery.ready( true ); 31 | } 32 | }, 33 | 34 | // Handle when the DOM is ready 35 | ready: function( wait ) { 36 | 37 | // Abort if there are pending holds or we're already ready 38 | if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { 39 | return; 40 | } 41 | 42 | // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). 43 | if ( !document.body ) { 44 | return setTimeout( jQuery.ready ); 45 | } 46 | 47 | // Remember that the DOM is ready 48 | jQuery.isReady = true; 49 | 50 | // If a normal DOM Ready event fired, decrement, and wait if need be 51 | if ( wait !== true && --jQuery.readyWait > 0 ) { 52 | return; 53 | } 54 | 55 | // If there are functions bound, to execute 56 | readyList.resolveWith( document, [ jQuery ] ); 57 | 58 | // Trigger any bound ready events 59 | if ( jQuery.fn.triggerHandler ) { 60 | jQuery( document ).triggerHandler( "ready" ); 61 | jQuery( document ).off( "ready" ); 62 | } 63 | } 64 | }); 65 | 66 | /** 67 | * Clean-up method for dom ready events 68 | */ 69 | function detach() { 70 | if ( document.addEventListener ) { 71 | document.removeEventListener( "DOMContentLoaded", completed, false ); 72 | window.removeEventListener( "load", completed, false ); 73 | 74 | } else { 75 | document.detachEvent( "onreadystatechange", completed ); 76 | window.detachEvent( "onload", completed ); 77 | } 78 | } 79 | 80 | /** 81 | * The ready event handler and self cleanup method 82 | */ 83 | function completed() { 84 | // readyState === "complete" is good enough for us to call the dom ready in oldIE 85 | if ( document.addEventListener || event.type === "load" || document.readyState === "complete" ) { 86 | detach(); 87 | jQuery.ready(); 88 | } 89 | } 90 | 91 | jQuery.ready.promise = function( obj ) { 92 | if ( !readyList ) { 93 | 94 | readyList = jQuery.Deferred(); 95 | 96 | // Catch cases where $(document).ready() is called after the browser event has already occurred. 97 | // we once tried to use readyState "interactive" here, but it caused issues like the one 98 | // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15 99 | if ( document.readyState === "complete" ) { 100 | // Handle it asynchronously to allow scripts the opportunity to delay ready 101 | setTimeout( jQuery.ready ); 102 | 103 | // Standards-based browsers support DOMContentLoaded 104 | } else if ( document.addEventListener ) { 105 | // Use the handy event callback 106 | document.addEventListener( "DOMContentLoaded", completed, false ); 107 | 108 | // A fallback to window.onload, that will always work 109 | window.addEventListener( "load", completed, false ); 110 | 111 | // If IE event model is used 112 | } else { 113 | // Ensure firing before onload, maybe late but safe also for iframes 114 | document.attachEvent( "onreadystatechange", completed ); 115 | 116 | // A fallback to window.onload, that will always work 117 | window.attachEvent( "onload", completed ); 118 | 119 | // If IE and not a frame 120 | // continually check to see if the document is ready 121 | var top = false; 122 | 123 | try { 124 | top = window.frameElement == null && document.documentElement; 125 | } catch(e) {} 126 | 127 | if ( top && top.doScroll ) { 128 | (function doScrollCheck() { 129 | if ( !jQuery.isReady ) { 130 | 131 | try { 132 | // Use the trick by Diego Perini 133 | // http://javascript.nwbox.com/IEContentLoaded/ 134 | top.doScroll("left"); 135 | } catch(e) { 136 | return setTimeout( doScrollCheck, 50 ); 137 | } 138 | 139 | // detach all dom ready events 140 | detach(); 141 | 142 | // and execute any waiting functions 143 | jQuery.ready(); 144 | } 145 | })(); 146 | } 147 | } 148 | } 149 | return readyList.promise( obj ); 150 | }; 151 | 152 | }); 153 | -------------------------------------------------------------------------------- /src/core/var/rsingleTag.js: -------------------------------------------------------------------------------- 1 | define(function() { 2 | // Match a standalone tag 3 | return (/^<(\w+)\s*\/?>(?:<\/\1>|)$/); 4 | }); 5 | -------------------------------------------------------------------------------- /src/css/addGetHookIf.js: -------------------------------------------------------------------------------- 1 | define(function() { 2 | 3 | function addGetHookIf( conditionFn, hookFn ) { 4 | // Define the hook, we'll check on the first run if it's really needed. 5 | return { 6 | get: function() { 7 | var condition = conditionFn(); 8 | 9 | if ( condition == null ) { 10 | // The test was not ready at this point; screw the hook this time 11 | // but check again when needed next time. 12 | return; 13 | } 14 | 15 | if ( condition ) { 16 | // Hook not needed (or it's not possible to use it due to missing dependency), 17 | // remove it. 18 | // Since there are no other hooks for marginRight, remove the whole object. 19 | delete this.get; 20 | return; 21 | } 22 | 23 | // Hook needed; redefine it so that the support test is not executed again. 24 | 25 | return (this.get = hookFn).apply( this, arguments ); 26 | } 27 | }; 28 | } 29 | 30 | return addGetHookIf; 31 | 32 | }); 33 | -------------------------------------------------------------------------------- /src/css/curCSS.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "exports", 3 | "../core", 4 | "./var/rnumnonpx", 5 | "./var/rmargin", 6 | "../selector" // contains 7 | ], function( exports, jQuery, rnumnonpx, rmargin ) { 8 | 9 | var getStyles, curCSS, 10 | rposition = /^(top|right|bottom|left)$/; 11 | 12 | if ( window.getComputedStyle ) { 13 | getStyles = function( elem ) { 14 | // Support: IE<=11+, Firefox<=30+ (#15098, #14150) 15 | // IE throws on elements created in popups 16 | // FF meanwhile throws on frame elements through "defaultView.getComputedStyle" 17 | if ( elem.ownerDocument.defaultView.opener ) { 18 | return elem.ownerDocument.defaultView.getComputedStyle( elem, null ); 19 | } 20 | 21 | return window.getComputedStyle( elem, null ); 22 | }; 23 | 24 | curCSS = function( elem, name, computed ) { 25 | var width, minWidth, maxWidth, ret, 26 | style = elem.style; 27 | 28 | computed = computed || getStyles( elem ); 29 | 30 | // getPropertyValue is only needed for .css('filter') in IE9, see #12537 31 | ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined; 32 | 33 | if ( computed ) { 34 | 35 | if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) { 36 | ret = jQuery.style( elem, name ); 37 | } 38 | 39 | // A tribute to the "awesome hack by Dean Edwards" 40 | // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right 41 | // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels 42 | // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values 43 | if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) { 44 | 45 | // Remember the original values 46 | width = style.width; 47 | minWidth = style.minWidth; 48 | maxWidth = style.maxWidth; 49 | 50 | // Put in the new values to get a computed value out 51 | style.minWidth = style.maxWidth = style.width = ret; 52 | ret = computed.width; 53 | 54 | // Revert the changed values 55 | style.width = width; 56 | style.minWidth = minWidth; 57 | style.maxWidth = maxWidth; 58 | } 59 | } 60 | 61 | // Support: IE 62 | // IE returns zIndex value as an integer. 63 | return ret === undefined ? 64 | ret : 65 | ret + ""; 66 | }; 67 | } else if ( document.documentElement.currentStyle ) { 68 | getStyles = function( elem ) { 69 | return elem.currentStyle; 70 | }; 71 | 72 | curCSS = function( elem, name, computed ) { 73 | var left, rs, rsLeft, ret, 74 | style = elem.style; 75 | 76 | computed = computed || getStyles( elem ); 77 | ret = computed ? computed[ name ] : undefined; 78 | 79 | // Avoid setting ret to empty string here 80 | // so we don't default to auto 81 | if ( ret == null && style && style[ name ] ) { 82 | ret = style[ name ]; 83 | } 84 | 85 | // From the awesome hack by Dean Edwards 86 | // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 87 | 88 | // If we're not dealing with a regular pixel number 89 | // but a number that has a weird ending, we need to convert it to pixels 90 | // but not position css attributes, as those are proportional to the parent element instead 91 | // and we can't measure the parent instead because it might trigger a "stacking dolls" problem 92 | if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) { 93 | 94 | // Remember the original values 95 | left = style.left; 96 | rs = elem.runtimeStyle; 97 | rsLeft = rs && rs.left; 98 | 99 | // Put in the new values to get a computed value out 100 | if ( rsLeft ) { 101 | rs.left = elem.currentStyle.left; 102 | } 103 | style.left = name === "fontSize" ? "1em" : ret; 104 | ret = style.pixelLeft + "px"; 105 | 106 | // Revert the changed values 107 | style.left = left; 108 | if ( rsLeft ) { 109 | rs.left = rsLeft; 110 | } 111 | } 112 | 113 | // Support: IE 114 | // IE returns zIndex value as an integer. 115 | return ret === undefined ? 116 | ret : 117 | ret + "" || "auto"; 118 | }; 119 | } 120 | 121 | exports.getStyles = getStyles; 122 | exports.curCSS = curCSS; 123 | 124 | }); 125 | -------------------------------------------------------------------------------- /src/css/defaultDisplay.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../core", 3 | "../manipulation" // appendTo 4 | ], function( jQuery ) { 5 | 6 | var iframe, 7 | elemdisplay = {}; 8 | 9 | /** 10 | * Retrieve the actual display of a element 11 | * @param {String} name nodeName of the element 12 | * @param {Object} doc Document object 13 | */ 14 | // Called only from within defaultDisplay 15 | function actualDisplay( name, doc ) { 16 | var style, 17 | elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ), 18 | 19 | // getDefaultComputedStyle might be reliably used only on attached element 20 | display = window.getDefaultComputedStyle && ( style = window.getDefaultComputedStyle( elem[ 0 ] ) ) ? 21 | 22 | // Use of this method is a temporary fix (more like optmization) until something better comes along, 23 | // since it was removed from specification and supported only in FF 24 | style.display : jQuery.css( elem[ 0 ], "display" ); 25 | 26 | // We don't have any data stored on the element, 27 | // so use "detach" method as fast way to get rid of the element 28 | elem.detach(); 29 | 30 | return display; 31 | } 32 | 33 | /** 34 | * Try to determine the default display value of an element 35 | * @param {String} nodeName 36 | */ 37 | function defaultDisplay( nodeName ) { 38 | var doc = document, 39 | display = elemdisplay[ nodeName ]; 40 | 41 | if ( !display ) { 42 | display = actualDisplay( nodeName, doc ); 43 | 44 | // If the simple way fails, read from inside an iframe 45 | if ( display === "none" || !display ) { 46 | 47 | // Use the already-created iframe if possible 48 | iframe = (iframe || jQuery( " 10 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /test/data/core/onready.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | alias-masked DOM properties (#14074) 6 | 10 | 11 | 12 | 13 |
14 | 15 |
16 | 23 | 24 | -------------------------------------------------------------------------------- /test/data/css/cssWidthBeforeDocReady.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 17 |
18 | 19 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /test/data/dashboard.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /test/data/data/dataAttrs.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IE11 onpageshow strangeness (#14894) 6 | 7 | 12 | 13 | 14 | Test for #14894 15 | 16 | 17 | -------------------------------------------------------------------------------- /test/data/dimensions/documentLarge.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 11 | 12 | 13 |
14 | 15 |
16 | 17 | 18 | -------------------------------------------------------------------------------- /test/data/dimensions/documentSmall.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 17 |
18 | 19 |
20 | 21 | 22 | -------------------------------------------------------------------------------- /test/data/echoData.php: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /test/data/echoQuery.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/data/errorWithJSON.php: -------------------------------------------------------------------------------- 1 | 25 | -------------------------------------------------------------------------------- /test/data/evalScript.php: -------------------------------------------------------------------------------- 1 | ok( "" === "GET", "request method is " ); -------------------------------------------------------------------------------- /test/data/event/focusElem.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | .focus() (activeElement access #13393) 6 | 7 | 8 | 9 | 10 | 11 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /test/data/event/focusinCrossFrame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | focusin event cross-frame (#14180) 6 | 7 | 8 | 9 | 10 | 11 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /test/data/event/longLoadScript.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/data/event/promiseReady.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Test case for jQuery ticket #11470 6 | 7 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /test/data/event/syncReady.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Test case for jQuery ticket #10067 6 | 7 | 8 | 9 | 10 | 15 | 16 | 20 | 21 |
22 | 23 | 24 | -------------------------------------------------------------------------------- /test/data/event/triggerunload.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /test/data/headers.php: -------------------------------------------------------------------------------- 1 | $value ) { 10 | 11 | $key = str_replace( "_" , "-" , substr( $key , 0 , 5 ) == "HTTP_" ? substr( $key , 5 ) : $key ); 12 | $headers[ $key ] = $value; 13 | 14 | } 15 | 16 | foreach( explode( "_" , $_GET[ "keys" ] ) as $key ) { 17 | 18 | // Only echo if key exists in the header 19 | if ( isset( $headers[ strtoupper( $key ) ] ) ) { 20 | echo "$key: " . @$headers[ strtoupper( $key ) ] . "\n"; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /test/data/if_modified_since.php: -------------------------------------------------------------------------------- 1 | 21 | -------------------------------------------------------------------------------- /test/data/iframe.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | iframe 4 | 5 | 6 |
span text
7 | 8 | 9 | -------------------------------------------------------------------------------- /test/data/json.php: -------------------------------------------------------------------------------- 1 | 14 | -------------------------------------------------------------------------------- /test/data/json_obj.js: -------------------------------------------------------------------------------- 1 | { "data": {"lang": "en", "length": 25} } 2 | -------------------------------------------------------------------------------- /test/data/jsonp.php: -------------------------------------------------------------------------------- 1 | 15 | -------------------------------------------------------------------------------- /test/data/manipulation/iframe-denied.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | body 6 | 7 | 8 |
9 | 10 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /test/data/name.html: -------------------------------------------------------------------------------- 1 | ERROR 2 | -------------------------------------------------------------------------------- /test/data/name.php: -------------------------------------------------------------------------------- 1 | $xml$result"; 12 | die(); 13 | } 14 | $name = $_REQUEST['name']; 15 | if($name == 'foo') { 16 | echo "bar"; 17 | die(); 18 | } else if($name == 'peter') { 19 | echo "pan"; 20 | die(); 21 | } 22 | 23 | echo 'ERROR '; 24 | ?> -------------------------------------------------------------------------------- /test/data/nocontent.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/data/offset/absolute.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | absolute 7 | 18 | 19 | 29 | 30 | 31 |
absolute-1 32 |
absolute-1-1 33 |
absolute-1-1-1
34 |
35 |
36 |
absolute-2
37 |
Has absolute position but no values set for the location ('auto').
38 |
39 |

Click the white box to move the marker to it. Clicking the box also changes the position to absolute (if not already) and sets the position according to the position method.

40 | 41 | 42 | -------------------------------------------------------------------------------- /test/data/offset/body.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | body 7 | 12 | 13 | 21 | 22 | 23 |
24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /test/data/offset/fixed.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | fixed 7 | 15 | 16 | 25 | 26 | 27 |
28 |
29 |
30 |
31 |
32 |

Click the white box to move the marker to it.

33 | 34 | 35 | -------------------------------------------------------------------------------- /test/data/offset/relative.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | relative 7 | 13 | 14 | 24 | 25 | 26 |
27 |
28 |
29 |

Click the white box to move the marker to it. Clicking the box also changes the position to absolute (if not already) and sets the position according to the position method.

30 | 31 | 32 | -------------------------------------------------------------------------------- /test/data/offset/scroll.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | scroll 7 | 16 | 17 | 28 | 29 | 30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |

Click the white box to move the marker to it.

38 | 39 | 40 | -------------------------------------------------------------------------------- /test/data/offset/static.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | static 7 | 13 | 14 | 24 | 25 | 26 |
27 |
28 |
29 |

Click the white box to move the marker to it. Clicking the box also changes the position to absolute (if not already) and sets the position according to the position method.

30 | 31 | 32 | -------------------------------------------------------------------------------- /test/data/offset/table.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | table 7 | 13 | 14 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
th-1th-2th-3
td-1td-2td-3
40 |
41 |

Click the white box to move the marker to it.

42 | 43 | 44 | -------------------------------------------------------------------------------- /test/data/params_html.php: -------------------------------------------------------------------------------- 1 |
2 | $value ) 4 | echo "$value"; 5 | ?> 6 |
7 |
8 | $value ) 10 | echo "$value"; 11 | ?> 12 |
-------------------------------------------------------------------------------- /test/data/readywaitasset.js: -------------------------------------------------------------------------------- 1 | var delayedMessage = "It worked!"; 2 | -------------------------------------------------------------------------------- /test/data/readywaitloader.js: -------------------------------------------------------------------------------- 1 | // Simple script loader that uses jQuery.readyWait via jQuery.holdReady() 2 | 3 | //Hold on jQuery! 4 | jQuery.holdReady(true); 5 | 6 | var readyRegExp = /^(complete|loaded)$/; 7 | 8 | function assetLoaded( evt ){ 9 | var node = evt.currentTarget || evt.srcElement; 10 | if ( evt.type === "load" || readyRegExp.test(node.readyState) ) { 11 | jQuery.holdReady(false); 12 | } 13 | } 14 | 15 | setTimeout( function() { 16 | var script = document.createElement("script"); 17 | script.type = "text/javascript"; 18 | if ( script.addEventListener ) { 19 | script.addEventListener( "load", assetLoaded, false ); 20 | } else { 21 | script.attachEvent( "onreadystatechange", assetLoaded ); 22 | } 23 | script.src = "data/readywaitasset.js"; 24 | document.getElementsByTagName("head")[0].appendChild(script); 25 | }, 2000 ); 26 | -------------------------------------------------------------------------------- /test/data/script.php: -------------------------------------------------------------------------------- 1 | 11 | ok( true, "Script executed correctly." ); 12 | -------------------------------------------------------------------------------- /test/data/selector/html5_selector.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | jQuery selector - attributes 6 | 7 | 8 | 9 | 12 | 13 | 19 | 20 | 21 | 23 | 24 |
26 | 27 |
31 | 37 | 39 |
40 | 41 | 42 | 44 |
45 | 46 | 49 | 50 | 52 | 53 |
    55 | 56 |
    58 | 59 |
    61 | 62 | 73 | 74 | 76 | 77 | 82 | 83 | 84 | 87 | 88 | 89 | 93 | 94 | 100 | 101 |
    103 |
    Term
    This is the first definition in compact format.
    104 |
    Term
    This is the second definition in compact format.
    105 |
    106 | 107 | 109 | 110 | Scrolling text (non-standard) 113 | 114 | 115 | -------------------------------------------------------------------------------- /test/data/selector/sizzle_cache.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | jQuery selector - sizzle cache 6 | 7 | 8 | 14 | 15 | 16 | 17 |
    18 | Worlds collide 19 |
    20 | 21 | 22 | -------------------------------------------------------------------------------- /test/data/statusText.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/data/support/bodyBackground.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 17 | 18 | 19 |
    20 | 21 | 22 |
    23 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /test/data/support/csp-clean.php: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /test/data/support/csp-log.php: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /test/data/support/csp.js: -------------------------------------------------------------------------------- 1 | jQuery(function() { 2 | parent.iframeCallback( getComputedSupport( jQuery.support ) ); 3 | }); 4 | -------------------------------------------------------------------------------- /test/data/support/csp.log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diracdeltas/jquery/af49b4227a156007626c1cbdceba5cd68f78df90/test/data/support/csp.log -------------------------------------------------------------------------------- /test/data/support/csp.php: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | CSP Test Page 11 | 12 | 13 | 14 | 15 | 16 |

    CSP Test Page

    17 | 18 | 19 | -------------------------------------------------------------------------------- /test/data/support/getComputedSupport.js: -------------------------------------------------------------------------------- 1 | function getComputedSupport( support ) { 2 | var prop, 3 | result = {}; 4 | 5 | for ( prop in support ) { 6 | if ( typeof support[ prop ] === "function" ) { 7 | result[ prop ] = support[ prop ](); 8 | } else { 9 | result[ prop ] = support[ prop ]; 10 | } 11 | } 12 | 13 | return result; 14 | } 15 | -------------------------------------------------------------------------------- /test/data/support/shrinkWrapBlocks.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 12 | 13 | 14 |
    15 | 16 |
    17 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /test/data/support/testElementCrash.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | 13 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /test/data/test.html: -------------------------------------------------------------------------------- 1 | html text
    2 | 6 | 7 | blabla 8 | -------------------------------------------------------------------------------- /test/data/test.php: -------------------------------------------------------------------------------- 1 | html text
    2 | 6 | 7 | blabla 8 | -------------------------------------------------------------------------------- /test/data/test2.html: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /test/data/test3.html: -------------------------------------------------------------------------------- 1 |
    This is a user
    2 |
    This is a user
    3 |
    This is a teacher
    4 |
    This is a superuser
    5 | -------------------------------------------------------------------------------- /test/data/testbar.php: -------------------------------------------------------------------------------- 1 | this.testBar = "bar"; 2 | jQuery("#ap").html("bar"); 3 | ok( true, "testbar.php executed"); 4 | -------------------------------------------------------------------------------- /test/data/testsuite.css: -------------------------------------------------------------------------------- 1 | /* for testing opacity set in styles in IE */ 2 | ol#empty { 3 | opacity: 0; 4 | filter:Alpha(opacity=0) progid:DXImageTransform.Microsoft.gradient(startColorStr='#ffff0000', EndColorStr='#ffffffff'); 5 | } 6 | 7 | div#fx-tests h4 { 8 | background: red; 9 | } 10 | 11 | div#fx-tests h4.pass { 12 | background: green; 13 | } 14 | 15 | div#fx-tests div.box { 16 | background: red; 17 | overflow: hidden; 18 | border: 2px solid #000; 19 | } 20 | 21 | div#fx-tests div.overflow { 22 | overflow: visible; 23 | } 24 | 25 | div.inline { 26 | display: inline; 27 | } 28 | 29 | div.autoheight { 30 | height: auto; 31 | } 32 | 33 | div.autowidth { 34 | width: auto; 35 | } 36 | 37 | div.autoopacity { 38 | opacity: auto; 39 | } 40 | 41 | div.largewidth { 42 | width: 100px; 43 | } 44 | 45 | div.largeheight { 46 | height: 100px; 47 | } 48 | 49 | div.largeopacity { 50 | filter: progid:DXImageTransform.Microsoft.Alpha(opacity=100); 51 | } 52 | 53 | div.medwidth { 54 | width: 50px; 55 | } 56 | 57 | div.medheight { 58 | height: 50px; 59 | } 60 | 61 | div.medopacity { 62 | opacity: 0.5; 63 | filter: progid:DXImageTransform.Microsoft.Alpha(opacity=50); 64 | } 65 | 66 | div.nowidth { 67 | width: 0px; 68 | } 69 | 70 | div.noheight { 71 | height: 0px; 72 | } 73 | 74 | div.noopacity { 75 | opacity: 0; 76 | filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0); 77 | } 78 | 79 | div.hidden { 80 | display: none; 81 | } 82 | 83 | div#fx-tests div.widewidth { 84 | background-repeat: repeat-x; 85 | } 86 | 87 | div#fx-tests div.wideheight { 88 | background-repeat: repeat-y; 89 | } 90 | 91 | div#fx-tests div.widewidth.wideheight { 92 | background-repeat: repeat; 93 | } 94 | 95 | div#fx-tests div.noback { 96 | background-image: none; 97 | } 98 | 99 | .chain-test, 100 | .chain-test div { 101 | width: 100px; 102 | height: 20px; 103 | position: relative; 104 | float: left; 105 | } 106 | .chain-test div { 107 | position: absolute; 108 | top: 0; 109 | left: 0; 110 | } 111 | 112 | .chain-test { 113 | background: red; 114 | } 115 | .chain-test div { 116 | background: green; 117 | } 118 | 119 | .chain-test-out { 120 | background: green; 121 | } 122 | .chain-test-out div { 123 | background: red; 124 | display: none; 125 | } 126 | 127 | /* tests to ensure jQuery can determine the native display mode of elements 128 | that have been set as display: none in stylesheets */ 129 | div#show-tests * { display: none; } 130 | 131 | #nothiddendiv { font-size: 16px; } 132 | #nothiddendivchild.em { font-size: 2em; } 133 | #nothiddendivchild.prct { font-size: 150%; } 134 | 135 | /* For testing type on vml in IE #7071 */ 136 | v\:oval { behavior:url(#default#VML); display:inline-block; } 137 | 138 | /* 8099 changes to default styles are read correctly */ 139 | tt { display: none; } 140 | sup { display: none; } 141 | dfn { display: none; } 142 | 143 | /* #9239 Attach a background to the body( avoid crashes in removing the test element in support ) */ 144 | body, div { background: url(http://static.jquery.com/files/rocker/images/logo_jquery_215x53.gif) no-repeat -1000px 0; } 145 | 146 | /* #6652 REMOVE FILTER:ALPHA(OPACITY=100) AFTER ANIMATION */ 147 | #t6652 div { filter: alpha(opacity=50); } 148 | 149 | /* #10501 */ 150 | section { background:#f0f; display:block; } 151 | 152 | /* #11971 */ 153 | #foo { background: url(1x1.jpg) right bottom no-repeat; } 154 | 155 | /* #14824 */ 156 | #span-14824 { display: block; } 157 | 158 | #display { display: list-item !important; } 159 | -------------------------------------------------------------------------------- /test/data/text.php: -------------------------------------------------------------------------------- 1 | Lorem ipsum dolor sit amet 2 | consectetuer adipiscing elit 3 | Sed lorem leo 4 | lorem leo consectetuer adipiscing elit 5 | Sed lorem leo 6 | rhoncus sit amet 7 | elementum at 8 | bibendum at, eros 9 | Cras at mi et tortor egestas vestibulum 10 | sed Cras at mi vestibulum 11 | Phasellus sed felis sit amet 12 | orci dapibus semper. 13 | -------------------------------------------------------------------------------- /test/data/with_fries.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 1 14 | 15 | 16 | 17 | 18 | foo 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /test/data/with_fries_over_jsonp.php: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /test/hovertest.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hover tests 4 | 5 | 32 | 33 | 34 |

    Hover (mouse{over,out,enter,leave}) Tests

    35 |

    Be sure to try moving the mouse out of the browser via the left side on each test.

    36 |
    37 | 38 |
    39 |
    40 | 41 | .hover() in/out: 0 / 0 42 |
    43 |
    44 | Mouse over here should NOT trigger the counter. 45 |
    46 |
    47 |
    48 |
    49 | 50 | Live enter/leave: 0 / 0 51 |
    52 |
    53 | Mouse over here should NOT trigger the counter. 54 |
    55 |
    56 |
    57 |
    58 | 59 | Delegated enter/leave: 0 / 0 60 |
    61 |
    62 | Mouse over here should NOT trigger the counter. 63 |
    64 |
    65 | 66 |
    67 |
    68 | 69 | Bind over/out: 0 / 0 70 |
    71 |
    72 | Mouse over here SHOULD trigger the counter. 73 |
    74 |
    75 |
    76 |
    77 | 78 | Live over/out: 0 / 0 79 |
    80 |
    81 | Mouse over here SHOULD trigger the counter. 82 |
    83 |
    84 |
    85 |
    86 | 87 | Delegated over/out: 0 / 0 88 |
    89 |
    90 | Mouse over here SHOULD trigger the counter. 91 |
    92 |
    93 | 94 |
    95 | 96 | 157 | 158 | 159 | -------------------------------------------------------------------------------- /test/jquery.js: -------------------------------------------------------------------------------- 1 | // Use the right jQuery source on the test page (and iframes) 2 | (function() { 3 | /* global loadTests: false */ 4 | 5 | var src, 6 | path = window.location.pathname.split( "test" )[ 0 ], 7 | QUnit = window.QUnit || parent.QUnit, 8 | require = window.require || parent.require; 9 | 10 | // Config parameter to force basic code paths 11 | QUnit.config.urlConfig.push({ 12 | id: "basic", 13 | label: "Bypass optimizations", 14 | tooltip: "Force use of the most basic code by disabling native querySelectorAll; contains; compareDocumentPosition; JSON.parse" 15 | }); 16 | if ( QUnit.urlParams.basic ) { 17 | document.querySelectorAll = null; 18 | document.documentElement.contains = null; 19 | document.documentElement.compareDocumentPosition = null; 20 | window.JSON = null; 21 | } 22 | 23 | // iFrames won't load AMD (the iframe tests synchronously expect jQuery to be there) 24 | QUnit.config.urlConfig.push({ 25 | id: "amd", 26 | label: "Load with AMD", 27 | tooltip: "Load the AMD jQuery file (and its dependencies)" 28 | }); 29 | // If QUnit is on window, this is the main window 30 | // This detection allows AMD tests to be run in an iframe 31 | if ( QUnit.urlParams.amd && window.QUnit ) { 32 | require.config({ 33 | baseUrl: path, 34 | paths: { 35 | sizzle: "src/sizzle/dist/sizzle" 36 | } 37 | }); 38 | src = "src/jquery"; 39 | // Include tests if specified 40 | if ( typeof loadTests !== "undefined" ) { 41 | require( [ src ], loadTests ); 42 | } else { 43 | require( [ src ] ); 44 | } 45 | return; 46 | } 47 | 48 | // Config parameter to use minified jQuery 49 | QUnit.config.urlConfig.push({ 50 | id: "dev", 51 | label: "Load unminified", 52 | tooltip: "Load the development (unminified) jQuery file" 53 | }); 54 | if ( QUnit.urlParams.dev ) { 55 | src = "dist/jquery.js"; 56 | } else { 57 | src = "dist/jquery.min.js"; 58 | } 59 | 60 | // Load jQuery 61 | document.write( " 8 | 12 | 13 | 14 |

    jQuery Local File Test

    15 |

    16 | Introduction 17 |

    18 |
      19 |
    • 20 | Access this file using the "file:" protocol, 21 |
    • 22 |
    • 23 | two green "OK" strings must appear below, 24 |
    • 25 |
    • 26 | Empty local files will issue errors, it's a known limitation. 27 |
    • 28 |
    29 |

    30 | Results 31 |

    32 |
      33 |
    • 34 | Success: 35 | 36 | 37 |
    • 38 |
    • 39 | Error: 40 | 41 | 42 |
    • 43 |
    44 |

    45 | Logs: 46 |

    47 |
      48 |
    49 | 75 | 76 | -------------------------------------------------------------------------------- /test/networkerror.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | 12 | 13 | jQuery Network Error Test for Firefox 14 | 15 | 18 | 19 | 36 | 37 | 38 |

    39 | jQuery Network Error Test for Firefox 40 |

    41 |
    42 | This is a test page for 43 | 44 | #8135 45 | 46 | which was reported in Firefox when accessing properties 47 | of an XMLHttpRequest object after a network error occurred. 48 |
    49 |
    Take the following steps:
    50 |
      51 |
    1. 52 | make sure you accessed this page through a web server, 53 |
    2. 54 |
    3. 55 | stop the web server, 56 |
    4. 57 |
    5. 58 | open the console, 59 |
    6. 60 |
    7. 61 | click this 62 | 63 | , 64 |
    8. 65 |
    9. 66 | wait for both requests to fail. 67 |
    10. 68 |
    69 |
    70 | Test passes if you get two log lines: 71 |
      72 |
    • 73 | the first starting with "abort", 74 |
    • 75 |
    • 76 | the second starting with "complete", 77 |
    • 78 |
    79 |
    80 |
    81 | Test fails if the browser notifies an exception. 82 |
    83 | 84 | 85 | -------------------------------------------------------------------------------- /test/readywait.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | jQuery.holdReady Test 11 | 12 | 17 | 18 | 19 | 21 | 22 | 23 | 34 | 35 | 36 |

    37 | jQuery.holdReady Test 38 |

    39 |

    40 | This is a test page for jQuery.readyWait and jQuery.holdReady, 41 | see 42 | #6781 43 | and 44 | #8803. 45 |

    46 |

    47 | Test for jQuery.holdReady, which can be used 48 | by plugins and other scripts to indicate something 49 | important to the page is still loading and needs 50 | to block the DOM ready callbacks that are registered 51 | with jQuery. 52 |

    53 |

    54 | Script loaders are the most likely kind of script 55 | to use jQuery.holdReady, but it could be used by 56 | other things like a script that loads a CSS file 57 | and wants to pause the DOM ready callbacks. 58 |

    59 |

    60 | Expected Result: The text 61 | It Worked! 62 | appears below after about 2 seconds. 63 |

    64 |

    65 | If there is an error in the console, 66 | or the text does not show up, then the test failed. 67 |

    68 |
    69 | 70 | 71 | -------------------------------------------------------------------------------- /test/unit/deprecated.js: -------------------------------------------------------------------------------- 1 | module("deprecated", { teardown: moduleTeardown }); 2 | 3 | if ( jQuery.fn.size ) { 4 | test("size()", function() { 5 | expect(1); 6 | equal( jQuery("#qunit-fixture p").size(), 6, "Get Number of Elements Found" ); 7 | }); 8 | } 9 | -------------------------------------------------------------------------------- /test/unit/exports.js: -------------------------------------------------------------------------------- 1 | module("exports", { teardown: moduleTeardown }); 2 | 3 | test("amdModule", function() { 4 | expect(1); 5 | 6 | equal( jQuery, amdDefined, "Make sure defined module matches jQuery" ); 7 | }); 8 | -------------------------------------------------------------------------------- /test/unit/ready.js: -------------------------------------------------------------------------------- 1 | module("event"); 2 | 3 | (function(){ 4 | var notYetReady, noEarlyExecution, 5 | order = [], 6 | args = {}; 7 | 8 | notYetReady = !jQuery.isReady; 9 | 10 | test("jQuery.isReady", function() { 11 | expect(2); 12 | 13 | equal(notYetReady, true, "jQuery.isReady should not be true before DOM ready"); 14 | equal(jQuery.isReady, true, "jQuery.isReady should be true once DOM is ready"); 15 | }); 16 | 17 | // Create an event handler. 18 | function makeHandler( testId ) { 19 | // When returned function is executed, push testId onto `order` array 20 | // to ensure execution order. Also, store event handler arg to ensure 21 | // the correct arg is being passed into the event handler. 22 | return function( arg ) { 23 | order.push(testId); 24 | args[testId] = arg; 25 | }; 26 | } 27 | 28 | // Bind to the ready event in every possible way. 29 | jQuery(makeHandler("a")); 30 | jQuery(document).ready(makeHandler("b")); 31 | jQuery(document).on("ready.readytest", makeHandler("c")); 32 | 33 | // Do it twice, just to be sure. 34 | jQuery(makeHandler("d")); 35 | jQuery(document).ready(makeHandler("e")); 36 | jQuery(document).on("ready.readytest", makeHandler("f")); 37 | 38 | noEarlyExecution = order.length === 0; 39 | 40 | // This assumes that QUnit tests are run on DOM ready! 41 | test("jQuery ready", function() { 42 | expect(10); 43 | 44 | ok(noEarlyExecution, "Handlers bound to DOM ready should not execute before DOM ready"); 45 | 46 | // Ensure execution order. 47 | deepEqual(order, ["a", "b", "d", "e", "c", "f"], "Bound DOM ready handlers should execute in on-order, but those bound with jQuery(document).on( 'ready', fn ) will always execute last"); 48 | 49 | // Ensure handler argument is correct. 50 | equal(args["a"], jQuery, "Argument passed to fn in jQuery( fn ) should be jQuery"); 51 | equal(args["b"], jQuery, "Argument passed to fn in jQuery(document).ready( fn ) should be jQuery"); 52 | ok(args["c"] instanceof jQuery.Event, "Argument passed to fn in jQuery(document).on( 'ready', fn ) should be an event object"); 53 | 54 | order = []; 55 | 56 | // Now that the ready event has fired, again bind to the ready event 57 | // in every possible way. These event handlers should execute immediately. 58 | jQuery(makeHandler("g")); 59 | equal(order.pop(), "g", "Event handler should execute immediately"); 60 | equal(args["g"], jQuery, "Argument passed to fn in jQuery( fn ) should be jQuery"); 61 | 62 | jQuery(document).ready(makeHandler("h")); 63 | equal(order.pop(), "h", "Event handler should execute immediately"); 64 | equal(args["h"], jQuery, "Argument passed to fn in jQuery(document).ready( fn ) should be jQuery"); 65 | 66 | jQuery(document).on("ready.readytest", makeHandler("never")); 67 | equal(order.length, 0, "Event handler should never execute since DOM ready has already passed"); 68 | 69 | // Cleanup. 70 | jQuery(document).off("ready.readytest"); 71 | }); 72 | 73 | })(); 74 | -------------------------------------------------------------------------------- /test/xhtml.php: -------------------------------------------------------------------------------- 1 | 6 | --------------------------------------------------------------------------------