Skip to content

Commit 79037c2

Browse files
everdimensionFagnerMartinsBrack
authored andcommitted
Add support for UglifyJS 'unsafe' option
Closes js-cookiegh-207. Closes js-cookiegh-206.
1 parent d430a73 commit 79037c2

File tree

5 files changed

+13
-9
lines changed

5 files changed

+13
-9
lines changed

Gruntfile.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,14 @@ module.exports = function (grunt) {
7070
},
7171
uglify: {
7272
options: {
73+
compress: {
74+
unsafe: true
75+
},
7376
banner: '/*! <%= pkg.name %> v<%= pkg.version %> | <%= pkg.license %> */\n'
7477
},
7578
build: {
7679
files: {
80+
'build/js.cookie.min.js': 'src/js.cookie.js',
7781
'build/js.cookie-<%= pkg.version %>.min.js': 'src/js.cookie.js'
7882
}
7983
}
@@ -234,9 +238,9 @@ module.exports = function (grunt) {
234238
}
235239

236240
grunt.registerTask('saucelabs', ['connect:build-sauce', 'saucelabs-qunit']);
237-
grunt.registerTask('test', ['jshint', 'jscs', 'connect:build-qunit', 'qunit', 'nodeunit']);
241+
grunt.registerTask('test', ['uglify', 'jshint', 'jscs', 'connect:build-qunit', 'qunit', 'nodeunit']);
238242

239-
grunt.registerTask('dev', ['test', 'uglify', 'compare_size']);
243+
grunt.registerTask('dev', ['test', 'compare_size']);
240244
grunt.registerTask('ci', ['test', 'saucelabs']);
241245

242246
grunt.registerTask('default', 'dev');

src/js.cookie.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@
7171

7272
return (document.cookie = [
7373
key, '=', value,
74-
attributes.expires && '; expires=' + attributes.expires.toUTCString(), // use expires attribute, max-age is not supported by IE
75-
attributes.path && '; path=' + attributes.path,
76-
attributes.domain && '; domain=' + attributes.domain,
77-
attributes.secure ? '; secure' : ''
74+
attributes.expires ? '; expires=' + attributes.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
75+
attributes.path ? '; path=' + attributes.path : '',
76+
attributes.domain ? '; domain=' + attributes.domain : '',
77+
attributes.secure ? '; secure' : ''
7878
].join(''));
7979
}
8080

test/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<link href="../node_modules/qunitjs/qunit/qunit.css" rel="stylesheet">
77
<script src="../node_modules/qunitjs/qunit/qunit.js"></script>
88
<script>Cookies = 'existent global'</script>
9-
<script src="../src/js.cookie.js"></script>
9+
<script src="../build/js.cookie.min.js"></script>
1010
<script src="polyfill.js"></script>
1111
<script src="utils.js"></script>
1212
<script src="tests.js"></script>

test/malformed_cookie.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33
<head>
44
<title></title>
5-
<script src="../src/js.cookie.js"></script>
5+
<script src="../build/js.cookie.min.js"></script>
66
<script>
77
try {
88
Object.defineProperty(document, "cookie", { get: function() { return "first=one; ; second=two"; } });

test/missing_semicolon.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<script src="utils.js"></script>
99
<script>
1010
(function() {
11-
var contents = window.loadFileSync('../src/js.cookie.js');
11+
var contents = window.loadFileSync('../build/js.cookie.min.js');
1212

1313
if (contents !== null) {
1414
var script = document.createElement('script');

0 commit comments

Comments
 (0)