Skip to content

Commit

Permalink
Add support for UglifyJS 'unsafe' option
Browse files Browse the repository at this point in the history
  • Loading branch information
everdimension authored and FagnerMartinsBrack committed Jun 19, 2016
1 parent d430a73 commit 79037c2
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
8 changes: 6 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,14 @@ module.exports = function (grunt) {
},
uglify: {
options: {
compress: {
unsafe: true
},
banner: '/*! <%= pkg.name %> v<%= pkg.version %> | <%= pkg.license %> */\n'
},
build: {
files: {
'build/js.cookie.min.js': 'src/js.cookie.js',
'build/js.cookie-<%= pkg.version %>.min.js': 'src/js.cookie.js'
}
}
Expand Down Expand Up @@ -234,9 +238,9 @@ module.exports = function (grunt) {
}

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

grunt.registerTask('dev', ['test', 'uglify', 'compare_size']);
grunt.registerTask('dev', ['test', 'compare_size']);
grunt.registerTask('ci', ['test', 'saucelabs']);

grunt.registerTask('default', 'dev');
Expand Down
8 changes: 4 additions & 4 deletions src/js.cookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@

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

Expand Down
2 changes: 1 addition & 1 deletion test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<link href="../node_modules/qunitjs/qunit/qunit.css" rel="stylesheet">
<script src="../node_modules/qunitjs/qunit/qunit.js"></script>
<script>Cookies = 'existent global'</script>
<script src="../src/js.cookie.js"></script>
<script src="../build/js.cookie.min.js"></script>
<script src="polyfill.js"></script>
<script src="utils.js"></script>
<script src="tests.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion test/malformed_cookie.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<title></title>
<script src="../src/js.cookie.js"></script>
<script src="../build/js.cookie.min.js"></script>
<script>
try {
Object.defineProperty(document, "cookie", { get: function() { return "first=one; ; second=two"; } });
Expand Down
2 changes: 1 addition & 1 deletion test/missing_semicolon.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<script src="utils.js"></script>
<script>
(function() {
var contents = window.loadFileSync('../src/js.cookie.js');
var contents = window.loadFileSync('../build/js.cookie.min.js');

if (contents !== null) {
var script = document.createElement('script');
Expand Down

0 comments on commit 79037c2

Please sign in to comment.