]> source.dussan.org Git - jquery.git/commitdiff
No ticket: Grunt changes from 2.0 selector-native
authorDave Methvin <dave.methvin@gmail.com>
Wed, 27 Feb 2013 02:59:08 +0000 (21:59 -0500)
committerRichard Gibson <richard.gibson@gmail.com>
Mon, 25 Mar 2013 18:45:45 +0000 (14:45 -0400)
(cherry picked from commits 1083f82d1ee0c8f15a66be15e6184294a69d4420 8be9cd1ce71de8affa32a85b596c1bfed2e714a6 054c6946d4f86e4ba5ce6284554c8cacd7498e93)

.gitignore
Gruntfile.js
README.md

index 9868a53695b3e1c5f5dcad61cebfc8b753152939..1040aefd47d7653c0dc61d212fd28496a40861a9 100644 (file)
@@ -1,3 +1,4 @@
+src/selector-sizzle.js
 src/selector.js
 dist
 .project
index a8dd4d864f5b881d4904e5d5018d781eb2fd6c7f..7180a8a27861c0adcf9656e86b1d0473b1b530f4 100644 (file)
@@ -22,7 +22,7 @@ module.exports = function( grunt ) {
                        files: distpaths
                },
                selector: {
-                       destFile: "src/selector.js",
+                       destFile: "src/selector-sizzle.js",
                        apiFile: "src/sizzle-jquery.js",
                        srcFile: "src/sizzle/dist/sizzle.js"
                },
@@ -39,10 +39,9 @@ module.exports = function( grunt ) {
                                        "src/queue.js",
                                        "src/attributes.js",
                                        "src/event.js",
-                                       "src/selector.js",
+                                       "src/selector-sizzle.js",
                                        "src/traversing.js",
                                        "src/manipulation.js",
-
                                        { flag: "css", src: "src/css.js" },
                                        "src/serialize.js",
                                        { flag: "event-alias", src: "src/event-alias.js" },
@@ -151,8 +150,7 @@ module.exports = function( grunt ) {
                });
        });
 
-       // Build src/selector.js
-       grunt.registerTask( "selector", "Build src/selector.js", function() {
+       grunt.registerTask( "selector", "Build Sizzle-based selector module", function() {
 
                var cfg = grunt.config("selector"),
                        name = cfg.destFile,
@@ -196,7 +194,7 @@ module.exports = function( grunt ) {
                // Rejoin the pieces
                compiled = parts.join("");
 
-               grunt.verbose.write("Injected sizzle-jquery.js into sizzle.js");
+               grunt.verbose.writeln("Injected " + cfg.apiFile + " into " + cfg.srcFile);
 
                // Write concatenated source to file, and ensure newline-only termination
                grunt.file.write( name, compiled.replace( /\x0d\x0a/g, "\x0a" ) );
@@ -334,37 +332,47 @@ module.exports = function( grunt ) {
                                var flag = filepath.flag,
                                                specified = false,
                                                omit = false,
-                                               message = "";
+                                               messages = [];
 
                                if ( flag ) {
                                        if ( excluded[ flag ] !== undefined ) {
-                                               message = ( "Excluding " + flag ).red;
+                                               messages.push([
+                                                       ( "Excluding " + flag ).red,
+                                                       ( "(" + filepath.src + ")" ).grey
+                                               ]);
                                                specified = true;
-                                               omit = true;
-                                       } else {
-                                               message = ( "Including " + flag ).green;
+                                               omit = !filepath.alt;
+                                               if ( !omit ) {
+                                                       flag += " alternate";
+                                                       filepath.src = filepath.alt;
+                                               }
+                                       }
+                                       if ( excluded[ flag ] === undefined ) {
+                                               messages.push([
+                                                       ( "Including " + flag ).green,
+                                                       ( "(" + filepath.src + ")" ).grey
+                                               ]);
 
                                                // If this module was actually specified by the
-                                               // builder, then st the flag to include it in the
+                                               // builder, then set the flag to include it in the
                                                // output list
                                                if ( modules[ "+" + flag ] ) {
                                                        specified = true;
                                                }
                                        }
 
+                                       filepath = filepath.src;
+
                                        // Only display the inclusion/exclusion list when handling
                                        // an explicit list.
                                        //
                                        // Additionally, only display modules that have been specified
                                        // by the user
                                        if ( explicit && specified ) {
-                                               grunt.log.writetableln([ 27, 30 ], [
-                                                       message,
-                                                       ( "(" + filepath.src + ")").grey
-                                               ]);
+                                               messages.forEach(function( message ) {
+                                                       grunt.log.writetableln( [ 27, 30 ], message );
+                                               });
                                        }
-
-                                       filepath = filepath.src;
                                }
 
                                if ( !omit ) {
index 97b6c220fa0fc1eac80e38597e3210412cd28941..4e30b7932bee877199cf40fef2e7a0679cbb7977 100644 (file)
--- a/README.md
+++ b/README.md
@@ -68,18 +68,26 @@ grunt
 The built version of jQuery will be put in the `dist/` subdirectory.
 
 
-### Modules (new in 1.8)
+### Modules
 
-Starting in jQuery 1.8, special builds can now be created that optionally exclude or include any of the following modules:
+Special builds can be created that exclude subsets of jQuery functionality.
+This allows for smaller custom builds when the builder is certain that those parts of jQuery are not being used.
+For example, an app that only used JSONP for `$.ajax()` and did not need to calculate offsets or positions of elements could exclude the offset and ajax/xhr modules. The current modules that can be excluded are:
 
-- ajax
-- css
-- dimensions
-- effects
-- offset
+- **ajax**: All AJAX functionality: `$.ajax()`, `$.get()`, `$.post()`, `$.ajaxSetup()`, `.load()`, transports, and ajax event shorthands such as `.ajaxStart()`.
+- **ajax/xhr**: The XMLHTTPRequest AJAX transport only.
+- **ajax/script**: The `<script>` AJAX transport only; used to retrieve scripts.
+- **ajax/jsonp**: The JSONP AJAX transport only; depends on the ajax/script transport.
+- **css**: The `.css()` method plus non-animated `.show()`, `.hide()` and `.toggle()`.
+- **deprecated**: Methods documented as deprecated but not yet removed; currently only `.andSelf()`.
+- **dimensions**: The `.width()` and `.height()` methods, including `inner-` and `outer-` variations.
+- **effects**: The `.animate()` method and its shorthands such as `.slideUp()` or `.hide("slow")`. 
+- **event-alias**: All event attaching/triggering shorthands like `.click()` or `.mouseover()`.
+- **offset**: The `.offset()`, `.position()`, `.offsetParent()`, `.scrollLeft()`, and `.scrollTop()` methods.
 
+The grunt build process is aware of dependencies across modules. If you explicitly remove a module, its dependent modules will be removed as well. For example, excluding the css module also excludes effects, since the effects module uses `.css()` to animate CSS properties. These dependencies are listed in Gruntfile.js and the build process shows a message for each dependent module it excludes.
 
-Before creating a custom build for use in production, be sure to check out the latest stable version:
+To create a custom build of the latest stable version, first check out the version:
 
 ```bash
 git pull; git checkout $(git describe --abbrev=0 --tags)
@@ -91,58 +99,31 @@ Then, make sure all Node dependencies are installed and all Git submodules are c
 npm install && grunt
 ```
 
-To create a custom build, use the following special `grunt` commands:
+Create the custom build, use the `grunt custom` option, listing the modules to be excluded. Examples:
 
-Exclude **ajax**:
+Exclude all **ajax** functionality:
 
 ```bash
 grunt custom:-ajax
 ```
 
-Exclude **css**:
+Exclude **css**, **effects**, **offset**, **dimensions**, and **position**. Excluding **css** automatically excludes its dependent modules:
 
 ```bash
-grunt custom:-css
-```
-
-Exclude **deprecated**:
-
-```bash
-grunt custom:-deprecated
-```
-
-Exclude **dimensions**:
-
-```bash
-grunt custom:-dimensions
-```
-
-Exclude **effects**:
-
-```bash
-grunt custom:-effects
-```
-
-Exclude **offset**:
-
-```bash
-grunt custom:-offset
+grunt custom:-css:-position
 ```
 
 Exclude **all** optional modules:
 
 ```bash
-grunt custom:-ajax,-css,-deprecated,-dimensions,-effects,-offset
+grunt custom:-ajax,-css,-deprecated,-dimensions,-effects,-event-alias,-offset
 ```
 
-
-Note: dependencies will be handled internally, by the build process.
-
+For questions or requests regarding custom builds, please start a thread on the [Developing jQuery Core](https://forum.jquery.com/developing-jquery-core) section of the forum. Due to the combinatorics and custom nature of these builds, they are not regularly tested in jQuery's unit test process.
 
 Running the Unit Tests
 --------------------------------------
 
-
 Start grunt to auto-build jQuery as you work:
 
 ```bash