Commit 131de8c8 authored by Dave Methvin's avatar Dave Methvin Committed by Richard Gibson

No ticket: Grunt changes from 2.0 selector-native

(cherry picked from commits 1083f82d 8be9cd1c 054c6946)
parent 336cf71a
src/selector-sizzle.js
src/selector.js src/selector.js
dist dist
.project .project
......
...@@ -22,7 +22,7 @@ module.exports = function( grunt ) { ...@@ -22,7 +22,7 @@ module.exports = function( grunt ) {
files: distpaths files: distpaths
}, },
selector: { selector: {
destFile: "src/selector.js", destFile: "src/selector-sizzle.js",
apiFile: "src/sizzle-jquery.js", apiFile: "src/sizzle-jquery.js",
srcFile: "src/sizzle/dist/sizzle.js" srcFile: "src/sizzle/dist/sizzle.js"
}, },
...@@ -39,10 +39,9 @@ module.exports = function( grunt ) { ...@@ -39,10 +39,9 @@ module.exports = function( grunt ) {
"src/queue.js", "src/queue.js",
"src/attributes.js", "src/attributes.js",
"src/event.js", "src/event.js",
"src/selector.js", "src/selector-sizzle.js",
"src/traversing.js", "src/traversing.js",
"src/manipulation.js", "src/manipulation.js",
{ flag: "css", src: "src/css.js" }, { flag: "css", src: "src/css.js" },
"src/serialize.js", "src/serialize.js",
{ flag: "event-alias", src: "src/event-alias.js" }, { flag: "event-alias", src: "src/event-alias.js" },
...@@ -151,8 +150,7 @@ module.exports = function( grunt ) { ...@@ -151,8 +150,7 @@ module.exports = function( grunt ) {
}); });
}); });
// Build src/selector.js grunt.registerTask( "selector", "Build Sizzle-based selector module", function() {
grunt.registerTask( "selector", "Build src/selector.js", function() {
var cfg = grunt.config("selector"), var cfg = grunt.config("selector"),
name = cfg.destFile, name = cfg.destFile,
...@@ -196,7 +194,7 @@ module.exports = function( grunt ) { ...@@ -196,7 +194,7 @@ module.exports = function( grunt ) {
// Rejoin the pieces // Rejoin the pieces
compiled = parts.join(""); 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 // Write concatenated source to file, and ensure newline-only termination
grunt.file.write( name, compiled.replace( /\x0d\x0a/g, "\x0a" ) ); grunt.file.write( name, compiled.replace( /\x0d\x0a/g, "\x0a" ) );
...@@ -334,37 +332,47 @@ module.exports = function( grunt ) { ...@@ -334,37 +332,47 @@ module.exports = function( grunt ) {
var flag = filepath.flag, var flag = filepath.flag,
specified = false, specified = false,
omit = false, omit = false,
message = ""; messages = [];
if ( flag ) { if ( flag ) {
if ( excluded[ flag ] !== undefined ) { if ( excluded[ flag ] !== undefined ) {
message = ( "Excluding " + flag ).red; messages.push([
( "Excluding " + flag ).red,
( "(" + filepath.src + ")" ).grey
]);
specified = true; specified = true;
omit = true; omit = !filepath.alt;
} else { if ( !omit ) {
message = ( "Including " + flag ).green; 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 // 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 // output list
if ( modules[ "+" + flag ] ) { if ( modules[ "+" + flag ] ) {
specified = true; specified = true;
} }
} }
filepath = filepath.src;
// Only display the inclusion/exclusion list when handling // Only display the inclusion/exclusion list when handling
// an explicit list. // an explicit list.
// //
// Additionally, only display modules that have been specified // Additionally, only display modules that have been specified
// by the user // by the user
if ( explicit && specified ) { if ( explicit && specified ) {
grunt.log.writetableln([ 27, 30 ], [ messages.forEach(function( message ) {
message, grunt.log.writetableln( [ 27, 30 ], message );
( "(" + filepath.src + ")").grey });
]);
} }
filepath = filepath.src;
} }
if ( !omit ) { if ( !omit ) {
......
...@@ -68,18 +68,26 @@ grunt ...@@ -68,18 +68,26 @@ grunt
The built version of jQuery will be put in the `dist/` subdirectory. 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 - **ajax**: All AJAX functionality: `$.ajax()`, `$.get()`, `$.post()`, `$.ajaxSetup()`, `.load()`, transports, and ajax event shorthands such as `.ajaxStart()`.
- css - **ajax/xhr**: The XMLHTTPRequest AJAX transport only.
- dimensions - **ajax/script**: The `<script>` AJAX transport only; used to retrieve scripts.
- effects - **ajax/jsonp**: The JSONP AJAX transport only; depends on the ajax/script transport.
- offset - **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 ```bash
git pull; git checkout $(git describe --abbrev=0 --tags) 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 ...@@ -91,58 +99,31 @@ Then, make sure all Node dependencies are installed and all Git submodules are c
npm install && grunt 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 ```bash
grunt custom:-ajax grunt custom:-ajax
``` ```
Exclude **css**: Exclude **css**, **effects**, **offset**, **dimensions**, and **position**. Excluding **css** automatically excludes its dependent modules:
```bash ```bash
grunt custom:-css grunt custom:-css:-position
```
Exclude **deprecated**:
```bash
grunt custom:-deprecated
```
Exclude **dimensions**:
```bash
grunt custom:-dimensions
```
Exclude **effects**:
```bash
grunt custom:-effects
```
Exclude **offset**:
```bash
grunt custom:-offset
``` ```
Exclude **all** optional modules: Exclude **all** optional modules:
```bash ```bash
grunt custom:-ajax,-css,-deprecated,-dimensions,-effects,-offset grunt custom:-ajax,-css,-deprecated,-dimensions,-effects,-event-alias,-offset
``` ```
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.
Note: dependencies will be handled internally, by the build process.
Running the Unit Tests Running the Unit Tests
-------------------------------------- --------------------------------------
Start grunt to auto-build jQuery as you work: Start grunt to auto-build jQuery as you work:
```bash ```bash
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment