less 3.7.0 → 3.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/Gruntfile.js +45 -7
  3. package/bin/lessc +24 -5
  4. package/dist/less.js +644 -210
  5. package/dist/less.min.js +7 -7
  6. package/lib/less/constants.js +13 -0
  7. package/lib/less/contexts.js +38 -10
  8. package/lib/less/default-options.js +1 -1
  9. package/lib/less/functions/color.js +84 -41
  10. package/lib/less/functions/data-uri.js +1 -1
  11. package/lib/less/functions/list.js +44 -9
  12. package/lib/less/import-manager.js +3 -3
  13. package/lib/less/index.js +1 -1
  14. package/lib/less/parse.js +1 -1
  15. package/lib/less/parser/parser.js +2 -9
  16. package/lib/less/source-map-output.js +2 -2
  17. package/lib/less/tree/color.js +58 -18
  18. package/lib/less/tree/declaration.js +1 -1
  19. package/lib/less/tree/expression.js +1 -1
  20. package/lib/less/tree/import.js +9 -8
  21. package/lib/less/tree/operation.js +1 -1
  22. package/lib/less/tree/url.js +12 -8
  23. package/lib/less/tree/variable-call.js +6 -3
  24. package/lib/less/utils.js +36 -26
  25. package/lib/less-browser/add-default-options.js +4 -0
  26. package/lib/less-browser/index.js +9 -2
  27. package/lib/less-node/image-size.js +1 -1
  28. package/lib/less-node/lessc-helper.js +2 -1
  29. package/package.json +5 -3
  30. package/test/browser/css/rewrite-urls/urls.css +36 -0
  31. package/test/browser/css/rootpath-rewrite-urls/urls.css +35 -0
  32. package/test/browser/less/rewrite-urls/urls.less +34 -0
  33. package/test/browser/less/rootpath-rewrite-urls/urls.less +33 -0
  34. package/test/browser/less.js +644 -210
  35. package/test/browser/runner-rewrite-urls-options.js +3 -0
  36. package/test/browser/runner-rewrite-urls-spec.js +3 -0
  37. package/test/browser/runner-rootpath-relative-spec.js +1 -1
  38. package/test/browser/runner-rootpath-rewrite-urls-options.js +4 -0
  39. package/test/browser/runner-rootpath-rewrite-urls-spec.js +3 -0
  40. package/test/css/colors.css +20 -3
  41. package/test/css/css-escapes.css +3 -0
  42. package/test/css/functions-each.css +34 -0
  43. package/test/css/functions.css +4 -4
  44. package/test/css/rewrite-urls-all/rewrite-urls-all.css +17 -0
  45. package/test/css/rewrite-urls-local/rewrite-urls-local.css +17 -0
  46. package/test/css/rootpath-rewrite-urls-all/rootpath-rewrite-urls-all.css +17 -0
  47. package/test/css/rootpath-rewrite-urls-local/rootpath-rewrite-urls-local.css +17 -0
  48. package/test/css/static-urls/urls.css +2 -2
  49. package/test/css/urls.css +2 -2
  50. package/test/index.js +8 -2
  51. package/test/less/colors.less +18 -0
  52. package/test/less/css-escapes.less +4 -0
  53. package/test/less/errors/color-func-invalid-color.txt +1 -1
  54. package/test/less/functions-each.less +51 -1
  55. package/test/less/rewrite-urls-all/folder/file.less +8 -0
  56. package/test/less/rewrite-urls-all/rewrite-urls-all.less +11 -0
  57. package/test/less/rewrite-urls-local/folder/file.less +8 -0
  58. package/test/less/rewrite-urls-local/rewrite-urls-local.less +11 -0
  59. package/test/less/rootpath-rewrite-urls-all/folder/file.less +8 -0
  60. package/test/less/rootpath-rewrite-urls-all/rootpath-rewrite-urls-all.less +11 -0
  61. package/test/less/rootpath-rewrite-urls-local/folder/file.less +8 -0
  62. package/test/less/rootpath-rewrite-urls-local/rootpath-rewrite-urls-local.less +11 -0
  63. package/test/less/sourcemaps/custom-props.less +8 -0
  64. package/test/less-bom/colors.less +18 -0
  65. package/test/less-bom/css-escapes.less +4 -0
  66. package/test/less-bom/errors/color-func-invalid-color.txt +1 -1
  67. package/test/less-bom/functions-each.less +51 -1
  68. package/test/less-bom/rewrite-urls-all/folder/file.less +8 -0
  69. package/test/less-bom/rewrite-urls-all/rewrite-urls-all.less +11 -0
  70. package/test/less-bom/rewrite-urls-local/folder/file.less +8 -0
  71. package/test/less-bom/rewrite-urls-local/rewrite-urls-local.less +11 -0
  72. package/test/less-bom/rootpath-rewrite-urls-all/folder/file.less +8 -0
  73. package/test/less-bom/rootpath-rewrite-urls-all/rootpath-rewrite-urls-all.less +11 -0
  74. package/test/less-bom/rootpath-rewrite-urls-local/folder/file.less +8 -0
  75. package/test/less-bom/rootpath-rewrite-urls-local/rootpath-rewrite-urls-local.less +11 -0
  76. package/test/less-bom/sourcemaps/custom-props.less +8 -0
  77. package/test/less-test.js +26 -12
  78. package/test/sourcemaps/custom-props.json +1 -0
  79. package/.npmignore +0 -8
  80. package/lib/less/math-constants.js +0 -6
  81. package/test/css/3rd-party/bootstrap.css +0 -6814
  82. package/test/less/3rd-party/bootstrap.less +0 -1
  83. package/test/less/errors/color-invalid-hex-code.less +0 -4
  84. package/test/less/errors/color-invalid-hex-code.txt +0 -4
  85. package/test/less/errors/color-invalid-hex-code2.less +0 -4
  86. package/test/less/errors/color-invalid-hex-code2.txt +0 -4
  87. package/test/less-bom/3rd-party/bootstrap.less +0 -1
  88. package/test/less-bom/errors/color-invalid-hex-code.less +0 -4
  89. package/test/less-bom/errors/color-invalid-hex-code.txt +0 -4
  90. package/test/less-bom/errors/color-invalid-hex-code2.less +0 -4
  91. package/test/less-bom/errors/color-invalid-hex-code2.txt +0 -4
package/dist/less.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Less - Leaner CSS v3.7.0
2
+ * Less - Leaner CSS v3.9.0
3
3
  * http://lesscss.org
4
4
  *
5
5
  * Copyright (c) 2009-2018, Alexis Sellier <self@cloudhead.net>
@@ -55,6 +55,10 @@ module.exports = function(window, options) {
55
55
  if (options.onReady === undefined) {
56
56
  options.onReady = true;
57
57
  }
58
+
59
+ if (options.relativeUrls) {
60
+ options.rewriteUrls = 'all';
61
+ }
58
62
  };
59
63
 
60
64
  },{"./browser":3,"./utils":11}],2:[function(require,module,exports){
@@ -126,7 +130,7 @@ if (options.onReady) {
126
130
  less.pageLoadFinished = less.refresh(less.env === 'development').then(resolveOrReject, resolveOrReject);
127
131
  }
128
132
 
129
- },{"../less/default-options":16,"./add-default-options":1,"./index":8,"promise/polyfill":103}],3:[function(require,module,exports){
133
+ },{"../less/default-options":17,"./add-default-options":1,"./index":8,"promise/polyfill":104}],3:[function(require,module,exports){
130
134
  var utils = require('./utils');
131
135
  module.exports = {
132
136
  createCSS: function (document, styles, sheet) {
@@ -522,7 +526,7 @@ module.exports = function(options, logger) {
522
526
  return FileManager;
523
527
  };
524
528
 
525
- },{"../less/environment/abstract-file-manager.js":17}],7:[function(require,module,exports){
529
+ },{"../less/environment/abstract-file-manager.js":18}],7:[function(require,module,exports){
526
530
  module.exports = function() {
527
531
 
528
532
  var functionRegistry = require('./../less/functions/function-registry');
@@ -552,7 +556,7 @@ module.exports = function() {
552
556
  functionRegistry.addMultiple(imageFunctions);
553
557
  };
554
558
 
555
- },{"./../less/functions/function-registry":26}],8:[function(require,module,exports){
559
+ },{"./../less/functions/function-registry":27}],8:[function(require,module,exports){
556
560
  //
557
561
  // index.js
558
562
  // Should expose the additional browser functions on to the less object
@@ -585,7 +589,13 @@ module.exports = function(window, options) {
585
589
  var typePattern = /^text\/(x-)?less$/;
586
590
 
587
591
  function clone(obj) {
588
- return JSON.parse(JSON.stringify(obj || {}));
592
+ var cloned = {};
593
+ for (var prop in obj) {
594
+ if (obj.hasOwnProperty(prop)) {
595
+ cloned[prop] = obj[prop];
596
+ }
597
+ }
598
+ return cloned;
589
599
  }
590
600
 
591
601
  // only really needed for phantom
@@ -648,7 +658,8 @@ module.exports = function(window, options) {
648
658
  currentDirectory: fileManager.getPath(path),
649
659
  filename: path,
650
660
  rootFilename: path,
651
- relativeUrls: instanceOptions.relativeUrls};
661
+ rewriteUrls: instanceOptions.rewriteUrls
662
+ };
652
663
 
653
664
  newFileInfo.entryPath = newFileInfo.currentDirectory;
654
665
  newFileInfo.rootpath = instanceOptions.rootpath || newFileInfo.currentDirectory;
@@ -827,7 +838,7 @@ module.exports = function(window, options) {
827
838
  return less;
828
839
  };
829
840
 
830
- },{"../less":36,"./browser":3,"./cache":4,"./error-reporting":5,"./file-manager":6,"./image-size":7,"./log-listener":9,"./plugin-loader":10,"./utils":11}],9:[function(require,module,exports){
841
+ },{"../less":37,"./browser":3,"./cache":4,"./error-reporting":5,"./file-manager":6,"./image-size":7,"./log-listener":9,"./plugin-loader":10,"./utils":11}],9:[function(require,module,exports){
831
842
  module.exports = function(less, options) {
832
843
 
833
844
  var logLevel_debug = 4,
@@ -898,7 +909,7 @@ PluginLoader.prototype.loadPlugin = function(filename, basePath, context, enviro
898
909
  module.exports = PluginLoader;
899
910
 
900
911
 
901
- },{"../less/environment/abstract-plugin-loader.js":18}],11:[function(require,module,exports){
912
+ },{"../less/environment/abstract-plugin-loader.js":19}],11:[function(require,module,exports){
902
913
  module.exports = {
903
914
  extractId: function(href) {
904
915
  return href.replace(/^[a-z-]+:\/+?[^\/]+/, '') // Remove protocol & domain
@@ -925,9 +936,23 @@ module.exports = {
925
936
  };
926
937
 
927
938
  },{}],12:[function(require,module,exports){
939
+ module.exports = {
940
+ Math: {
941
+ ALWAYS: 0,
942
+ PARENS_DIVISION: 1,
943
+ PARENS: 2,
944
+ STRICT_LEGACY: 3
945
+ },
946
+ RewriteUrls: {
947
+ OFF: 0,
948
+ LOCAL: 1,
949
+ ALL: 2
950
+ }
951
+ };
952
+ },{}],13:[function(require,module,exports){
928
953
  var contexts = {};
929
954
  module.exports = contexts;
930
- var MATH = require('./math-constants');
955
+ var Constants = require('./constants');
931
956
 
932
957
  var copyFromOriginal = function copyFromOriginal(original, destination, propertiesToCopy) {
933
958
  if (!original) { return; }
@@ -945,7 +970,7 @@ var copyFromOriginal = function copyFromOriginal(original, destination, properti
945
970
  var parseCopyProperties = [
946
971
  // options
947
972
  'paths', // option - unmodified - paths to search for imports on
948
- 'relativeUrls', // option - whether to adjust URL's to be relative
973
+ 'rewriteUrls', // option - whether to adjust URL's to be relative
949
974
  'rootpath', // option - rootpath to append to URL's
950
975
  'strictImports', // option -
951
976
  'insecure', // option - whether to allow imports from insecure ssl hosts
@@ -978,7 +1003,8 @@ var evalCopyProperties = [
978
1003
  'urlArgs', // whether to add args into url tokens
979
1004
  'javascriptEnabled', // option - whether Inline JavaScript is enabled. if undefined, defaults to false
980
1005
  'pluginManager', // Used as the plugin manager for the session
981
- 'importantScope' // used to bubble up !important statements
1006
+ 'importantScope', // used to bubble up !important statements
1007
+ 'rewriteUrls' // option - whether to adjust URL's to be relative
982
1008
  ];
983
1009
 
984
1010
  contexts.Eval = function(options, frames) {
@@ -1022,26 +1048,45 @@ contexts.Eval.prototype.isMathOn = function (op) {
1022
1048
  if (!this.mathOn) {
1023
1049
  return false;
1024
1050
  }
1025
- if (op === '/' && this.math !== MATH.ALWAYS && (!this.parensStack || !this.parensStack.length)) {
1051
+ if (op === '/' && this.math !== Constants.Math.ALWAYS && (!this.parensStack || !this.parensStack.length)) {
1026
1052
  return false;
1027
1053
  }
1028
- if (this.math > MATH.PARENS_DIVISION) {
1054
+ if (this.math > Constants.Math.PARENS_DIVISION) {
1029
1055
  return this.parensStack && this.parensStack.length;
1030
1056
  }
1031
1057
  return true;
1032
1058
  };
1033
1059
 
1034
- contexts.Eval.prototype.isPathRelative = function (path) {
1035
- return !/^(?:[a-z-]+:|\/|#)/i.test(path);
1060
+ contexts.Eval.prototype.pathRequiresRewrite = function (path) {
1061
+ var isRelative = this.rewriteUrls === Constants.RewriteUrls.LOCAL ? isPathLocalRelative : isPathRelative;
1062
+
1063
+ return isRelative(path);
1064
+ };
1065
+
1066
+ contexts.Eval.prototype.rewritePath = function (path, rootpath) {
1067
+ var newPath;
1068
+
1069
+ rootpath = rootpath || '';
1070
+ newPath = this.normalizePath(rootpath + path);
1071
+
1072
+ // If a path was explicit relative and the rootpath was not an absolute path
1073
+ // we must ensure that the new path is also explicit relative.
1074
+ if (isPathLocalRelative(path) &&
1075
+ isPathRelative(rootpath) &&
1076
+ isPathLocalRelative(newPath) === false) {
1077
+ newPath = './' + newPath;
1078
+ }
1079
+
1080
+ return newPath;
1036
1081
  };
1037
1082
 
1038
- contexts.Eval.prototype.normalizePath = function( path ) {
1083
+ contexts.Eval.prototype.normalizePath = function (path) {
1039
1084
  var
1040
1085
  segments = path.split('/').reverse(),
1041
1086
  segment;
1042
1087
 
1043
1088
  path = [];
1044
- while (segments.length !== 0 ) {
1089
+ while (segments.length !== 0) {
1045
1090
  segment = segments.pop();
1046
1091
  switch ( segment ) {
1047
1092
  case '.':
@@ -1054,7 +1099,7 @@ contexts.Eval.prototype.normalizePath = function( path ) {
1054
1099
  }
1055
1100
  break;
1056
1101
  default:
1057
- path.push( segment );
1102
+ path.push(segment);
1058
1103
  break;
1059
1104
  }
1060
1105
  }
@@ -1062,9 +1107,17 @@ contexts.Eval.prototype.normalizePath = function( path ) {
1062
1107
  return path.join('/');
1063
1108
  };
1064
1109
 
1110
+ function isPathRelative(path) {
1111
+ return !/^(?:[a-z-]+:|\/|#)/i.test(path);
1112
+ }
1113
+
1114
+ function isPathLocalRelative(path) {
1115
+ return path.charAt(0) === '.';
1116
+ }
1117
+
1065
1118
  // todo - do the same for the toCSS ?
1066
1119
 
1067
- },{"./math-constants":39}],13:[function(require,module,exports){
1120
+ },{"./constants":12}],14:[function(require,module,exports){
1068
1121
  module.exports = {
1069
1122
  'aliceblue':'#f0f8ff',
1070
1123
  'antiquewhite':'#faebd7',
@@ -1215,13 +1268,13 @@ module.exports = {
1215
1268
  'yellow':'#ffff00',
1216
1269
  'yellowgreen':'#9acd32'
1217
1270
  };
1218
- },{}],14:[function(require,module,exports){
1271
+ },{}],15:[function(require,module,exports){
1219
1272
  module.exports = {
1220
1273
  colors: require('./colors'),
1221
1274
  unitConversions: require('./unit-conversions')
1222
1275
  };
1223
1276
 
1224
- },{"./colors":13,"./unit-conversions":15}],15:[function(require,module,exports){
1277
+ },{"./colors":14,"./unit-conversions":16}],16:[function(require,module,exports){
1225
1278
  module.exports = {
1226
1279
  length: {
1227
1280
  'm': 1,
@@ -1243,7 +1296,7 @@ module.exports = {
1243
1296
  'turn': 1
1244
1297
  }
1245
1298
  };
1246
- },{}],16:[function(require,module,exports){
1299
+ },{}],17:[function(require,module,exports){
1247
1300
  // Export a new default each time
1248
1301
  module.exports = function() {
1249
1302
  return {
@@ -1288,7 +1341,7 @@ module.exports = function() {
1288
1341
  * that references an image, exactly the same URL will be output in the css.
1289
1342
  * This option allows you to re-write URL's in imported files so that the
1290
1343
  * URL is always relative to the base imported file */
1291
- relativeUrls: false,
1344
+ rewriteUrls: false,
1292
1345
 
1293
1346
  /* Compatibility with IE8. Used for limiting data-uri length */
1294
1347
  ieCompat: false, // true until 3.0
@@ -1317,7 +1370,7 @@ module.exports = function() {
1317
1370
  urlArgs: ''
1318
1371
  }
1319
1372
  }
1320
- },{}],17:[function(require,module,exports){
1373
+ },{}],18:[function(require,module,exports){
1321
1374
  var abstractFileManager = function() {
1322
1375
  };
1323
1376
 
@@ -1442,7 +1495,7 @@ abstractFileManager.prototype.extractUrlParts = function extractUrlParts(url, ba
1442
1495
 
1443
1496
  module.exports = abstractFileManager;
1444
1497
 
1445
- },{}],18:[function(require,module,exports){
1498
+ },{}],19:[function(require,module,exports){
1446
1499
  var functionRegistry = require('../functions/function-registry'),
1447
1500
  LessError = require('../less-error');
1448
1501
 
@@ -1633,7 +1686,7 @@ AbstractPluginLoader.prototype.printUsage = function(plugins) {
1633
1686
  module.exports = AbstractPluginLoader;
1634
1687
 
1635
1688
 
1636
- },{"../functions/function-registry":26,"../less-error":37}],19:[function(require,module,exports){
1689
+ },{"../functions/function-registry":27,"../less-error":38}],20:[function(require,module,exports){
1637
1690
  /**
1638
1691
  * @todo Document why this abstraction exists, and the relationship between
1639
1692
  * environment, file managers, and plugin manager
@@ -1691,7 +1744,7 @@ environment.prototype.clearFileManagers = function () {
1691
1744
 
1692
1745
  module.exports = environment;
1693
1746
 
1694
- },{"../logger":38}],20:[function(require,module,exports){
1747
+ },{"../logger":39}],21:[function(require,module,exports){
1695
1748
 
1696
1749
  var functionRegistry = require('./function-registry'),
1697
1750
  Anonymous = require('../tree/anonymous'),
@@ -1708,7 +1761,7 @@ functionRegistry.addMultiple({
1708
1761
  }
1709
1762
  });
1710
1763
 
1711
- },{"../tree/anonymous":50,"../tree/keyword":70,"./function-registry":26}],21:[function(require,module,exports){
1764
+ },{"../tree/anonymous":50,"../tree/keyword":70,"./function-registry":27}],22:[function(require,module,exports){
1712
1765
  var Color = require('../tree/color'),
1713
1766
  functionRegistry = require('./function-registry');
1714
1767
 
@@ -1784,7 +1837,7 @@ for (var f in colorBlendModeFunctions) {
1784
1837
 
1785
1838
  functionRegistry.addMultiple(colorBlend);
1786
1839
 
1787
- },{"../tree/color":55,"./function-registry":26}],22:[function(require,module,exports){
1840
+ },{"../tree/color":55,"./function-registry":27}],23:[function(require,module,exports){
1788
1841
  var Dimension = require('../tree/dimension'),
1789
1842
  Color = require('../tree/color'),
1790
1843
  Quoted = require('../tree/quoted'),
@@ -1795,8 +1848,17 @@ var Dimension = require('../tree/dimension'),
1795
1848
  function clamp(val) {
1796
1849
  return Math.min(1, Math.max(0, val));
1797
1850
  }
1798
- function hsla(color) {
1799
- return colorFunctions.hsla(color.h, color.s, color.l, color.a);
1851
+ function hsla(origColor, hsl) {
1852
+ var color = colorFunctions.hsla(hsl.h, hsl.s, hsl.l, hsl.a);
1853
+ if (color) {
1854
+ if (origColor.value &&
1855
+ /^(rgb|hsl)/.test(origColor.value)) {
1856
+ color.value = origColor.value;
1857
+ } else {
1858
+ color.value = 'rgb';
1859
+ }
1860
+ return color;
1861
+ }
1800
1862
  }
1801
1863
  function number(n) {
1802
1864
  if (n instanceof Dimension) {
@@ -1819,46 +1881,79 @@ function scaled(n, size) {
1819
1881
  }
1820
1882
  colorFunctions = {
1821
1883
  rgb: function (r, g, b) {
1822
- return colorFunctions.rgba(r, g, b, 1.0);
1884
+ var color = colorFunctions.rgba(r, g, b, 1.0);
1885
+ if (color) {
1886
+ color.value = 'rgb';
1887
+ return color;
1888
+ }
1823
1889
  },
1824
1890
  rgba: function (r, g, b, a) {
1825
- var rgb = [r, g, b].map(function (c) { return scaled(c, 255); });
1826
- a = number(a);
1827
- return new Color(rgb, a);
1891
+ try {
1892
+ if (r instanceof Color) {
1893
+ if (g) {
1894
+ a = number(g);
1895
+ } else {
1896
+ a = r.alpha;
1897
+ }
1898
+ return new Color(r.rgb, a, 'rgba');
1899
+ }
1900
+ var rgb = [r, g, b].map(function (c) { return scaled(c, 255); });
1901
+ a = number(a);
1902
+ return new Color(rgb, a, 'rgba');
1903
+ }
1904
+ catch (e) {}
1828
1905
  },
1829
1906
  hsl: function (h, s, l) {
1830
- return colorFunctions.hsla(h, s, l, 1.0);
1907
+ var color = colorFunctions.hsla(h, s, l, 1.0);
1908
+ if (color) {
1909
+ color.value = 'hsl';
1910
+ return color;
1911
+ }
1831
1912
  },
1832
1913
  hsla: function (h, s, l, a) {
1914
+ try {
1915
+ if (h instanceof Color) {
1916
+ if (s) {
1917
+ a = number(s);
1918
+ } else {
1919
+ a = h.alpha;
1920
+ }
1921
+ return new Color(h.rgb, a, 'hsla');
1922
+ }
1833
1923
 
1834
- var m1, m2;
1924
+ var m1, m2;
1835
1925
 
1836
- function hue(h) {
1837
- h = h < 0 ? h + 1 : (h > 1 ? h - 1 : h);
1838
- if (h * 6 < 1) {
1839
- return m1 + (m2 - m1) * h * 6;
1840
- }
1841
- else if (h * 2 < 1) {
1842
- return m2;
1843
- }
1844
- else if (h * 3 < 2) {
1845
- return m1 + (m2 - m1) * (2 / 3 - h) * 6;
1846
- }
1847
- else {
1848
- return m1;
1926
+ function hue(h) {
1927
+ h = h < 0 ? h + 1 : (h > 1 ? h - 1 : h);
1928
+ if (h * 6 < 1) {
1929
+ return m1 + (m2 - m1) * h * 6;
1930
+ }
1931
+ else if (h * 2 < 1) {
1932
+ return m2;
1933
+ }
1934
+ else if (h * 3 < 2) {
1935
+ return m1 + (m2 - m1) * (2 / 3 - h) * 6;
1936
+ }
1937
+ else {
1938
+ return m1;
1939
+ }
1849
1940
  }
1850
- }
1851
1941
 
1852
- h = (number(h) % 360) / 360;
1853
- s = clamp(number(s)); l = clamp(number(l)); a = clamp(number(a));
1942
+ h = (number(h) % 360) / 360;
1943
+ s = clamp(number(s)); l = clamp(number(l)); a = clamp(number(a));
1854
1944
 
1855
- m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;
1856
- m1 = l * 2 - m2;
1945
+ m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;
1946
+ m1 = l * 2 - m2;
1857
1947
 
1858
- return colorFunctions.rgba(hue(h + 1 / 3) * 255,
1859
- hue(h) * 255,
1860
- hue(h - 1 / 3) * 255,
1861
- a);
1948
+ var rgb = [
1949
+ hue(h + 1 / 3) * 255,
1950
+ hue(h) * 255,
1951
+ hue(h - 1 / 3) * 255
1952
+ ];
1953
+ a = number(a);
1954
+ return new Color(rgb, a, 'hsla');
1955
+ }
1956
+ catch (e) {}
1862
1957
  },
1863
1958
 
1864
1959
  hsv: function(h, s, v) {
@@ -1946,7 +2041,7 @@ colorFunctions = {
1946
2041
  hsl.s += amount.value / 100;
1947
2042
  }
1948
2043
  hsl.s = clamp(hsl.s);
1949
- return hsla(hsl);
2044
+ return hsla(color, hsl);
1950
2045
  },
1951
2046
  desaturate: function (color, amount, method) {
1952
2047
  var hsl = color.toHSL();
@@ -1958,7 +2053,7 @@ colorFunctions = {
1958
2053
  hsl.s -= amount.value / 100;
1959
2054
  }
1960
2055
  hsl.s = clamp(hsl.s);
1961
- return hsla(hsl);
2056
+ return hsla(color, hsl);
1962
2057
  },
1963
2058
  lighten: function (color, amount, method) {
1964
2059
  var hsl = color.toHSL();
@@ -1970,7 +2065,7 @@ colorFunctions = {
1970
2065
  hsl.l += amount.value / 100;
1971
2066
  }
1972
2067
  hsl.l = clamp(hsl.l);
1973
- return hsla(hsl);
2068
+ return hsla(color, hsl);
1974
2069
  },
1975
2070
  darken: function (color, amount, method) {
1976
2071
  var hsl = color.toHSL();
@@ -1982,7 +2077,7 @@ colorFunctions = {
1982
2077
  hsl.l -= amount.value / 100;
1983
2078
  }
1984
2079
  hsl.l = clamp(hsl.l);
1985
- return hsla(hsl);
2080
+ return hsla(color, hsl);
1986
2081
  },
1987
2082
  fadein: function (color, amount, method) {
1988
2083
  var hsl = color.toHSL();
@@ -1994,7 +2089,7 @@ colorFunctions = {
1994
2089
  hsl.a += amount.value / 100;
1995
2090
  }
1996
2091
  hsl.a = clamp(hsl.a);
1997
- return hsla(hsl);
2092
+ return hsla(color, hsl);
1998
2093
  },
1999
2094
  fadeout: function (color, amount, method) {
2000
2095
  var hsl = color.toHSL();
@@ -2006,14 +2101,14 @@ colorFunctions = {
2006
2101
  hsl.a -= amount.value / 100;
2007
2102
  }
2008
2103
  hsl.a = clamp(hsl.a);
2009
- return hsla(hsl);
2104
+ return hsla(color, hsl);
2010
2105
  },
2011
2106
  fade: function (color, amount) {
2012
2107
  var hsl = color.toHSL();
2013
2108
 
2014
2109
  hsl.a = amount.value / 100;
2015
2110
  hsl.a = clamp(hsl.a);
2016
- return hsla(hsl);
2111
+ return hsla(color, hsl);
2017
2112
  },
2018
2113
  spin: function (color, amount) {
2019
2114
  var hsl = color.toHSL();
@@ -2021,7 +2116,7 @@ colorFunctions = {
2021
2116
 
2022
2117
  hsl.h = hue < 0 ? 360 + hue : hue;
2023
2118
 
2024
- return hsla(hsl);
2119
+ return hsla(color, hsl);
2025
2120
  },
2026
2121
  //
2027
2122
  // Copyright (c) 2006-2009 Hampton Catlin, Natalie Weizenbaum, and Chris Eppstein
@@ -2125,8 +2220,9 @@ colorFunctions = {
2125
2220
  },
2126
2221
  color: function(c) {
2127
2222
  if ((c instanceof Quoted) &&
2128
- (/^#([a-f0-9]{6}|[a-f0-9]{3})$/i.test(c.value))) {
2129
- return new Color(c.value.slice(1));
2223
+ (/^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3,4})$/i.test(c.value))) {
2224
+ var val = c.value.slice(1);
2225
+ return new Color(val, undefined, '#' + val);
2130
2226
  }
2131
2227
  if ((c instanceof Color) || (c = Color.fromKeyword(c.value))) {
2132
2228
  c.value = undefined;
@@ -2134,7 +2230,7 @@ colorFunctions = {
2134
2230
  }
2135
2231
  throw {
2136
2232
  type: 'Argument',
2137
- message: 'argument must be a color keyword or 3/6 digit hex e.g. #FFF'
2233
+ message: 'argument must be a color keyword or 3|4|6|8 digit hex e.g. #FFF'
2138
2234
  };
2139
2235
  },
2140
2236
  tint: function(color, amount) {
@@ -2146,7 +2242,7 @@ colorFunctions = {
2146
2242
  };
2147
2243
  functionRegistry.addMultiple(colorFunctions);
2148
2244
 
2149
- },{"../tree/anonymous":50,"../tree/color":55,"../tree/dimension":62,"../tree/quoted":80,"./function-registry":26}],23:[function(require,module,exports){
2245
+ },{"../tree/anonymous":50,"../tree/color":55,"../tree/dimension":62,"../tree/quoted":80,"./function-registry":27}],24:[function(require,module,exports){
2150
2246
  module.exports = function(environment) {
2151
2247
  var Quoted = require('../tree/quoted'),
2152
2248
  URL = require('../tree/url'),
@@ -2167,7 +2263,7 @@ module.exports = function(environment) {
2167
2263
  var mimetype = mimetypeNode && mimetypeNode.value;
2168
2264
  var filePath = filePathNode.value;
2169
2265
  var currentFileInfo = this.currentFileInfo;
2170
- var currentDirectory = currentFileInfo.relativeUrls ?
2266
+ var currentDirectory = currentFileInfo.rewriteUrls ?
2171
2267
  currentFileInfo.currentDirectory : currentFileInfo.entryPath;
2172
2268
 
2173
2269
  var fragmentStart = filePath.indexOf('#');
@@ -2236,7 +2332,7 @@ module.exports = function(environment) {
2236
2332
  });
2237
2333
  };
2238
2334
 
2239
- },{"../logger":38,"../tree/quoted":80,"../tree/url":85,"../utils":89,"./function-registry":26}],24:[function(require,module,exports){
2335
+ },{"../logger":39,"../tree/quoted":80,"../tree/url":85,"../utils":89,"./function-registry":27}],25:[function(require,module,exports){
2240
2336
  var Keyword = require('../tree/keyword'),
2241
2337
  functionRegistry = require('./function-registry');
2242
2338
 
@@ -2265,7 +2361,7 @@ functionRegistry.add('default', defaultFunc.eval.bind(defaultFunc));
2265
2361
 
2266
2362
  module.exports = defaultFunc;
2267
2363
 
2268
- },{"../tree/keyword":70,"./function-registry":26}],25:[function(require,module,exports){
2364
+ },{"../tree/keyword":70,"./function-registry":27}],26:[function(require,module,exports){
2269
2365
  var Expression = require('../tree/expression');
2270
2366
 
2271
2367
  var functionCaller = function(name, context, index, currentFileInfo) {
@@ -2313,7 +2409,7 @@ functionCaller.prototype.call = function(args) {
2313
2409
 
2314
2410
  module.exports = functionCaller;
2315
2411
 
2316
- },{"../tree/expression":64}],26:[function(require,module,exports){
2412
+ },{"../tree/expression":64}],27:[function(require,module,exports){
2317
2413
  function makeRegistry( base ) {
2318
2414
  return {
2319
2415
  _data: {},
@@ -2349,7 +2445,7 @@ function makeRegistry( base ) {
2349
2445
  }
2350
2446
 
2351
2447
  module.exports = makeRegistry( null );
2352
- },{}],27:[function(require,module,exports){
2448
+ },{}],28:[function(require,module,exports){
2353
2449
  module.exports = function(environment) {
2354
2450
  var functions = {
2355
2451
  functionRegistry: require('./function-registry'),
@@ -2372,9 +2468,11 @@ module.exports = function(environment) {
2372
2468
  return functions;
2373
2469
  };
2374
2470
 
2375
- },{"./boolean":20,"./color":22,"./color-blending":21,"./data-uri":23,"./default":24,"./function-caller":25,"./function-registry":26,"./list":28,"./math":30,"./number":31,"./string":32,"./svg":33,"./types":34}],28:[function(require,module,exports){
2376
- var Dimension = require('../tree/dimension'),
2471
+ },{"./boolean":21,"./color":23,"./color-blending":22,"./data-uri":24,"./default":25,"./function-caller":26,"./function-registry":27,"./list":29,"./math":31,"./number":32,"./string":33,"./svg":34,"./types":35}],29:[function(require,module,exports){
2472
+ var Comment = require('../tree/comment'),
2473
+ Dimension = require('../tree/dimension'),
2377
2474
  Declaration = require('../tree/declaration'),
2475
+ Expression = require('../tree/expression'),
2378
2476
  Ruleset = require('../tree/ruleset'),
2379
2477
  Selector = require('../tree/selector'),
2380
2478
  Element = require('../tree/element'),
@@ -2401,8 +2499,36 @@ functionRegistry.addMultiple({
2401
2499
  length: function(values) {
2402
2500
  return new Dimension(getItemsFromNode(values).length);
2403
2501
  },
2502
+ /**
2503
+ * Creates a Less list of incremental values.
2504
+ * Modeled after Lodash's range function, also exists natively in PHP
2505
+ *
2506
+ * @param {Dimension} [start=1]
2507
+ * @param {Dimension} end - e.g. 10 or 10px - unit is added to output
2508
+ * @param {Dimension} [step=1]
2509
+ */
2510
+ range: function(start, end, step) {
2511
+ var from, to, stepValue = 1, list = [];
2512
+ if (end) {
2513
+ to = end;
2514
+ from = start.value;
2515
+ if (step) {
2516
+ stepValue = step.value;
2517
+ }
2518
+ }
2519
+ else {
2520
+ from = 1;
2521
+ to = start;
2522
+ }
2523
+
2524
+ for (var i = from; i <= to.value; i += stepValue) {
2525
+ list.push(new Dimension(i, to.unit));
2526
+ }
2527
+
2528
+ return new Expression(list);
2529
+ },
2404
2530
  each: function(list, rs) {
2405
- var i = 0, rules = [], newRules, iterator;
2531
+ var rules = [], newRules, iterator;
2406
2532
 
2407
2533
  if (list.value) {
2408
2534
  if (Array.isArray(list.value)) {
@@ -2412,6 +2538,8 @@ functionRegistry.addMultiple({
2412
2538
  }
2413
2539
  } else if (list.ruleset) {
2414
2540
  iterator = list.ruleset.rules;
2541
+ } else if (list.rules) {
2542
+ iterator = list.rules;
2415
2543
  } else if (Array.isArray(list)) {
2416
2544
  iterator = list;
2417
2545
  } else {
@@ -2430,17 +2558,20 @@ functionRegistry.addMultiple({
2430
2558
  } else {
2431
2559
  rs = rs.ruleset;
2432
2560
  }
2433
-
2434
- iterator.forEach(function(item) {
2435
- i = i + 1;
2436
- var key, value;
2561
+
2562
+ for (var i = 0; i < iterator.length; i++) {
2563
+ var key, value, item = iterator[i];
2437
2564
  if (item instanceof Declaration) {
2438
2565
  key = typeof item.name === 'string' ? item.name : item.name[0].value;
2439
2566
  value = item.value;
2440
2567
  } else {
2441
- key = new Dimension(i);
2568
+ key = new Dimension(i + 1);
2442
2569
  value = item;
2443
2570
  }
2571
+
2572
+ if (item instanceof Comment) {
2573
+ continue;
2574
+ }
2444
2575
 
2445
2576
  newRules = rs.rules.slice(0);
2446
2577
  if (valueName) {
@@ -2450,7 +2581,7 @@ functionRegistry.addMultiple({
2450
2581
  }
2451
2582
  if (indexName) {
2452
2583
  newRules.push(new Declaration(indexName,
2453
- new Dimension(i),
2584
+ new Dimension(i + 1),
2454
2585
  false, false, this.index, this.currentFileInfo));
2455
2586
  }
2456
2587
  if (keyName) {
@@ -2464,7 +2595,7 @@ functionRegistry.addMultiple({
2464
2595
  rs.strictImports,
2465
2596
  rs.visibilityInfo()
2466
2597
  ));
2467
- });
2598
+ }
2468
2599
 
2469
2600
  return new Ruleset([ new(Selector)([ new Element("", '&') ]) ],
2470
2601
  rules,
@@ -2475,7 +2606,7 @@ functionRegistry.addMultiple({
2475
2606
  }
2476
2607
  });
2477
2608
 
2478
- },{"../tree/declaration":60,"../tree/dimension":62,"../tree/element":63,"../tree/ruleset":81,"../tree/selector":82,"./function-registry":26}],29:[function(require,module,exports){
2609
+ },{"../tree/comment":57,"../tree/declaration":60,"../tree/dimension":62,"../tree/element":63,"../tree/expression":64,"../tree/ruleset":81,"../tree/selector":82,"./function-registry":27}],30:[function(require,module,exports){
2479
2610
  var Dimension = require('../tree/dimension');
2480
2611
 
2481
2612
  var MathHelper = function() {
@@ -2492,7 +2623,7 @@ MathHelper._math = function (fn, unit, n) {
2492
2623
  return new Dimension(fn(parseFloat(n.value)), unit);
2493
2624
  };
2494
2625
  module.exports = MathHelper;
2495
- },{"../tree/dimension":62}],30:[function(require,module,exports){
2626
+ },{"../tree/dimension":62}],31:[function(require,module,exports){
2496
2627
  var functionRegistry = require('./function-registry'),
2497
2628
  mathHelper = require('./math-helper.js');
2498
2629
 
@@ -2523,7 +2654,7 @@ mathFunctions.round = function (n, f) {
2523
2654
 
2524
2655
  functionRegistry.addMultiple(mathFunctions);
2525
2656
 
2526
- },{"./function-registry":26,"./math-helper.js":29}],31:[function(require,module,exports){
2657
+ },{"./function-registry":27,"./math-helper.js":30}],32:[function(require,module,exports){
2527
2658
  var Dimension = require('../tree/dimension'),
2528
2659
  Anonymous = require('../tree/anonymous'),
2529
2660
  functionRegistry = require('./function-registry'),
@@ -2606,7 +2737,7 @@ functionRegistry.addMultiple({
2606
2737
  }
2607
2738
  });
2608
2739
 
2609
- },{"../tree/anonymous":50,"../tree/dimension":62,"./function-registry":26,"./math-helper.js":29}],32:[function(require,module,exports){
2740
+ },{"../tree/anonymous":50,"../tree/dimension":62,"./function-registry":27,"./math-helper.js":30}],33:[function(require,module,exports){
2610
2741
  var Quoted = require('../tree/quoted'),
2611
2742
  Anonymous = require('../tree/anonymous'),
2612
2743
  JavaScript = require('../tree/javascript'),
@@ -2645,7 +2776,7 @@ functionRegistry.addMultiple({
2645
2776
  }
2646
2777
  });
2647
2778
 
2648
- },{"../tree/anonymous":50,"../tree/javascript":68,"../tree/quoted":80,"./function-registry":26}],33:[function(require,module,exports){
2779
+ },{"../tree/anonymous":50,"../tree/javascript":68,"../tree/quoted":80,"./function-registry":27}],34:[function(require,module,exports){
2649
2780
  module.exports = function(environment) {
2650
2781
  var Dimension = require('../tree/dimension'),
2651
2782
  Color = require('../tree/color'),
@@ -2734,7 +2865,7 @@ module.exports = function(environment) {
2734
2865
  });
2735
2866
  };
2736
2867
 
2737
- },{"../tree/color":55,"../tree/dimension":62,"../tree/expression":64,"../tree/quoted":80,"../tree/url":85,"./function-registry":26}],34:[function(require,module,exports){
2868
+ },{"../tree/color":55,"../tree/dimension":62,"../tree/expression":64,"../tree/quoted":80,"../tree/url":85,"./function-registry":27}],35:[function(require,module,exports){
2738
2869
  var Keyword = require('../tree/keyword'),
2739
2870
  DetachedRuleset = require('../tree/detached-ruleset'),
2740
2871
  Dimension = require('../tree/dimension'),
@@ -2810,7 +2941,7 @@ functionRegistry.addMultiple({
2810
2941
  }
2811
2942
  });
2812
2943
 
2813
- },{"../tree/anonymous":50,"../tree/color":55,"../tree/detached-ruleset":61,"../tree/dimension":62,"../tree/keyword":70,"../tree/operation":77,"../tree/quoted":80,"../tree/url":85,"./function-registry":26}],35:[function(require,module,exports){
2944
+ },{"../tree/anonymous":50,"../tree/color":55,"../tree/detached-ruleset":61,"../tree/dimension":62,"../tree/keyword":70,"../tree/operation":77,"../tree/quoted":80,"../tree/url":85,"./function-registry":27}],36:[function(require,module,exports){
2814
2945
  var contexts = require('./contexts'),
2815
2946
  Parser = require('./parser/parser'),
2816
2947
  LessError = require('./less-error'),
@@ -2821,7 +2952,7 @@ var contexts = require('./contexts'),
2821
2952
  module.exports = function(environment) {
2822
2953
 
2823
2954
  // FileInfo = {
2824
- // 'relativeUrls' - option - whether to adjust URL's to be relative
2955
+ // 'rewriteUrls' - option - whether to adjust URL's to be relative
2825
2956
  // 'filename' - full resolved filename of current file
2826
2957
  // 'rootpath' - path to append to normal URLs for this node
2827
2958
  // 'currentDirectory' - path to the current file, absolute
@@ -2878,7 +3009,7 @@ module.exports = function(environment) {
2878
3009
  };
2879
3010
 
2880
3011
  var newFileInfo = {
2881
- relativeUrls: this.context.relativeUrls,
3012
+ rewriteUrls: this.context.rewriteUrls,
2882
3013
  entryPath: currentFileInfo.entryPath,
2883
3014
  rootpath: currentFileInfo.rootpath,
2884
3015
  rootFilename: currentFileInfo.rootFilename
@@ -2905,7 +3036,7 @@ module.exports = function(environment) {
2905
3036
  // - If path of imported file is '../mixins.less' and rootpath is 'less/',
2906
3037
  // then rootpath should become 'less/../'
2907
3038
  newFileInfo.currentDirectory = fileManager.getPath(resolvedFilename);
2908
- if (newFileInfo.relativeUrls) {
3039
+ if (newFileInfo.rewriteUrls) {
2909
3040
  newFileInfo.rootpath = fileManager.join(
2910
3041
  (importManager.context.rootpath || ''),
2911
3042
  fileManager.pathDiff(newFileInfo.currentDirectory, newFileInfo.entryPath));
@@ -2979,12 +3110,12 @@ module.exports = function(environment) {
2979
3110
  return ImportManager;
2980
3111
  };
2981
3112
 
2982
- },{"./contexts":12,"./less-error":37,"./logger":38,"./parser/parser":44,"./utils":89,"promise":undefined}],36:[function(require,module,exports){
3113
+ },{"./contexts":13,"./less-error":38,"./logger":39,"./parser/parser":44,"./utils":89,"promise":undefined}],37:[function(require,module,exports){
2983
3114
  module.exports = function(environment, fileManagers) {
2984
3115
  var SourceMapOutput, SourceMapBuilder, ParseTree, ImportManager, Environment;
2985
3116
 
2986
3117
  var initial = {
2987
- version: [3, 7, 0],
3118
+ version: [3, 9, 0],
2988
3119
  data: require('./data'),
2989
3120
  tree: require('./tree'),
2990
3121
  Environment: (Environment = require('./environment/environment')),
@@ -3036,7 +3167,7 @@ module.exports = function(environment, fileManagers) {
3036
3167
  return api;
3037
3168
  };
3038
3169
 
3039
- },{"./contexts":12,"./data":14,"./environment/abstract-file-manager":17,"./environment/abstract-plugin-loader":18,"./environment/environment":19,"./functions":27,"./import-manager":35,"./less-error":37,"./logger":38,"./parse":41,"./parse-tree":40,"./parser/parser":44,"./plugin-manager":45,"./render":46,"./source-map-builder":47,"./source-map-output":48,"./transform-tree":49,"./tree":67,"./utils":89,"./visitors":93}],37:[function(require,module,exports){
3170
+ },{"./contexts":13,"./data":15,"./environment/abstract-file-manager":18,"./environment/abstract-plugin-loader":19,"./environment/environment":20,"./functions":28,"./import-manager":36,"./less-error":38,"./logger":39,"./parse":41,"./parse-tree":40,"./parser/parser":44,"./plugin-manager":45,"./render":46,"./source-map-builder":47,"./source-map-output":48,"./transform-tree":49,"./tree":67,"./utils":89,"./visitors":93}],38:[function(require,module,exports){
3040
3171
  var utils = require('./utils');
3041
3172
  /**
3042
3173
  * This is a centralized class of any error that could be thrown internally (mostly by the parser).
@@ -3179,7 +3310,7 @@ LessError.prototype.toString = function(options) {
3179
3310
  return message;
3180
3311
  };
3181
3312
 
3182
- },{"./utils":89}],38:[function(require,module,exports){
3313
+ },{"./utils":89}],39:[function(require,module,exports){
3183
3314
  module.exports = {
3184
3315
  error: function(msg) {
3185
3316
  this._fireEvent('error', msg);
@@ -3215,13 +3346,6 @@ module.exports = {
3215
3346
  _listeners: []
3216
3347
  };
3217
3348
 
3218
- },{}],39:[function(require,module,exports){
3219
- module.exports = {
3220
- ALWAYS: 0,
3221
- PARENS_DIVISION: 1,
3222
- PARENS: 2,
3223
- STRICT_LEGACY: 3
3224
- };
3225
3349
  },{}],40:[function(require,module,exports){
3226
3350
  var LessError = require('./less-error'),
3227
3351
  transformTree = require('./transform-tree'),
@@ -3284,7 +3408,7 @@ module.exports = function(SourceMapBuilder) {
3284
3408
  return ParseTree;
3285
3409
  };
3286
3410
 
3287
- },{"./less-error":37,"./logger":38,"./transform-tree":49}],41:[function(require,module,exports){
3411
+ },{"./less-error":38,"./logger":39,"./transform-tree":49}],41:[function(require,module,exports){
3288
3412
  var PromiseConstructor,
3289
3413
  contexts = require('./contexts'),
3290
3414
  Parser = require('./parser/parser'),
@@ -3333,7 +3457,7 @@ module.exports = function(environment, ParseTree, ImportManager) {
3333
3457
  var entryPath = filename.replace(/[^\/\\]*$/, '');
3334
3458
  rootFileInfo = {
3335
3459
  filename: filename,
3336
- relativeUrls: context.relativeUrls,
3460
+ rewriteUrls: context.rewriteUrls,
3337
3461
  rootpath: context.rootpath || '',
3338
3462
  currentDirectory: entryPath,
3339
3463
  entryPath: entryPath,
@@ -3377,7 +3501,7 @@ module.exports = function(environment, ParseTree, ImportManager) {
3377
3501
  return parse;
3378
3502
  };
3379
3503
 
3380
- },{"./contexts":12,"./less-error":37,"./parser/parser":44,"./plugin-manager":45,"./utils":89,"promise":undefined}],42:[function(require,module,exports){
3504
+ },{"./contexts":13,"./less-error":38,"./parser/parser":44,"./plugin-manager":45,"./utils":89,"promise":undefined}],42:[function(require,module,exports){
3381
3505
  // Split the input into chunks.
3382
3506
  module.exports = function (input, fail) {
3383
3507
  var len = input.length, level = 0, parenLevel = 0,
@@ -4515,15 +4639,8 @@ var Parser = function Parser(context, imports, fileInfo) {
4515
4639
  color: function () {
4516
4640
  var rgb;
4517
4641
 
4518
- if (parserInput.currentChar() === '#' && (rgb = parserInput.$re(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})/))) {
4519
- // strip colons, brackets, whitespaces and other characters that should not
4520
- // definitely be part of color string
4521
- var colorCandidateString = rgb.input.match(/^#([\w]+).*/);
4522
- colorCandidateString = colorCandidateString[1];
4523
- if (!colorCandidateString.match(/^[A-Fa-f0-9]+$/)) { // verify if candidate consists only of allowed HEX characters
4524
- error('Invalid HEX color code');
4525
- }
4526
- return new(tree.Color)(rgb[1], undefined, '#' + colorCandidateString);
4642
+ if (parserInput.currentChar() === '#' && (rgb = parserInput.$re(/^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3,4})/))) {
4643
+ return new(tree.Color)(rgb[1], undefined, rgb[0]);
4527
4644
  }
4528
4645
  },
4529
4646
 
@@ -6161,7 +6278,7 @@ Parser.serializeVars = function(vars) {
6161
6278
 
6162
6279
  module.exports = Parser;
6163
6280
 
6164
- },{"../functions/function-registry":26,"../less-error":37,"../tree":67,"../utils":89,"../visitors":93,"./parser-input":43}],45:[function(require,module,exports){
6281
+ },{"../functions/function-registry":27,"../less-error":38,"../tree":67,"../utils":89,"../visitors":93,"./parser-input":43}],45:[function(require,module,exports){
6165
6282
  /**
6166
6283
  * Plugin Manager
6167
6284
  */
@@ -6500,7 +6617,7 @@ module.exports = function (environment) {
6500
6617
  sourceColumns,
6501
6618
  i;
6502
6619
 
6503
- if (fileInfo) {
6620
+ if (fileInfo && fileInfo.filename) {
6504
6621
  var inputSource = this._contentsMap[fileInfo.filename];
6505
6622
 
6506
6623
  // remove vars/banner added to the top of the file
@@ -6519,7 +6636,7 @@ module.exports = function (environment) {
6519
6636
  lines = chunk.split('\n');
6520
6637
  columns = lines[lines.length - 1];
6521
6638
 
6522
- if (fileInfo) {
6639
+ if (fileInfo && fileInfo.filename) {
6523
6640
  if (!mapLines) {
6524
6641
  this._sourceMapGenerator.addMapping({ generated: { line: this._lineNumber + 1, column: this._column},
6525
6642
  original: { line: sourceLines.length, column: sourceColumns.length},
@@ -6679,7 +6796,7 @@ module.exports = function(root, options) {
6679
6796
  return evaldRoot;
6680
6797
  };
6681
6798
 
6682
- },{"./contexts":12,"./tree":67,"./visitors":93}],50:[function(require,module,exports){
6799
+ },{"./contexts":13,"./tree":67,"./visitors":93}],50:[function(require,module,exports){
6683
6800
  var Node = require('./node');
6684
6801
 
6685
6802
  var Anonymous = function (value, index, currentFileInfo, mapLines, rulesetLike, visibilityInfo) {
@@ -7005,7 +7122,7 @@ Call.prototype.genCSS = function (context, output) {
7005
7122
  };
7006
7123
  module.exports = Call;
7007
7124
 
7008
- },{"../functions/function-caller":25,"./anonymous":50,"./node":76}],55:[function(require,module,exports){
7125
+ },{"../functions/function-caller":26,"./anonymous":50,"./node":76}],55:[function(require,module,exports){
7009
7126
  var Node = require('./node'),
7010
7127
  colors = require('../data/colors');
7011
7128
 
@@ -7013,6 +7130,7 @@ var Node = require('./node'),
7013
7130
  // RGB Colors - #ff0014, #eee
7014
7131
  //
7015
7132
  var Color = function (rgb, a, originalForm) {
7133
+ var self = this;
7016
7134
  //
7017
7135
  // The end goal here, is to parse the arguments
7018
7136
  // into an integer triplet, such as `128, 255, 0`
@@ -7021,16 +7139,26 @@ var Color = function (rgb, a, originalForm) {
7021
7139
  //
7022
7140
  if (Array.isArray(rgb)) {
7023
7141
  this.rgb = rgb;
7024
- } else if (rgb.length == 6) {
7025
- this.rgb = rgb.match(/.{2}/g).map(function (c) {
7026
- return parseInt(c, 16);
7142
+ } else if (rgb.length >= 6) {
7143
+ this.rgb = [];
7144
+ rgb.match(/.{2}/g).map(function (c, i) {
7145
+ if (i < 3) {
7146
+ self.rgb.push(parseInt(c, 16));
7147
+ } else {
7148
+ self.alpha = (parseInt(c, 16)) / 255;
7149
+ }
7027
7150
  });
7028
7151
  } else {
7029
- this.rgb = rgb.split('').map(function (c) {
7030
- return parseInt(c + c, 16);
7152
+ this.rgb = [];
7153
+ rgb.split('').map(function (c, i) {
7154
+ if (i < 3) {
7155
+ self.rgb.push(parseInt(c + c, 16));
7156
+ } else {
7157
+ self.alpha = (parseInt(c + c, 16)) / 255;
7158
+ }
7031
7159
  });
7032
7160
  }
7033
- this.alpha = typeof a === 'number' ? a : 1;
7161
+ this.alpha = this.alpha || (typeof a === 'number' ? a : 1);
7034
7162
  if (typeof originalForm !== 'undefined') {
7035
7163
  this.value = originalForm;
7036
7164
  }
@@ -7065,25 +7193,54 @@ Color.prototype.genCSS = function (context, output) {
7065
7193
  output.add(this.toCSS(context));
7066
7194
  };
7067
7195
  Color.prototype.toCSS = function (context, doNotCompress) {
7068
- var compress = context && context.compress && !doNotCompress, color, alpha;
7196
+ var compress = context && context.compress && !doNotCompress, color, alpha,
7197
+ colorFunction, args = [];
7069
7198
 
7070
7199
  // `value` is set if this color was originally
7071
7200
  // converted from a named color string so we need
7072
7201
  // to respect this and try to output named color too.
7202
+ alpha = this.fround(context, this.alpha);
7203
+
7073
7204
  if (this.value) {
7074
- return this.value;
7205
+ if (this.value.indexOf('rgb') === 0) {
7206
+ if (alpha < 1) {
7207
+ colorFunction = 'rgba';
7208
+ }
7209
+ } else if (this.value.indexOf('hsl') === 0) {
7210
+ if (alpha < 1) {
7211
+ colorFunction = 'hsla';
7212
+ } else {
7213
+ colorFunction = 'hsl';
7214
+ }
7215
+ } else {
7216
+ return this.value;
7217
+ }
7218
+ } else {
7219
+ if (alpha < 1) {
7220
+ colorFunction = 'rgba';
7221
+ }
7075
7222
  }
7076
7223
 
7077
- // If we have some transparency, the only way to represent it
7078
- // is via `rgba`. Otherwise, we use the hex representation,
7079
- // which has better compatibility with older browsers.
7080
- // Values are capped between `0` and `255`, rounded and zero-padded.
7081
- alpha = this.fround(context, this.alpha);
7082
- if (alpha < 1) {
7083
- return 'rgba(' + this.rgb.map(function (c) {
7084
- return clamp(Math.round(c), 255);
7085
- }).concat(clamp(alpha, 1))
7086
- .join(',' + (compress ? '' : ' ')) + ')';
7224
+ switch (colorFunction) {
7225
+ case 'rgba':
7226
+ args = this.rgb.map(function (c) {
7227
+ return clamp(Math.round(c), 255);
7228
+ }).concat(clamp(alpha, 1));
7229
+ break;
7230
+ case 'hsla':
7231
+ args.push(clamp(alpha, 1));
7232
+ case 'hsl':
7233
+ color = this.toHSL();
7234
+ args = [
7235
+ this.fround(context, color.h),
7236
+ this.fround(context, color.s * 100) + '%',
7237
+ this.fround(context, color.l * 100) + '%'
7238
+ ].concat(args);
7239
+ }
7240
+
7241
+ if (colorFunction) {
7242
+ // Values are capped between `0` and `255`, rounded and zero-padded.
7243
+ return colorFunction + '(' + args.join(',' + (compress ? '' : ' ')) + ')';
7087
7244
  }
7088
7245
 
7089
7246
  color = this.toRGB();
@@ -7196,7 +7353,7 @@ Color.fromKeyword = function(keyword) {
7196
7353
  };
7197
7354
  module.exports = Color;
7198
7355
 
7199
- },{"../data/colors":13,"./node":76}],56:[function(require,module,exports){
7356
+ },{"../data/colors":14,"./node":76}],56:[function(require,module,exports){
7200
7357
  var Node = require('./node');
7201
7358
 
7202
7359
  var Combinator = function (value) {
@@ -7330,7 +7487,7 @@ var Node = require('./node'),
7330
7487
  Value = require('./value'),
7331
7488
  Keyword = require('./keyword'),
7332
7489
  Anonymous = require('./anonymous'),
7333
- MATH = require('../math-constants');
7490
+ MATH = require('../constants').Math;
7334
7491
 
7335
7492
  var Declaration = function (name, value, important, merge, index, currentFileInfo, inline, variable) {
7336
7493
  this.name = name;
@@ -7428,7 +7585,7 @@ Declaration.prototype.makeImportant = function () {
7428
7585
  };
7429
7586
 
7430
7587
  module.exports = Declaration;
7431
- },{"../math-constants":39,"./anonymous":50,"./keyword":70,"./node":76,"./value":86}],61:[function(require,module,exports){
7588
+ },{"../constants":12,"./anonymous":50,"./keyword":70,"./node":76,"./value":86}],61:[function(require,module,exports){
7432
7589
  var Node = require('./node'),
7433
7590
  contexts = require('../contexts'),
7434
7591
  utils = require('../utils');
@@ -7453,7 +7610,7 @@ DetachedRuleset.prototype.callEval = function (context) {
7453
7610
  };
7454
7611
  module.exports = DetachedRuleset;
7455
7612
 
7456
- },{"../contexts":12,"../utils":89,"./node":76}],62:[function(require,module,exports){
7613
+ },{"../contexts":13,"../utils":89,"./node":76}],62:[function(require,module,exports){
7457
7614
  var Node = require('./node'),
7458
7615
  unitConversions = require('../data/unit-conversions'),
7459
7616
  Unit = require('./unit'),
@@ -7616,7 +7773,7 @@ Dimension.prototype.convertTo = function (conversions) {
7616
7773
  };
7617
7774
  module.exports = Dimension;
7618
7775
 
7619
- },{"../data/unit-conversions":15,"./color":55,"./node":76,"./unit":84}],63:[function(require,module,exports){
7776
+ },{"../data/unit-conversions":16,"./color":55,"./node":76,"./unit":84}],63:[function(require,module,exports){
7620
7777
  var Node = require('./node'),
7621
7778
  Paren = require('./paren'),
7622
7779
  Combinator = require('./combinator');
@@ -7687,7 +7844,7 @@ var Node = require('./node'),
7687
7844
  Paren = require('./paren'),
7688
7845
  Comment = require('./comment'),
7689
7846
  Dimension = require('./dimension'),
7690
- MATH = require('../math-constants');
7847
+ MATH = require('../constants').Math;
7691
7848
 
7692
7849
  var Expression = function (value, noSpacing) {
7693
7850
  this.value = value;
@@ -7749,7 +7906,7 @@ Expression.prototype.throwAwayComments = function () {
7749
7906
  };
7750
7907
  module.exports = Expression;
7751
7908
 
7752
- },{"../math-constants":39,"./comment":57,"./dimension":62,"./node":76,"./paren":78}],65:[function(require,module,exports){
7909
+ },{"../constants":12,"./comment":57,"./dimension":62,"./node":76,"./paren":78}],65:[function(require,module,exports){
7753
7910
  var Node = require('./node'),
7754
7911
  Selector = require('./selector');
7755
7912
 
@@ -7909,17 +8066,18 @@ Import.prototype.evalForImport = function (context) {
7909
8066
  };
7910
8067
  Import.prototype.evalPath = function (context) {
7911
8068
  var path = this.path.eval(context);
7912
- var rootpath = this._fileInfo && this._fileInfo.rootpath;
8069
+ var fileInfo = this._fileInfo;
7913
8070
 
7914
8071
  if (!(path instanceof URL)) {
7915
- if (rootpath) {
7916
- var pathValue = path.value;
7917
- // Add the base path if the import is relative
7918
- if (pathValue && context.isPathRelative(pathValue)) {
7919
- path.value = rootpath + pathValue;
7920
- }
8072
+ // Add the rootpath if the URL requires a rewrite
8073
+ var pathValue = path.value;
8074
+ if (fileInfo &&
8075
+ pathValue &&
8076
+ context.pathRequiresRewrite(pathValue)) {
8077
+ path.value = context.rewritePath(pathValue, fileInfo.rootpath);
8078
+ } else {
8079
+ path.value = context.normalizePath(path.value);
7921
8080
  }
7922
- path.value = context.normalizePath(path.value);
7923
8081
  }
7924
8082
 
7925
8083
  return path;
@@ -7991,7 +8149,7 @@ Import.prototype.doEval = function (context) {
7991
8149
  };
7992
8150
  module.exports = Import;
7993
8151
 
7994
- },{"../less-error":37,"../utils":89,"./anonymous":50,"./media":71,"./node":76,"./quoted":80,"./ruleset":81,"./url":85}],67:[function(require,module,exports){
8152
+ },{"../less-error":38,"../utils":89,"./anonymous":50,"./media":71,"./node":76,"./quoted":80,"./ruleset":81,"./url":85}],67:[function(require,module,exports){
7995
8153
  var tree = Object.create(null);
7996
8154
 
7997
8155
  tree.Node = require('./node');
@@ -8476,7 +8634,7 @@ MixinCall.prototype.format = function (args) {
8476
8634
  };
8477
8635
  module.exports = MixinCall;
8478
8636
 
8479
- },{"../functions/default":24,"./mixin-definition":73,"./node":76,"./selector":82}],73:[function(require,module,exports){
8637
+ },{"../functions/default":25,"./mixin-definition":73,"./node":76,"./selector":82}],73:[function(require,module,exports){
8480
8638
  var Selector = require('./selector'),
8481
8639
  Element = require('./element'),
8482
8640
  Ruleset = require('./ruleset'),
@@ -8687,7 +8845,7 @@ Definition.prototype.matchArgs = function (args, context) {
8687
8845
  };
8688
8846
  module.exports = Definition;
8689
8847
 
8690
- },{"../contexts":12,"../utils":89,"./declaration":60,"./detached-ruleset":61,"./element":63,"./expression":64,"./ruleset":81,"./selector":82}],74:[function(require,module,exports){
8848
+ },{"../contexts":13,"../utils":89,"./declaration":60,"./detached-ruleset":61,"./element":63,"./expression":64,"./ruleset":81,"./selector":82}],74:[function(require,module,exports){
8691
8849
  var Node = require('./node'),
8692
8850
  Variable = require('./variable'),
8693
8851
  Ruleset = require('./ruleset'),
@@ -8953,7 +9111,7 @@ module.exports = Node;
8953
9111
  var Node = require('./node'),
8954
9112
  Color = require('./color'),
8955
9113
  Dimension = require('./dimension'),
8956
- MATH = require('../math-constants');
9114
+ MATH = require('../constants').Math;
8957
9115
 
8958
9116
  var Operation = function (op, operands, isSpaced) {
8959
9117
  this.op = op.trim();
@@ -9005,7 +9163,7 @@ Operation.prototype.genCSS = function (context, output) {
9005
9163
 
9006
9164
  module.exports = Operation;
9007
9165
 
9008
- },{"../math-constants":39,"./color":55,"./dimension":62,"./node":76}],78:[function(require,module,exports){
9166
+ },{"../constants":12,"./color":55,"./dimension":62,"./node":76}],78:[function(require,module,exports){
9009
9167
  var Node = require('./node');
9010
9168
 
9011
9169
  var Paren = function (node) {
@@ -9965,7 +10123,7 @@ Ruleset.prototype.joinSelector = function (paths, context, selector) {
9965
10123
  };
9966
10124
  module.exports = Ruleset;
9967
10125
 
9968
- },{"../contexts":12,"../functions/default":24,"../functions/function-registry":26,"../utils":89,"./anonymous":50,"./comment":57,"./debug-info":59,"./declaration":60,"./element":63,"./keyword":70,"./node":76,"./paren":78,"./selector":82}],82:[function(require,module,exports){
10126
+ },{"../contexts":13,"../functions/default":25,"../functions/function-registry":27,"../utils":89,"./anonymous":50,"./comment":57,"./debug-info":59,"./declaration":60,"./element":63,"./keyword":70,"./node":76,"./paren":78,"./selector":82}],82:[function(require,module,exports){
9969
10127
  var Node = require('./node'),
9970
10128
  Element = require('./element'),
9971
10129
  LessError = require('../less-error');
@@ -10098,7 +10256,7 @@ Selector.prototype.getIsOutput = function() {
10098
10256
  };
10099
10257
  module.exports = Selector;
10100
10258
 
10101
- },{"../less-error":37,"./element":63,"./node":76}],83:[function(require,module,exports){
10259
+ },{"../less-error":38,"./element":63,"./node":76}],83:[function(require,module,exports){
10102
10260
  var Node = require('./node');
10103
10261
 
10104
10262
  var UnicodeDescriptor = function (value) {
@@ -10232,7 +10390,7 @@ Unit.prototype.cancel = function () {
10232
10390
  };
10233
10391
  module.exports = Unit;
10234
10392
 
10235
- },{"../data/unit-conversions":15,"../utils":89,"./node":76}],85:[function(require,module,exports){
10393
+ },{"../data/unit-conversions":16,"../utils":89,"./node":76}],85:[function(require,module,exports){
10236
10394
  var Node = require('./node');
10237
10395
 
10238
10396
  var URL = function (val, index, currentFileInfo, isEvald) {
@@ -10256,20 +10414,19 @@ URL.prototype.eval = function (context) {
10256
10414
  rootpath;
10257
10415
 
10258
10416
  if (!this.isEvald) {
10259
- // Add the base path if the URL is relative
10417
+ // Add the rootpath if the URL requires a rewrite
10260
10418
  rootpath = this.fileInfo() && this.fileInfo().rootpath;
10261
- if (rootpath &&
10419
+ if (typeof rootpath === 'string' &&
10262
10420
  typeof val.value === 'string' &&
10263
- context.isPathRelative(val.value)) {
10264
-
10421
+ context.pathRequiresRewrite(val.value)) {
10265
10422
  if (!val.quote) {
10266
- rootpath = rootpath.replace(/[\(\)'"\s]/g, function(match) { return '\\' + match; });
10423
+ rootpath = escapePath(rootpath);
10267
10424
  }
10268
- val.value = rootpath + val.value;
10425
+ val.value = context.rewritePath(val.value, rootpath);
10426
+ } else {
10427
+ val.value = context.normalizePath(val.value);
10269
10428
  }
10270
10429
 
10271
- val.value = context.normalizePath(val.value);
10272
-
10273
10430
  // Add url args if enabled
10274
10431
  if (context.urlArgs) {
10275
10432
  if (!val.value.match(/^\s*data:/)) {
@@ -10286,6 +10443,11 @@ URL.prototype.eval = function (context) {
10286
10443
 
10287
10444
  return new URL(val, this.getIndex(), this.fileInfo(), true);
10288
10445
  };
10446
+
10447
+ function escapePath(path) {
10448
+ return path.replace(/[\(\)'"\s]/g, function(match) { return '\\' + match; });
10449
+ }
10450
+
10289
10451
  module.exports = URL;
10290
10452
 
10291
10453
  },{"./node":76}],86:[function(require,module,exports){
@@ -10349,16 +10511,19 @@ VariableCall.prototype.eval = function (context) {
10349
10511
  error = new LessError({message: 'Could not evaluate variable call ' + this.variable});
10350
10512
 
10351
10513
  if (!detachedRuleset.ruleset) {
10352
- if (Array.isArray(detachedRuleset)) {
10514
+ if (detachedRuleset.rules) {
10353
10515
  rules = detachedRuleset;
10354
10516
  }
10517
+ else if (Array.isArray(detachedRuleset)) {
10518
+ rules = new Ruleset('', detachedRuleset);
10519
+ }
10355
10520
  else if (Array.isArray(detachedRuleset.value)) {
10356
- rules = detachedRuleset.value;
10521
+ rules = new Ruleset('', detachedRuleset.value);
10357
10522
  }
10358
10523
  else {
10359
10524
  throw error;
10360
10525
  }
10361
- detachedRuleset = new DetachedRuleset(new Ruleset('', rules));
10526
+ detachedRuleset = new DetachedRuleset(rules);
10362
10527
  }
10363
10528
  if (detachedRuleset.ruleset) {
10364
10529
  return detachedRuleset.callEval(context);
@@ -10367,7 +10532,7 @@ VariableCall.prototype.eval = function (context) {
10367
10532
  };
10368
10533
  module.exports = VariableCall;
10369
10534
 
10370
- },{"../less-error":37,"./detached-ruleset":61,"./node":76,"./ruleset":81,"./variable":88}],88:[function(require,module,exports){
10535
+ },{"../less-error":38,"./detached-ruleset":61,"./node":76,"./ruleset":81,"./variable":88}],88:[function(require,module,exports){
10371
10536
  var Node = require('./node'),
10372
10537
  Call = require('./call');
10373
10538
 
@@ -10431,7 +10596,8 @@ module.exports = Variable;
10431
10596
 
10432
10597
  },{"./call":54,"./node":76}],89:[function(require,module,exports){
10433
10598
  /* jshint proto: true */
10434
- var MATH = require('./math-constants');
10599
+ var Constants = require('./constants');
10600
+ var clone = require('clone');
10435
10601
 
10436
10602
  var utils = {
10437
10603
  getLocation: function(index, inputStream) {
@@ -10471,49 +10637,58 @@ var utils = {
10471
10637
  return cloned;
10472
10638
  },
10473
10639
  copyOptions: function(obj1, obj2) {
10640
+ if (obj2 && obj2._defaults) {
10641
+ return obj2;
10642
+ }
10474
10643
  var opts = utils.defaults(obj1, obj2);
10475
10644
  if (opts.strictMath) {
10476
- opts.math = MATH.STRICT_LEGACY;
10645
+ opts.math = Constants.Math.STRICT_LEGACY;
10477
10646
  }
10478
- if (opts.hasOwnProperty('math') && typeof opts.math === 'string') {
10647
+ // Back compat with changed relativeUrls option
10648
+ if (opts.relativeUrls) {
10649
+ opts.rewriteUrls = Constants.RewriteUrls.ALL;
10650
+ }
10651
+ if (typeof opts.math === 'string') {
10479
10652
  switch (opts.math.toLowerCase()) {
10480
10653
  case 'always':
10481
- opts.math = MATH.ALWAYS;
10654
+ opts.math = Constants.Math.ALWAYS;
10482
10655
  break;
10483
10656
  case 'parens-division':
10484
- opts.math = MATH.PARENS_DIVISION;
10657
+ opts.math = Constants.Math.PARENS_DIVISION;
10485
10658
  break;
10486
10659
  case 'strict':
10487
10660
  case 'parens':
10488
- opts.math = MATH.PARENS;
10661
+ opts.math = Constants.Math.PARENS;
10489
10662
  break;
10490
10663
  case 'strict-legacy':
10491
- opts.math = MATH.STRICT_LEGACY;
10664
+ opts.math = Constants.Math.STRICT_LEGACY;
10665
+ }
10666
+ }
10667
+ if (typeof opts.rewriteUrls === 'string') {
10668
+ switch (opts.rewriteUrls.toLowerCase()) {
10669
+ case 'off':
10670
+ opts.rewriteUrls = Constants.RewriteUrls.OFF;
10671
+ break;
10672
+ case 'local':
10673
+ opts.rewriteUrls = Constants.RewriteUrls.LOCAL;
10674
+ break;
10675
+ case 'all':
10676
+ opts.rewriteUrls = Constants.RewriteUrls.ALL;
10677
+ break;
10492
10678
  }
10493
10679
  }
10494
10680
  return opts;
10495
10681
  },
10496
10682
  defaults: function(obj1, obj2) {
10497
- if (!obj2._defaults || obj2._defaults !== obj1) {
10498
- for (var prop in obj1) {
10499
- if (obj1.hasOwnProperty(prop)) {
10500
- if (!obj2.hasOwnProperty(prop)) {
10501
- obj2[prop] = obj1[prop];
10502
- }
10503
- else if (Array.isArray(obj1[prop])
10504
- && Array.isArray(obj2[prop])) {
10505
-
10506
- obj1[prop].forEach(function(p) {
10507
- if (obj2[prop].indexOf(p) === -1) {
10508
- obj2[prop].push(p);
10509
- }
10510
- });
10511
- }
10512
- }
10513
- }
10683
+ var newObj = obj2 || {};
10684
+ if (!obj2._defaults) {
10685
+ newObj = {};
10686
+ var defaults = clone(obj1);
10687
+ newObj._defaults = defaults;
10688
+ var cloned = obj2 ? clone(obj2) : {};
10689
+ Object.assign(newObj, defaults, cloned);
10514
10690
  }
10515
- obj2._defaults = obj1;
10516
- return obj2;
10691
+ return newObj;
10517
10692
  },
10518
10693
  merge: function(obj1, obj2) {
10519
10694
  for (var prop in obj2) {
@@ -10540,7 +10715,7 @@ var utils = {
10540
10715
  };
10541
10716
 
10542
10717
  module.exports = utils;
10543
- },{"./math-constants":39}],90:[function(require,module,exports){
10718
+ },{"./constants":12,"clone":100}],90:[function(require,module,exports){
10544
10719
  var tree = require('../tree'),
10545
10720
  Visitor = require('./visitor'),
10546
10721
  logger = require('../logger'),
@@ -11004,7 +11179,7 @@ ProcessExtendsVisitor.prototype = {
11004
11179
 
11005
11180
  module.exports = ProcessExtendsVisitor;
11006
11181
 
11007
- },{"../logger":38,"../tree":67,"../utils":89,"./visitor":97}],91:[function(require,module,exports){
11182
+ },{"../logger":39,"../tree":67,"../utils":89,"./visitor":97}],91:[function(require,module,exports){
11008
11183
  function ImportSequencer(onSequencerEmpty) {
11009
11184
  this.imports = [];
11010
11185
  this.variableImports = [];
@@ -11252,7 +11427,7 @@ ImportVisitor.prototype = {
11252
11427
  };
11253
11428
  module.exports = ImportVisitor;
11254
11429
 
11255
- },{"../contexts":12,"../utils":89,"./import-sequencer":91,"./visitor":97}],93:[function(require,module,exports){
11430
+ },{"../contexts":13,"../utils":89,"./import-sequencer":91,"./visitor":97}],93:[function(require,module,exports){
11256
11431
  var visitors = {
11257
11432
  Visitor: require('./visitor'),
11258
11433
  ImportVisitor: require('./import-visitor'),
@@ -12170,6 +12345,265 @@ rawAsap.makeRequestCallFromTimer = makeRequestCallFromTimer;
12170
12345
 
12171
12346
  }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
12172
12347
  },{}],100:[function(require,module,exports){
12348
+ var clone = (function() {
12349
+ 'use strict';
12350
+
12351
+ function _instanceof(obj, type) {
12352
+ return type != null && obj instanceof type;
12353
+ }
12354
+
12355
+ var nativeMap;
12356
+ try {
12357
+ nativeMap = Map;
12358
+ } catch(_) {
12359
+ // maybe a reference error because no `Map`. Give it a dummy value that no
12360
+ // value will ever be an instanceof.
12361
+ nativeMap = function() {};
12362
+ }
12363
+
12364
+ var nativeSet;
12365
+ try {
12366
+ nativeSet = Set;
12367
+ } catch(_) {
12368
+ nativeSet = function() {};
12369
+ }
12370
+
12371
+ var nativePromise;
12372
+ try {
12373
+ nativePromise = Promise;
12374
+ } catch(_) {
12375
+ nativePromise = function() {};
12376
+ }
12377
+
12378
+ /**
12379
+ * Clones (copies) an Object using deep copying.
12380
+ *
12381
+ * This function supports circular references by default, but if you are certain
12382
+ * there are no circular references in your object, you can save some CPU time
12383
+ * by calling clone(obj, false).
12384
+ *
12385
+ * Caution: if `circular` is false and `parent` contains circular references,
12386
+ * your program may enter an infinite loop and crash.
12387
+ *
12388
+ * @param `parent` - the object to be cloned
12389
+ * @param `circular` - set to true if the object to be cloned may contain
12390
+ * circular references. (optional - true by default)
12391
+ * @param `depth` - set to a number if the object is only to be cloned to
12392
+ * a particular depth. (optional - defaults to Infinity)
12393
+ * @param `prototype` - sets the prototype to be used when cloning an object.
12394
+ * (optional - defaults to parent prototype).
12395
+ * @param `includeNonEnumerable` - set to true if the non-enumerable properties
12396
+ * should be cloned as well. Non-enumerable properties on the prototype
12397
+ * chain will be ignored. (optional - false by default)
12398
+ */
12399
+ function clone(parent, circular, depth, prototype, includeNonEnumerable) {
12400
+ if (typeof circular === 'object') {
12401
+ depth = circular.depth;
12402
+ prototype = circular.prototype;
12403
+ includeNonEnumerable = circular.includeNonEnumerable;
12404
+ circular = circular.circular;
12405
+ }
12406
+ // maintain two arrays for circular references, where corresponding parents
12407
+ // and children have the same index
12408
+ var allParents = [];
12409
+ var allChildren = [];
12410
+
12411
+ var useBuffer = typeof Buffer != 'undefined';
12412
+
12413
+ if (typeof circular == 'undefined')
12414
+ circular = true;
12415
+
12416
+ if (typeof depth == 'undefined')
12417
+ depth = Infinity;
12418
+
12419
+ // recurse this function so we don't reset allParents and allChildren
12420
+ function _clone(parent, depth) {
12421
+ // cloning null always returns null
12422
+ if (parent === null)
12423
+ return null;
12424
+
12425
+ if (depth === 0)
12426
+ return parent;
12427
+
12428
+ var child;
12429
+ var proto;
12430
+ if (typeof parent != 'object') {
12431
+ return parent;
12432
+ }
12433
+
12434
+ if (_instanceof(parent, nativeMap)) {
12435
+ child = new nativeMap();
12436
+ } else if (_instanceof(parent, nativeSet)) {
12437
+ child = new nativeSet();
12438
+ } else if (_instanceof(parent, nativePromise)) {
12439
+ child = new nativePromise(function (resolve, reject) {
12440
+ parent.then(function(value) {
12441
+ resolve(_clone(value, depth - 1));
12442
+ }, function(err) {
12443
+ reject(_clone(err, depth - 1));
12444
+ });
12445
+ });
12446
+ } else if (clone.__isArray(parent)) {
12447
+ child = [];
12448
+ } else if (clone.__isRegExp(parent)) {
12449
+ child = new RegExp(parent.source, __getRegExpFlags(parent));
12450
+ if (parent.lastIndex) child.lastIndex = parent.lastIndex;
12451
+ } else if (clone.__isDate(parent)) {
12452
+ child = new Date(parent.getTime());
12453
+ } else if (useBuffer && Buffer.isBuffer(parent)) {
12454
+ if (Buffer.allocUnsafe) {
12455
+ // Node.js >= 4.5.0
12456
+ child = Buffer.allocUnsafe(parent.length);
12457
+ } else {
12458
+ // Older Node.js versions
12459
+ child = new Buffer(parent.length);
12460
+ }
12461
+ parent.copy(child);
12462
+ return child;
12463
+ } else if (_instanceof(parent, Error)) {
12464
+ child = Object.create(parent);
12465
+ } else {
12466
+ if (typeof prototype == 'undefined') {
12467
+ proto = Object.getPrototypeOf(parent);
12468
+ child = Object.create(proto);
12469
+ }
12470
+ else {
12471
+ child = Object.create(prototype);
12472
+ proto = prototype;
12473
+ }
12474
+ }
12475
+
12476
+ if (circular) {
12477
+ var index = allParents.indexOf(parent);
12478
+
12479
+ if (index != -1) {
12480
+ return allChildren[index];
12481
+ }
12482
+ allParents.push(parent);
12483
+ allChildren.push(child);
12484
+ }
12485
+
12486
+ if (_instanceof(parent, nativeMap)) {
12487
+ parent.forEach(function(value, key) {
12488
+ var keyChild = _clone(key, depth - 1);
12489
+ var valueChild = _clone(value, depth - 1);
12490
+ child.set(keyChild, valueChild);
12491
+ });
12492
+ }
12493
+ if (_instanceof(parent, nativeSet)) {
12494
+ parent.forEach(function(value) {
12495
+ var entryChild = _clone(value, depth - 1);
12496
+ child.add(entryChild);
12497
+ });
12498
+ }
12499
+
12500
+ for (var i in parent) {
12501
+ var attrs;
12502
+ if (proto) {
12503
+ attrs = Object.getOwnPropertyDescriptor(proto, i);
12504
+ }
12505
+
12506
+ if (attrs && attrs.set == null) {
12507
+ continue;
12508
+ }
12509
+ child[i] = _clone(parent[i], depth - 1);
12510
+ }
12511
+
12512
+ if (Object.getOwnPropertySymbols) {
12513
+ var symbols = Object.getOwnPropertySymbols(parent);
12514
+ for (var i = 0; i < symbols.length; i++) {
12515
+ // Don't need to worry about cloning a symbol because it is a primitive,
12516
+ // like a number or string.
12517
+ var symbol = symbols[i];
12518
+ var descriptor = Object.getOwnPropertyDescriptor(parent, symbol);
12519
+ if (descriptor && !descriptor.enumerable && !includeNonEnumerable) {
12520
+ continue;
12521
+ }
12522
+ child[symbol] = _clone(parent[symbol], depth - 1);
12523
+ if (!descriptor.enumerable) {
12524
+ Object.defineProperty(child, symbol, {
12525
+ enumerable: false
12526
+ });
12527
+ }
12528
+ }
12529
+ }
12530
+
12531
+ if (includeNonEnumerable) {
12532
+ var allPropertyNames = Object.getOwnPropertyNames(parent);
12533
+ for (var i = 0; i < allPropertyNames.length; i++) {
12534
+ var propertyName = allPropertyNames[i];
12535
+ var descriptor = Object.getOwnPropertyDescriptor(parent, propertyName);
12536
+ if (descriptor && descriptor.enumerable) {
12537
+ continue;
12538
+ }
12539
+ child[propertyName] = _clone(parent[propertyName], depth - 1);
12540
+ Object.defineProperty(child, propertyName, {
12541
+ enumerable: false
12542
+ });
12543
+ }
12544
+ }
12545
+
12546
+ return child;
12547
+ }
12548
+
12549
+ return _clone(parent, depth);
12550
+ }
12551
+
12552
+ /**
12553
+ * Simple flat clone using prototype, accepts only objects, usefull for property
12554
+ * override on FLAT configuration object (no nested props).
12555
+ *
12556
+ * USE WITH CAUTION! This may not behave as you wish if you do not know how this
12557
+ * works.
12558
+ */
12559
+ clone.clonePrototype = function clonePrototype(parent) {
12560
+ if (parent === null)
12561
+ return null;
12562
+
12563
+ var c = function () {};
12564
+ c.prototype = parent;
12565
+ return new c();
12566
+ };
12567
+
12568
+ // private utility functions
12569
+
12570
+ function __objToStr(o) {
12571
+ return Object.prototype.toString.call(o);
12572
+ }
12573
+ clone.__objToStr = __objToStr;
12574
+
12575
+ function __isDate(o) {
12576
+ return typeof o === 'object' && __objToStr(o) === '[object Date]';
12577
+ }
12578
+ clone.__isDate = __isDate;
12579
+
12580
+ function __isArray(o) {
12581
+ return typeof o === 'object' && __objToStr(o) === '[object Array]';
12582
+ }
12583
+ clone.__isArray = __isArray;
12584
+
12585
+ function __isRegExp(o) {
12586
+ return typeof o === 'object' && __objToStr(o) === '[object RegExp]';
12587
+ }
12588
+ clone.__isRegExp = __isRegExp;
12589
+
12590
+ function __getRegExpFlags(re) {
12591
+ var flags = '';
12592
+ if (re.global) flags += 'g';
12593
+ if (re.ignoreCase) flags += 'i';
12594
+ if (re.multiline) flags += 'm';
12595
+ return flags;
12596
+ }
12597
+ clone.__getRegExpFlags = __getRegExpFlags;
12598
+
12599
+ return clone;
12600
+ })();
12601
+
12602
+ if (typeof module === 'object' && module.exports) {
12603
+ module.exports = clone;
12604
+ }
12605
+
12606
+ },{}],101:[function(require,module,exports){
12173
12607
  'use strict';
12174
12608
 
12175
12609
  var asap = require('asap/raw');
@@ -12384,7 +12818,7 @@ function doResolve(fn, promise) {
12384
12818
  }
12385
12819
  }
12386
12820
 
12387
- },{"asap/raw":99}],101:[function(require,module,exports){
12821
+ },{"asap/raw":99}],102:[function(require,module,exports){
12388
12822
  'use strict';
12389
12823
 
12390
12824
  //This file contains the ES6 extensions to the core Promises/A+ API
@@ -12493,7 +12927,7 @@ Promise.prototype['catch'] = function (onRejected) {
12493
12927
  return this.then(null, onRejected);
12494
12928
  };
12495
12929
 
12496
- },{"./core.js":100}],102:[function(require,module,exports){
12930
+ },{"./core.js":101}],103:[function(require,module,exports){
12497
12931
  // should work in any browser without browserify
12498
12932
 
12499
12933
  if (typeof Promise.prototype.done !== 'function') {
@@ -12506,7 +12940,7 @@ if (typeof Promise.prototype.done !== 'function') {
12506
12940
  })
12507
12941
  }
12508
12942
  }
12509
- },{}],103:[function(require,module,exports){
12943
+ },{}],104:[function(require,module,exports){
12510
12944
  // not "use strict" so we can declare global "Promise"
12511
12945
 
12512
12946
  var asap = require('asap');
@@ -12518,5 +12952,5 @@ if (typeof Promise === 'undefined') {
12518
12952
 
12519
12953
  require('./polyfill-done.js');
12520
12954
 
12521
- },{"./lib/core.js":100,"./lib/es6-extensions.js":101,"./polyfill-done.js":102,"asap":98}]},{},[2])(2)
12955
+ },{"./lib/core.js":101,"./lib/es6-extensions.js":102,"./polyfill-done.js":103,"asap":98}]},{},[2])(2)
12522
12956
  });