Skip to content
Permalink
Browse files

Use the correct escape for BOM; add build code to detect non-ASCII.

  • Loading branch information...
dmethvin committed Oct 11, 2012
1 parent 798a7a7 commit 1450305402ee8f36825fd5fa44df913a3be2f4c8
Showing with 22 additions and 1 deletion.
  1. +21 −0 grunt.js
  2. +1 −1 src/core.js
@@ -416,6 +416,27 @@ module.exports = function( grunt ) {
return path !== "*";
});

// Ensure the dist files are pure ASCII
var fs = require("fs"),
nonascii = false;
distpaths.forEach(function( filename ) {
var buf = fs.readFileSync( filename, "utf8" ),
i, c;
if ( buf.length !== Buffer.byteLength( buf, "utf8" ) ) {
log.writeln( filename + ": Non-ASCII characters detected:" );
for ( i = 0; i < buf.length; i++ ) {
c = buf.charCodeAt( i );
if ( c > 127 ) {
log.writeln( "- position " + i + ": " + c );
log.writeln( "-- " + buf.substring( i - 20, i + 20 ) );
nonascii = true;
}
}
}
});
if ( nonascii ) {
return false;
}

// Proceed only if there are actual
// paths to write to
@@ -605,7 +605,7 @@ jQuery.extend({
},

// Use native String.trim function wherever possible
trim: core_trim && !core_trim.call("\xFEFF\xA0") ?
trim: core_trim && !core_trim.call("\uFEFF\xA0") ?
function( text ) {
return text == null ?
"" :

3 comments on commit 1450305

@FrankFang

This comment has been minimized.

Copy link

replied Oct 14, 2012

I wonder how can I fix this. ( Run on Windows 7)

D:\Code\github\jquery [master +2 ~0 -0 !]> grunt
path.existsSync is now called fs.existsSync.
Running "submodules" task

Running "selector:src/selector.js" (selector) task
File 'src/selector.js' created.

Running "build:dist/jquery.js:*" (build) task
File 'dist/jquery.js' created.

Running "lint:dist" (lint) task
Lint free.

Running "lint:grunt" (lint) task
Lint free.

Running "lint:tests" (lint) task
Lint free.

Running "min:dist/jquery.min.js" (min) task
File "dist/jquery.min.js" created.
Uncompressed size: 266813 bytes.
Compressed size: 33390 bytes gzipped (93436 bytes minified).

Running "dist:*" (dist) task
dist/jquery.js: Non-ASCII characters detected:

  • position 286: 20013
    -- 17:22:09 GMT+0800 (中国标准时间)
    */
    (functio
  • position 287: 22269
    -- 17:22:09 GMT+0800 (中国标准时间)
    */
    (function
  • position 288: 26631
    -- 7:22:09 GMT+0800 (中国标准时间)
    */
    (function(
  • position 289: 20934
    -- :22:09 GMT+0800 (中国标准时间)
    */
    (function(
  • position 290: 26102
    -- 22:09 GMT+0800 (中国标准时间)
    */
    (function( w
  • position 291: 38388
    -- 2:09 GMT+0800 (中国标准时间)
    /
    (function( wi
    Task "dist:
    " failed. Use --force to continue.

Aborted due to warnings.

@dmethvin

This comment has been minimized.

Copy link
Member Author

replied Oct 14, 2012

Hmmm, seems like we'll need to use our own date format to prevent localized time zone names from peeking through. http://bugs.jquery.com/ticket/12725

@FrankFang

This comment has been minimized.

Copy link

replied Oct 15, 2012

"grunt custom" doesn't work.
D:\Code\github\jquery [master]> grunt custom:+ajax,-dimensions,-effects,-offset
path.existsSync is now called fs.existsSync.
Running "custom:+ajax" (custom) task
Creating custom build...
Done, without errors.
D:\Code\github\jquery [master]> cd .\dist ; ls
目录: D:\Code\github\jquery\dist
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 2012/10/14 17:57 0 .sizecache.json

I don't know why there is nothing in dist.

Please sign in to comment.
You can’t perform that action at this time.