]> source.dussan.org Git - jquery.git/commitdiff
Fix #13274: Wrap sourceMap directive in multiline comments. Close gh-1143.
authorRichard Gibson <richard.gibson@gmail.com>
Wed, 23 Jan 2013 22:42:28 +0000 (17:42 -0500)
committerRichard Gibson <richard.gibson@gmail.com>
Fri, 25 Jan 2013 15:03:53 +0000 (10:03 -0500)
Gruntfile.js
test/data/core/cc_on.html [new file with mode: 0644]
test/unit/core.js

index 5b45547ff0dbdafe610a237bc4cfb852d890749d..5ad39bf02daa1ffa1068a654ba37bc3ee4033c01 100644 (file)
@@ -409,7 +409,7 @@ module.exports = function( grunt ) {
                        nonascii = false;
 
                distpaths.forEach(function( filename ) {
-                       var i, c,
+                       var i, c, map,
                                text = fs.readFileSync( filename, "utf8" );
 
                        // Ensure files use only \n for line endings, not \r\n
@@ -438,7 +438,18 @@ module.exports = function( grunt ) {
                                text = text.replace( /"dist\//g, "\"" );
                                fs.writeFileSync( filename, text, "utf-8" );
                        } else if ( /\.min\.js$/.test( filename ) ) {
-                               text = text.replace( /sourceMappingURL=dist\//, "sourceMappingURL=" );
+                               // Wrap sourceMap directive in multiline comments (#13274)
+                               text = text.replace( /\n?(\/\/@\s*sourceMappingURL=)(.*)/,
+                                       function( _, directive, path ) {
+                                               map = "\n" + directive + path.replace( /^dist\//, "" );
+                                               return "";
+                                       });
+                               if ( map ) {
+                                       text = text.replace( /(^\/\*[\w\W]*?)\s*\*\/|$/,
+                                               function( _, comment ) {
+                                                       return ( comment || "\n/*" ) + map + "\n*/";
+                                               });
+                               }
                                fs.writeFileSync( filename, text, "utf-8" );
                        }
 
diff --git a/test/data/core/cc_on.html b/test/data/core/cc_on.html
new file mode 100644 (file)
index 0000000..88bb010
--- /dev/null
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+       <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+       <script>
+               var cc_on = false,
+                       errors = [];
+/*@cc_on
+               cc_on = true;
+@*/
+               window.onerror = function( errorMessage, filePath, lineNumber ) {
+                       errors.push( errorMessage );
+               };
+       </script>
+       <script src="../../../dist/jquery.min.js"></script>
+</head>
+<body>
+       <script>
+               window.parent.iframeCallback( cc_on, errors, jQuery );
+       </script>
+</body>
+</html>
index f7612896fa7eca834cf750e8d449c526e265a540..373373185d6e32f89a8d2660ad22ede3ed439aec 100644 (file)
@@ -17,6 +17,13 @@ test("Basic requirements", function() {
        ok( $, "$" );
 });
 
+testIframeWithCallback( "Conditional compilation compatibility (#13274)", "core/cc_on.html", function( cc_on, errors, $ ) {
+       expect( 3 );
+       ok( true, "JScript conditional compilation " + ( cc_on ? "supported" : "not supported" ) );
+       deepEqual( errors, [], "No errors" );
+       ok( $(), "jQuery executes" );
+});
+
 test("jQuery()", function() {
 
        var elem, i,