uglifier 1.2.6 → 1.2.7

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of uglifier might be problematic. Click here for more details.

Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/uglify.js +64 -31
  3. data/uglifier.gemspec +2 -2
  4. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.6
1
+ 1.2.7
@@ -2632,6 +2632,10 @@ exports.is_identifier_char = is_identifier_char;
2632
2632
  exports.set_logger = function(logger) {
2633
2633
  warn = logger;
2634
2634
  };
2635
+
2636
+ // Local variables:
2637
+ // js-indent-level: 8
2638
+ // End:
2635
2639
  }, "process": function(exports, require, module) {/***********************************************************************
2636
2640
 
2637
2641
  A JavaScript tokenizer / parser / beautifier / compressor.
@@ -2693,6 +2697,7 @@ exports.set_logger = function(logger) {
2693
2697
  ***********************************************************************/
2694
2698
 
2695
2699
  var jsp = require("./parse-js"),
2700
+ curry = jsp.curry,
2696
2701
  slice = jsp.slice,
2697
2702
  member = jsp.member,
2698
2703
  is_identifier_char = jsp.is_identifier_char,
@@ -3023,8 +3028,8 @@ Scope.prototype = {
3023
3028
  return name;
3024
3029
  }
3025
3030
  },
3026
- active: function(dir) {
3027
- return member(dir, this.directives) || this.parent && this.parent.active(dir);
3031
+ active_directive: function(dir) {
3032
+ return member(dir, this.directives) || this.parent && this.parent.active_directive(dir);
3028
3033
  }
3029
3034
  };
3030
3035
 
@@ -3471,9 +3476,9 @@ function prepare_ifs(ast) {
3471
3476
  var fi = statements[i];
3472
3477
  if (fi[0] != "if") continue;
3473
3478
 
3474
- if (fi[3] && walk(fi[3])) continue;
3479
+ if (fi[3]) continue;
3475
3480
 
3476
- var t = walk(fi[2]);
3481
+ var t = fi[2];
3477
3482
  if (!aborts(t)) continue;
3478
3483
 
3479
3484
  var conditional = walk(fi[1]);
@@ -3532,6 +3537,10 @@ function for_side_effects(ast, handler) {
3532
3537
  if (op == "++" || op == "--")
3533
3538
  return found.apply(this, arguments);
3534
3539
  };
3540
+ function binary(op) {
3541
+ if (op == "&&" || op == "||")
3542
+ return found.apply(this, arguments);
3543
+ };
3535
3544
  return w.with_walkers({
3536
3545
  "try": found,
3537
3546
  "throw": found,
@@ -3550,6 +3559,8 @@ function for_side_effects(ast, handler) {
3550
3559
  "return": found,
3551
3560
  "unary-prefix": unary,
3552
3561
  "unary-postfix": unary,
3562
+ "conditional": found,
3563
+ "binary": binary,
3553
3564
  "defun": found
3554
3565
  }, function(){
3555
3566
  while (true) try {
@@ -3625,7 +3636,7 @@ function ast_lift_variables(ast) {
3625
3636
  if (ret == null) ret = d;
3626
3637
  else ret = [ "seq", d, ret ];
3627
3638
  }
3628
- if (ret == null) {
3639
+ if (ret == null && w.parent()[0] != "for") {
3629
3640
  if (w.parent()[0] == "for-in")
3630
3641
  return [ "name", defs[0][0] ];
3631
3642
  return MAP.skip;
@@ -3656,6 +3667,12 @@ function ast_lift_variables(ast) {
3656
3667
  };
3657
3668
 
3658
3669
  function ast_squeeze(ast, options) {
3670
+ ast = squeeze_1(ast, options);
3671
+ ast = squeeze_2(ast, options);
3672
+ return ast;
3673
+ };
3674
+
3675
+ function squeeze_1(ast, options) {
3659
3676
  options = defaults(options, {
3660
3677
  make_seqs : true,
3661
3678
  dead_code : true,
@@ -3727,17 +3744,7 @@ function ast_squeeze(ast, options) {
3727
3744
  };
3728
3745
 
3729
3746
  function _lambda(name, args, body) {
3730
- return [ this[0], name, args, with_scope(body.scope, function() {
3731
- return tighten(body, "lambda");
3732
- }) ];
3733
- };
3734
-
3735
- function with_scope(s, cont) {
3736
- var _scope = scope;
3737
- scope = s;
3738
- var ret = cont();
3739
- scope = _scope;
3740
- return ret;
3747
+ return [ this[0], name, args, tighten(body, "lambda") ];
3741
3748
  };
3742
3749
 
3743
3750
  // this function does a few things:
@@ -3957,9 +3964,7 @@ function ast_squeeze(ast, options) {
3957
3964
  },
3958
3965
  "if": make_if,
3959
3966
  "toplevel": function(body) {
3960
- return with_scope(this.scope, function() {
3961
- return [ "toplevel", tighten(body) ];
3962
- });
3967
+ return [ "toplevel", tighten(body) ];
3963
3968
  },
3964
3969
  "switch": function(expr, body) {
3965
3970
  var last = body.length - 1;
@@ -4031,12 +4036,6 @@ function ast_squeeze(ast, options) {
4031
4036
  }
4032
4037
  return [ this[0], op, lvalue, rvalue ];
4033
4038
  },
4034
- "directive": function(dir) {
4035
- if (scope.active(dir))
4036
- return [ "block" ];
4037
- scope.directives.push(dir);
4038
- return [ this[0], dir ];
4039
- },
4040
4039
  "call": function(expr, args) {
4041
4040
  expr = walk(expr);
4042
4041
  if (options.unsafe && expr[0] == "dot" && expr[1][0] == "string" && expr[2] == "toString") {
@@ -4054,11 +4053,35 @@ function ast_squeeze(ast, options) {
4054
4053
  return [ this[0], num ];
4055
4054
  }
4056
4055
  }, function() {
4057
- for (var i = 0; i < 2; ++i) {
4058
- ast = prepare_ifs(ast);
4059
- ast = walk(ast_add_scope(ast));
4060
- }
4061
- return ast;
4056
+ return walk(prepare_ifs(walk(prepare_ifs(ast))));
4057
+ });
4058
+ };
4059
+
4060
+ function squeeze_2(ast, options) {
4061
+ var w = ast_walker(), walk = w.walk, scope;
4062
+ function with_scope(s, cont) {
4063
+ var save = scope, ret;
4064
+ scope = s;
4065
+ ret = cont();
4066
+ scope = save;
4067
+ return ret;
4068
+ };
4069
+ function lambda(name, args, body) {
4070
+ return [ this[0], name, args, with_scope(body.scope, curry(MAP, body, walk)) ];
4071
+ };
4072
+ return w.with_walkers({
4073
+ "directive": function(dir) {
4074
+ if (scope.active_directive(dir))
4075
+ return [ "block" ];
4076
+ scope.directives.push(dir);
4077
+ },
4078
+ "toplevel": function(body) {
4079
+ return [ this[0], with_scope(this.scope, curry(MAP, body, walk)) ];
4080
+ },
4081
+ "function": lambda,
4082
+ "defun": lambda
4083
+ }, function(){
4084
+ return walk(ast_add_scope(ast));
4062
4085
  });
4063
4086
  };
4064
4087
 
@@ -4467,7 +4490,9 @@ function gen_code(ast, options) {
4467
4490
  })), "]" ]);
4468
4491
  },
4469
4492
  "stat": function(stmt) {
4470
- return make(stmt).replace(/;*\s*$/, ";");
4493
+ return stmt != null
4494
+ ? make(stmt).replace(/;*\s*$/, ";")
4495
+ : ";";
4471
4496
  },
4472
4497
  "seq": function() {
4473
4498
  return add_commas(MAP(slice(arguments), make));
@@ -4723,6 +4748,10 @@ exports.MAP = MAP;
4723
4748
 
4724
4749
  // keep this last!
4725
4750
  exports.ast_squeeze_more = require("./squeeze-more").ast_squeeze_more;
4751
+
4752
+ // Local variables:
4753
+ // js-indent-level: 8
4754
+ // End:
4726
4755
  }, "squeeze-more": function(exports, require, module) {var jsp = require("./parse-js"),
4727
4756
  pro = require("./process"),
4728
4757
  slice = jsp.slice,
@@ -4797,6 +4826,10 @@ function ast_squeeze_more(ast) {
4797
4826
  };
4798
4827
 
4799
4828
  exports.ast_squeeze_more = ast_squeeze_more;
4829
+
4830
+ // Local variables:
4831
+ // js-indent-level: 8
4832
+ // End:
4800
4833
  }});
4801
4834
  ;
4802
4835
  global.UglifyJS = {};
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "uglifier"
8
- s.version = "1.2.6"
8
+ s.version = "1.2.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ville Lautanala"]
12
- s.date = "2012-06-28"
12
+ s.date = "2012-08-02"
13
13
  s.email = "lautis@gmail.com"
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE.txt",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uglifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.6
4
+ version: 1.2.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-28 00:00:00.000000000 Z
12
+ date: 2012-08-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: execjs
@@ -145,7 +145,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
145
145
  version: '0'
146
146
  segments:
147
147
  - 0
148
- hash: 1608746242454897319
148
+ hash: -3465563417105298794
149
149
  required_rubygems_version: !ruby/object:Gem::Requirement
150
150
  none: false
151
151
  requirements: