autoprefixer-rails 0.3.20130502 → 0.4.20130507

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,8 @@
1
+ == 0.4 (Winter Is Coming)
2
+ * Remove outdated prefixes.
3
+ * Add border-radius and box-shadow properties to database.
4
+ * Change degrees in webkit gradients.
5
+
1
6
  == 0.3 (Growing Strong)
2
7
  * Use own filters instead of Rework’s `prefix` and `prefixValue`.
3
8
  * Smarter value prefixer without false match “order” in “border”.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- autoprefixer-rails (0.3.20130502)
4
+ autoprefixer-rails (0.4.20130507)
5
5
  execjs
6
6
 
7
7
  GEM
@@ -50,7 +50,7 @@ GEM
50
50
  mime-types (~> 1.16)
51
51
  treetop (~> 1.4.8)
52
52
  mime-types (1.23)
53
- multi_json (1.7.2)
53
+ multi_json (1.7.3)
54
54
  polyglot (0.3.3)
55
55
  rack (1.4.5)
56
56
  rack-cache (1.2)
data/README.md CHANGED
@@ -44,6 +44,7 @@ Sponsored by [Evil Martians](http://evilmartians.com/).
44
44
  * Properties and browsers database is updated automatically
45
45
  (from [Can I Use](http://caniuse.com/)), so prefixes will be always actual
46
46
  (scripts don’t have holidays and work).
47
+ * Remove outdated prefixes to clean libraries and legacy code.
47
48
  * It also adds prefixes to the values. For example, to `calc(1em + 5px)` or
48
49
  to properties names in `transition`.
49
50
 
@@ -1,3 +1,3 @@
1
1
  module AutoprefixerRails
2
- VERSION = '0.3.20130502'.freeze unless defined? AutoprefixerRails::VERSION
2
+ VERSION = '0.4.20130507'.freeze unless defined? AutoprefixerRails::VERSION
3
3
  end
@@ -2744,7 +2744,26 @@ module.exports = {
2744
2744
  "ios 4.3",
2745
2745
  "ios 5.0",
2746
2746
  "ios 5.1"
2747
- ]
2747
+ ],
2748
+ replace: function (string, prefix) {
2749
+ var regexp;
2750
+ if (prefix !== '-webkit-') {
2751
+ return;
2752
+ }
2753
+ regexp = /((repeating-)?(linear|radial)-gradient\()\s*(-?\d+deg)?/g;
2754
+ return string.replace(regexp, function (_0, gradient, _1, _2, deg) {
2755
+ if (deg) {
2756
+ deg = parseInt(deg);
2757
+ deg += 90;
2758
+ if (deg > 360) {
2759
+ deg -= 360;
2760
+ }
2761
+ return prefix + gradient + deg + 'deg';
2762
+ } else {
2763
+ return prefix + gradient;
2764
+ }
2765
+ });
2766
+ }
2748
2767
  },
2749
2768
  "radial-gradient": {
2750
2769
  props: [
@@ -2803,7 +2822,26 @@ module.exports = {
2803
2822
  "ios 4.3",
2804
2823
  "ios 5.0",
2805
2824
  "ios 5.1"
2806
- ]
2825
+ ],
2826
+ replace: function (string, prefix) {
2827
+ var regexp;
2828
+ if (prefix !== '-webkit-') {
2829
+ return;
2830
+ }
2831
+ regexp = /((repeating-)?(linear|radial)-gradient\()\s*(-?\d+deg)?/g;
2832
+ return string.replace(regexp, function (_0, gradient, _1, _2, deg) {
2833
+ if (deg) {
2834
+ deg = parseInt(deg);
2835
+ deg += 90;
2836
+ if (deg > 360) {
2837
+ deg -= 360;
2838
+ }
2839
+ return prefix + gradient + deg + 'deg';
2840
+ } else {
2841
+ return prefix + gradient;
2842
+ }
2843
+ });
2844
+ }
2807
2845
  },
2808
2846
  "repeating-linear-gradient": {
2809
2847
  props: [
@@ -2862,7 +2900,26 @@ module.exports = {
2862
2900
  "ios 4.3",
2863
2901
  "ios 5.0",
2864
2902
  "ios 5.1"
2865
- ]
2903
+ ],
2904
+ replace: function (string, prefix) {
2905
+ var regexp;
2906
+ if (prefix !== '-webkit-') {
2907
+ return;
2908
+ }
2909
+ regexp = /((repeating-)?(linear|radial)-gradient\()\s*(-?\d+deg)?/g;
2910
+ return string.replace(regexp, function (_0, gradient, _1, _2, deg) {
2911
+ if (deg) {
2912
+ deg = parseInt(deg);
2913
+ deg += 90;
2914
+ if (deg > 360) {
2915
+ deg -= 360;
2916
+ }
2917
+ return prefix + gradient + deg + 'deg';
2918
+ } else {
2919
+ return prefix + gradient;
2920
+ }
2921
+ });
2922
+ }
2866
2923
  },
2867
2924
  "repeating-radial-gradient": {
2868
2925
  props: [
@@ -2921,7 +2978,26 @@ module.exports = {
2921
2978
  "ios 4.3",
2922
2979
  "ios 5.0",
2923
2980
  "ios 5.1"
2924
- ]
2981
+ ],
2982
+ replace: function (string, prefix) {
2983
+ var regexp;
2984
+ if (prefix !== '-webkit-') {
2985
+ return;
2986
+ }
2987
+ regexp = /((repeating-)?(linear|radial)-gradient\()\s*(-?\d+deg)?/g;
2988
+ return string.replace(regexp, function (_0, gradient, _1, _2, deg) {
2989
+ if (deg) {
2990
+ deg = parseInt(deg);
2991
+ deg += 90;
2992
+ if (deg > 360) {
2993
+ deg -= 360;
2994
+ }
2995
+ return prefix + gradient + deg + 'deg';
2996
+ } else {
2997
+ return prefix + gradient;
2998
+ }
2999
+ });
3000
+ }
2925
3001
  }
2926
3002
  };
2927
3003
 
@@ -3728,6 +3804,110 @@ module.exports = {
3728
3804
  ],
3729
3805
  transition: true
3730
3806
  },
3807
+ "border-bottom-left-radius": {
3808
+ browsers: [
3809
+ "ff 2",
3810
+ "ff 3",
3811
+ "ff 3.5",
3812
+ "ff 3.6",
3813
+ "chrome 4",
3814
+ "safari 4",
3815
+ "safari 3.1",
3816
+ "safari 3.2",
3817
+ "ios 3.2"
3818
+ ],
3819
+ transition: true,
3820
+ prefixed: {
3821
+ "-moz-": "moz-border-radius-bottomleft"
3822
+ }
3823
+ },
3824
+ "border-bottom-right-radius": {
3825
+ browsers: [
3826
+ "ff 2",
3827
+ "ff 3",
3828
+ "ff 3.5",
3829
+ "ff 3.6",
3830
+ "chrome 4",
3831
+ "safari 4",
3832
+ "safari 3.1",
3833
+ "safari 3.2",
3834
+ "ios 3.2"
3835
+ ],
3836
+ transition: true,
3837
+ prefixed: {
3838
+ "-moz-": "moz-border-radius-bottomright"
3839
+ }
3840
+ },
3841
+ "border-radius": {
3842
+ browsers: [
3843
+ "ff 2",
3844
+ "ff 3",
3845
+ "ff 3.5",
3846
+ "ff 3.6",
3847
+ "chrome 4",
3848
+ "safari 4",
3849
+ "safari 3.1",
3850
+ "safari 3.2",
3851
+ "ios 3.2"
3852
+ ],
3853
+ transition: true
3854
+ },
3855
+ "border-top-left-radius": {
3856
+ browsers: [
3857
+ "ff 2",
3858
+ "ff 3",
3859
+ "ff 3.5",
3860
+ "ff 3.6",
3861
+ "chrome 4",
3862
+ "safari 4",
3863
+ "safari 3.1",
3864
+ "safari 3.2",
3865
+ "ios 3.2"
3866
+ ],
3867
+ transition: true,
3868
+ prefixed: {
3869
+ "-moz-": "moz-border-radius-topleft"
3870
+ }
3871
+ },
3872
+ "border-top-right-radius": {
3873
+ browsers: [
3874
+ "ff 2",
3875
+ "ff 3",
3876
+ "ff 3.5",
3877
+ "ff 3.6",
3878
+ "chrome 4",
3879
+ "safari 4",
3880
+ "safari 3.1",
3881
+ "safari 3.2",
3882
+ "ios 3.2"
3883
+ ],
3884
+ transition: true,
3885
+ prefixed: {
3886
+ "-moz-": "moz-border-radius-topright"
3887
+ }
3888
+ },
3889
+ "box-shadow": {
3890
+ browsers: [
3891
+ "ff 3.5",
3892
+ "ff 3.6",
3893
+ "chrome 4",
3894
+ "chrome 5",
3895
+ "chrome 6",
3896
+ "chrome 7",
3897
+ "chrome 8",
3898
+ "chrome 9",
3899
+ "safari 4",
3900
+ "safari 5",
3901
+ "safari 3.1",
3902
+ "safari 3.2",
3903
+ "ios 3.2",
3904
+ "ios 4.0",
3905
+ "ios 4.1",
3906
+ "ios 4.2",
3907
+ "ios 4.3"
3908
+ ],
3909
+ transition: true
3910
+ },
3731
3911
  "box-sizing": {
3732
3912
  browsers: [
3733
3913
  "ff 2",
@@ -6058,6 +6238,7 @@ require.register("autoprefixer/lib/autoprefixer.js", function(exports, require,
6058
6238
  * You should have received a copy of the GNU Lesser General Public License
6059
6239
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
6060
6240
  */
6241
+ (function () {
6061
6242
  'use strict';
6062
6243
 
6063
6244
  var rework = require('rework');
@@ -6075,7 +6256,7 @@ var uniq = function (array) {
6075
6256
 
6076
6257
  // Split prefix and property name.
6077
6258
  var splitPrefix = function (prop) {
6078
- if ( prop[0] == '-' ) {
6259
+ if ( prop[0] === '-' ) {
6079
6260
  var sep = prop.indexOf('-', 1) + 1;
6080
6261
  return { prefix: prop.slice(0, sep), name: prop.slice(sep) };
6081
6262
  } else {
@@ -6086,7 +6267,7 @@ var splitPrefix = function (prop) {
6086
6267
  // Generate RegExp to test, does CSS value contain some `word`.
6087
6268
  var containRegexp = function (word) {
6088
6269
  return new RegExp('(^|\\s|,|\\()' +
6089
- word.replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1") +
6270
+ word.replace(/([.?*+\^\$\[\]\\(){}|\-])/g, "\\$1") +
6090
6271
  '($|\\s|\\()', 'ig');
6091
6272
  };
6092
6273
 
@@ -6144,28 +6325,31 @@ var autoprefixer = {
6144
6325
  requirements = [requirements];
6145
6326
  }
6146
6327
 
6147
- var browsers = this.parse(requirements);
6148
- var props = this.prefixes(browsers);
6328
+ var browsers = this.parse(requirements);
6329
+ var values = this.filter(this.data.values, browsers);
6330
+ var props = this.filter(this.data.props, browsers);
6331
+ var prefixes = this.prefixes(props, values);
6332
+ var unprefixes = this.unprefixes(props, values);
6149
6333
 
6150
- return function (style, css) {
6151
- autoprefixer.prefixer(props, style, css);
6334
+ return function (style) {
6335
+ autoprefixer.unprefixer(unprefixes, style);
6336
+ autoprefixer.prefixer(prefixes, style);
6152
6337
  };
6153
6338
  },
6154
6339
 
6155
- // Change `style` declarations in parsed `css`, to add prefixes for `props`.
6156
- prefixer: function (props, style, css) {
6340
+ // Change `style` declarations in parsed CSS, to add prefixes for `props`.
6341
+ prefixer: function (props, style) {
6157
6342
  if ( props['@keyframes'] ) {
6158
6343
  // Keyframes
6159
-
6160
- style.rules.forEach(function(rule) {
6344
+ style.rules.forEach(function(rule) {
6161
6345
  if ( !rule.keyframes ) {
6162
6346
  return;
6163
6347
  }
6164
6348
 
6165
6349
  props['@keyframes'].prefixes.forEach(function (prefix) {
6166
6350
  var contain = style.rules.some(function (other) {
6167
- return other.keyframes && rule.name == other.name &&
6168
- other.vendor == prefix;
6351
+ return other.keyframes && rule.name === other.name &&
6352
+ other.vendor === prefix;
6169
6353
  });
6170
6354
  if ( contain ) {
6171
6355
  return;
@@ -6207,7 +6391,7 @@ var autoprefixer = {
6207
6391
 
6208
6392
  var contain = function (rules, prop, value) {
6209
6393
  return rules.some(function (rule) {
6210
- return rule.property == prop && rule.value == value;
6394
+ return rule.property === prop && rule.value === value;
6211
6395
  });
6212
6396
  };
6213
6397
  var add = function (rules, num, prop, value) {
@@ -6218,11 +6402,12 @@ var autoprefixer = {
6218
6402
  rules.splice(num, 0, { property: prop, value: value });
6219
6403
  return num + 1;
6220
6404
  };
6405
+ var num, rule, prop;
6221
6406
 
6222
6407
  // Properties
6223
- for ( var num = 0; num < rules.length; num += 1 ) {
6224
- var rule = rules[num];
6225
- var prop = props[rule.property];
6408
+ for ( num = 0; num < rules.length; num += 1 ) {
6409
+ rule = rules[num];
6410
+ prop = props[rule.property];
6226
6411
 
6227
6412
  if ( !prop || !prop.prefixes ) {
6228
6413
  continue;
@@ -6232,14 +6417,14 @@ var autoprefixer = {
6232
6417
  }
6233
6418
 
6234
6419
  prop.prefixes.forEach(function (prefix) {
6235
- if ( vendor && vendor != prefix ) {
6420
+ if ( vendor && vendor !== prefix ) {
6236
6421
  return;
6237
6422
  }
6238
6423
  var wrong = prefixes.some(function (other) {
6239
- if ( other == prefix ) {
6424
+ if ( other === prefix ) {
6240
6425
  return false;
6241
6426
  }
6242
- return rule.value.indexOf(other) != -1;
6427
+ return rule.value.indexOf(other) !== -1;
6243
6428
  });
6244
6429
  if ( wrong ) {
6245
6430
  return;
@@ -6247,15 +6432,15 @@ var autoprefixer = {
6247
6432
 
6248
6433
  num = add(rules, num, prefix + rule.property, rule.value);
6249
6434
  });
6250
- };
6435
+ }
6251
6436
 
6252
6437
  // Values
6253
- for ( var num = 0; num < rules.length; num += 1 ) {
6254
- var rule = rules[num];
6438
+ for ( num = 0; num < rules.length; num += 1 ) {
6439
+ rule = rules[num];
6255
6440
 
6256
- var split = splitPrefix(rule.property);
6257
- var prop = props[split.name];
6441
+ var split = splitPrefix(rule.property);
6258
6442
  var propVendor = split.prefix || vendor;
6443
+ prop = props[split.name];
6259
6444
 
6260
6445
  var valuePrefixer = function (values) {
6261
6446
  var prefixed = { };
@@ -6267,12 +6452,22 @@ var autoprefixer = {
6267
6452
  }
6268
6453
 
6269
6454
  value.prefixes.forEach(function (prefix) {
6270
- if ( propVendor && propVendor != prefix ) {
6455
+ if ( propVendor && propVendor !== prefix ) {
6271
6456
  return;
6272
6457
  }
6273
6458
  if ( !prefixed[prefix]) {
6274
6459
  prefixed[prefix] = rule.value;
6275
6460
  }
6461
+ if ( value.replace ) {
6462
+ if ( prefixed[prefix].match(value.regexp) ) {
6463
+ var replaced = value.replace(
6464
+ prefixed[prefix], prefix);
6465
+ if ( replaced ) {
6466
+ prefixed[prefix] = replaced;
6467
+ return;
6468
+ }
6469
+ }
6470
+ }
6276
6471
  prefixed[prefix] = prefixed[prefix].replace(
6277
6472
  value.regexp, '$1' + prefix + name + '$2');
6278
6473
  });
@@ -6280,7 +6475,7 @@ var autoprefixer = {
6280
6475
 
6281
6476
 
6282
6477
  for ( var prefix in prefixed ) {
6283
- if ( prefixed[prefix] != rule.value ) {
6478
+ if ( prefixed[prefix] !== rule.value ) {
6284
6479
  if ( propVendor ) {
6285
6480
  var exists = contain(rules, rule.property,
6286
6481
  prefixed[prefix]);
@@ -6310,9 +6505,47 @@ var autoprefixer = {
6310
6505
  });
6311
6506
  },
6312
6507
 
6508
+ // Change `style` declarations in parsed CSS, to remove `remove`.
6509
+ unprefixer: function (remove, style) {
6510
+ var all = remove.values['*'];
6511
+
6512
+ // Keyframes
6513
+ style.rules = style.rules.filter(function (rule) {
6514
+ return !(rule.keyframes && remove.keyframes[rule.vendor]);
6515
+ });
6516
+
6517
+ rework.visit.declarations(style, function (rules) {
6518
+ for ( var num = 0; num < rules.length; num += 1 ) {
6519
+ var rule = rules[num];
6520
+
6521
+ // Properties
6522
+ if ( remove.props[rule.property] ) {
6523
+ rules.splice(num, 1);
6524
+ continue;
6525
+ }
6526
+
6527
+ // Values
6528
+ var prop = splitPrefix(rule.property).name;
6529
+ var values = all;
6530
+ if ( remove.values[prop] ) {
6531
+ values = values.concat(remove.values[prop]);
6532
+ }
6533
+ if ( prop === 'transition' || prop === 'transition-property' ) {
6534
+ values = values.concat(remove.transition);
6535
+ }
6536
+ values.forEach(function (value) {
6537
+ if ( rule.value.match(value) ) {
6538
+ rules.splice(num, 1);
6539
+ return false;
6540
+ }
6541
+ });
6542
+ }
6543
+ });
6544
+ },
6545
+
6313
6546
  // Return array of browsers for requirements in free form.
6314
6547
  parse: function (requirements) {
6315
- if ( requirements.length == 0 ) {
6548
+ if ( requirements.length === 0 ) {
6316
6549
  requirements = ['last 2 versions'];
6317
6550
  }
6318
6551
 
@@ -6395,18 +6628,18 @@ var autoprefixer = {
6395
6628
  for ( var name in data ) {
6396
6629
  var need = data[name].browsers;
6397
6630
  var prefixes = browsers.filter(function (browser) {
6398
- return need.indexOf(browser) != -1;
6631
+ return need.indexOf(browser) !== -1;
6399
6632
  }).map(function (browser) {
6400
6633
  var key = browser.split(' ')[0];
6401
6634
  return autoprefixer.data.browsers[key].prefix;
6402
- }).sort(function (a, b) { return b.length - a.length });
6635
+ }).sort(function (a, b) { return b.length - a.length; });
6403
6636
 
6404
6637
  if ( prefixes.length ) {
6405
6638
  prefixes = uniq(prefixes);
6406
6639
 
6407
- var obj = { prefixes: prefixes }
6640
+ var obj = { prefixes: prefixes };
6408
6641
  for ( var key in data[name] ) {
6409
- if ( key == 'browsers' ) {
6642
+ if ( key === 'browsers' ) {
6410
6643
  continue;
6411
6644
  }
6412
6645
  obj[key] = data[name][key];
@@ -6423,10 +6656,7 @@ var autoprefixer = {
6423
6656
  },
6424
6657
 
6425
6658
  // Return properties, which them prefixed values inside.
6426
- prefixes: function (browsers) {
6427
- var values = this.filter(this.data.values, browsers);
6428
- var props = this.filter(this.data.props, browsers);
6429
-
6659
+ prefixes: function (props, values) {
6430
6660
  for ( var name in values ) {
6431
6661
  values[name].props.forEach(function (prop) {
6432
6662
  if ( !props[prop] ) {
@@ -6440,10 +6670,69 @@ var autoprefixer = {
6440
6670
  }
6441
6671
 
6442
6672
  return props;
6673
+ },
6674
+
6675
+ // Return old properties and values to remove.
6676
+ unprefixes: function (props, values) {
6677
+ var remove = { props: {}, values: {}, transition: [], keyframes: {} };
6678
+ var name, prefixes, prop, value, names;
6679
+
6680
+ for ( name in this.data.props ) {
6681
+ prop = this.data.props[name];
6682
+ prefixes = prop.browsers.map(function (b) {
6683
+ var key = b.split(' ')[0];
6684
+ return autoprefixer.data.browsers[key].prefix;
6685
+ });
6686
+ uniq(prefixes).filter(function (prefix) {
6687
+ if ( !props[name] ) {
6688
+ return true;
6689
+ }
6690
+ return props[name].prefixes.indexOf(prefix) === -1;
6691
+ }).forEach(function (prefix) {
6692
+ if ( prop.transition ) {
6693
+ remove.transition.push(containRegexp(prefix + name));
6694
+ }
6695
+ if ( name === '@keyframes' ) {
6696
+ remove.keyframes[prefix] = true;
6697
+ } else {
6698
+ if ( prop.prefixed && prop.prefixed[prefix] ) {
6699
+ remove.props[prop.prefixed[prefix]] = true;
6700
+ } else {
6701
+ remove.props[prefix + name] = true;
6702
+ }
6703
+ }
6704
+ });
6705
+ }
6706
+
6707
+ for ( name in this.data.values ) {
6708
+ value = this.data.values[name];
6709
+ prefixes = value.browsers.map(function (b) {
6710
+ var key = b.split(' ')[0];
6711
+ return autoprefixer.data.browsers[key].prefix;
6712
+ });
6713
+ names = uniq(prefixes).filter(function (prefix) {
6714
+ if ( !values[name] ) {
6715
+ return true;
6716
+ }
6717
+ return values[name].prefixes.indexOf(prefix) === -1;
6718
+ }).map(function (prefix) {
6719
+ return containRegexp(prefix + name);
6720
+ });
6721
+
6722
+ value.props.forEach(function (prop) {
6723
+ if ( !remove.values[prop] ) {
6724
+ remove.values[prop] = [];
6725
+ }
6726
+ remove.values[prop] = remove.values[prop].concat(names);
6727
+ });
6728
+ }
6729
+
6730
+ return remove;
6443
6731
  }
6444
6732
  };
6445
6733
 
6446
6734
  module.exports = autoprefixer;
6735
+ })();
6447
6736
 
6448
6737
  });
6449
6738
  require.alias("visionmedia-rework/index.js", "autoprefixer/deps/rework/index.js");
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autoprefixer-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.20130502
4
+ version: 0.4.20130507
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: 2013-05-02 00:00:00.000000000 Z
12
+ date: 2013-05-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: execjs
@@ -82,7 +82,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
82
82
  version: '0'
83
83
  segments:
84
84
  - 0
85
- hash: -3902734870157313034
85
+ hash: -3871692389760765521
86
86
  required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  none: false
88
88
  requirements:
@@ -91,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
91
  version: '0'
92
92
  segments:
93
93
  - 0
94
- hash: -3902734870157313034
94
+ hash: -3871692389760765521
95
95
  requirements: []
96
96
  rubyforge_project:
97
97
  rubygems_version: 1.8.23