Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated to less.js 1.3.2

  • Loading branch information...
commit 40dbf53540d6d67cea500f57931fd21ea0f399c0 1 parent b825735
@marklagendijk authored
Showing with 6,882 additions and 418 deletions.
  1. +1 −0  .gitignore
  2. +1 −5 WinLess/node_modules/less/.npmignore
  3. +63 −1 WinLess/node_modules/less/CHANGELOG.md
  4. +50 −0 WinLess/node_modules/less/CONTRIBUTING.md
  5. +11 −0 WinLess/node_modules/less/Makefile
  6. +171 −46 WinLess/node_modules/less/lib/less/browser.js
  7. +52 −17 WinLess/node_modules/less/lib/less/functions.js
  8. +107 −31 WinLess/node_modules/less/lib/less/index.js
  9. +5 −2 WinLess/node_modules/less/lib/less/lessc_helper.js
  10. +132 −56 WinLess/node_modules/less/lib/less/parser.js
  11. +1 −1  WinLess/node_modules/less/lib/less/rhino.js
  12. +3 −1 WinLess/node_modules/less/lib/less/tree.js
  13. +3 −1 WinLess/node_modules/less/lib/less/tree/dimension.js
  14. +2 −1  WinLess/node_modules/less/lib/less/tree/element.js
  15. +11 −12 WinLess/node_modules/less/lib/less/tree/import.js
  16. +3 −5 WinLess/node_modules/less/lib/less/tree/media.js
  17. +120 −54 WinLess/node_modules/less/lib/less/tree/mixin.js
  18. +5 −0 WinLess/node_modules/less/lib/less/tree/operation.js
  19. +1 −1  WinLess/node_modules/less/lib/less/tree/quoted.js
  20. +7 −0 WinLess/node_modules/less/lib/less/tree/rule.js
  21. +56 −16 WinLess/node_modules/less/lib/less/tree/ruleset.js
  22. +11 −6 WinLess/node_modules/less/lib/less/tree/selector.js
  23. +13 −0 WinLess/node_modules/less/lib/less/tree/unicode-descriptor.js
  24. +11 −7 WinLess/node_modules/less/lib/less/tree/url.js
  25. +13 −1 WinLess/node_modules/less/lib/less/tree/variable.js
  26. +15 −0 WinLess/node_modules/less/node_modules/.bin/ycssmin
  27. +6 −0 WinLess/node_modules/less/node_modules/.bin/ycssmin.cmd
  28. +11 −0 WinLess/node_modules/less/node_modules/ycssmin/.npmignore
  29. +8 −0 WinLess/node_modules/less/node_modules/ycssmin/.travis.yml
  30. +25 −0 WinLess/node_modules/less/node_modules/ycssmin/LICENSE
  31. +14 −0 WinLess/node_modules/less/node_modules/ycssmin/Makefile
  32. +97 −0 WinLess/node_modules/less/node_modules/ycssmin/README.md
  33. +89 −83 WinLess/node_modules/less/{lib/less → node_modules/ycssmin}/cssmin.js
  34. +62 −0 WinLess/node_modules/less/node_modules/ycssmin/package.json
  35. +2 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/background-position.css
  36. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/background-position.css.min
  37. +5 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/border-none.css
  38. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/border-none.css.min
  39. +9 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/box-model-hack.css
  40. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/box-model-hack.css.min
  41. +10 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/bug2527974.css
  42. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/bug2527974.css.min
  43. +19 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/bug2527991.css
  44. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/bug2527991.css.min
  45. +4 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/bug2527998.css
  46. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/bug2527998.css.min
  47. +5 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/bug2528034.css
  48. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/bug2528034.css.min
  49. +9 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/charset-media.css
  50. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/charset-media.css.min
  51. +8 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/color-simple.css
  52. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/color-simple.css.min
  53. +46 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/color.css
  54. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/color.css.min
  55. +3 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/comment.css
  56. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/comment.css.min
  57. +15 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/concat-charset.css
  58. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/concat-charset.css.min
  59. +23 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/dataurl-base64-doublequotes.css
  60. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/dataurl-base64-doublequotes.css.min
  61. +10 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/dataurl-base64-eof.css
  62. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/dataurl-base64-eof.css.min
  63. +34 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/dataurl-base64-linebreakindata.css
  64. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/dataurl-base64-linebreakindata.css.min
  65. +26 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/dataurl-base64-noquotes.css
  66. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/dataurl-base64-noquotes.css.min
  67. +23 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/dataurl-base64-singlequotes.css
  68. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/dataurl-base64-singlequotes.css.min
  69. +27 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/dataurl-base64-twourls.css
  70. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/dataurl-base64-twourls.css.min
  71. +30 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/dataurl-dbquote-font.css
  72. +5 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/dataurl-dbquote-font.css.min
  73. +13 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/dataurl-nonbase64-doublequotes.css
  74. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/dataurl-nonbase64-doublequotes.css.min
  75. +11 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/dataurl-nonbase64-noquotes.css
  76. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/dataurl-nonbase64-noquotes.css.min
  77. +15 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/dataurl-nonbase64-singlequotes.css
  78. +2 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/dataurl-nonbase64-singlequotes.css.min
  79. +31 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/dataurl-noquote-multiline-font.css
  80. +3 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/dataurl-noquote-multiline-font.css.min
  81. +90 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/dataurl-realdata-doublequotes.css
  82. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/dataurl-realdata-doublequotes.css.min
  83. +90 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/dataurl-realdata-noquotes.css
  84. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/dataurl-realdata-noquotes.css.min
  85. +90 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/dataurl-realdata-singlequotes.css
  86. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/dataurl-realdata-singlequotes.css.min
  87. +106 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/dataurl-realdata-yuiapp.css
  88. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/dataurl-realdata-yuiapp.css.min
  89. +30 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/dataurl-singlequote-font.css
  90. +3 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/dataurl-singlequote-font.css.min
  91. +3 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/decimals.css
  92. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/decimals.css.min
  93. +7 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/dollar-header.css
  94. +3 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/dollar-header.css.min
  95. +6 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/font-face.css
  96. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/font-face.css.min
  97. +5 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/ie5mac.css
  98. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/ie5mac.css.min
  99. +16 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/media-empty-class.css
  100. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/media-empty-class.css.min
  101. +3 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/media-multi.css
  102. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/media-multi.css.min
  103. +3 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/media-test.css
  104. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/media-test.css.min
  105. +14 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/opacity-filter.css
  106. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/opacity-filter.css.min
  107. +15 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/preserve-case.css
  108. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/preserve-case.css.min
  109. +6 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/preserve-new-line.css
  110. +3 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/preserve-new-line.css.min
  111. +7 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/preserve-strings.css
  112. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/preserve-strings.css.min
  113. +16 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/pseudo-first.css
  114. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/pseudo-first.css.min
  115. +5 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/pseudo.css
  116. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/pseudo.css.min
  117. +13 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/special-comments.css
  118. +9 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/special-comments.css.min
  119. +118 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/special/linebreakpos.css
  120. +6 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/special/linebreakpos.css.min
  121. +5 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/star-underscore-hacks.css
  122. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/star-underscore-hacks.css.min
  123. +8 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/string-in-comment.css
  124. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/string-in-comment.css.min
  125. +2 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/webkit-transform.css
  126. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/webkit-transform.css.min
  127. +6 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/files/zeros.css
  128. +1 −0  WinLess/node_modules/less/node_modules/ycssmin/tests/files/zeros.css.min
  129. +49 −0 WinLess/node_modules/less/node_modules/ycssmin/tests/tests.js
  130. +18 −5 WinLess/node_modules/less/package.json
  131. +29 −0 WinLess/node_modules/less/test/browser-test-prepare.js
  132. +74 −0 WinLess/node_modules/less/test/browser/common.js
  133. +36 −0 WinLess/node_modules/less/test/browser/css/relative-urls/urls.css
  134. +36 −0 WinLess/node_modules/less/test/browser/css/rootpath-relative/urls.css
  135. +36 −0 WinLess/node_modules/less/test/browser/css/rootpath/urls.css
  136. +36 −0 WinLess/node_modules/less/test/browser/css/urls.css
  137. +681 −0 WinLess/node_modules/less/test/browser/jasmine-html.js
  138. +82 −0 WinLess/node_modules/less/test/browser/jasmine.css
  139. +2,600 −0 WinLess/node_modules/less/test/browser/jasmine.js
  140. +4 −0 WinLess/node_modules/less/test/browser/less/imports/urls.less
  141. +4 −0 WinLess/node_modules/less/test/browser/less/imports/urls2.less
  142. +33 −0 WinLess/node_modules/less/test/browser/less/relative-urls/urls.less
  143. +33 −0 WinLess/node_modules/less/test/browser/less/rootpath-relative/urls.less
  144. +33 −0 WinLess/node_modules/less/test/browser/less/rootpath/urls.less
  145. +33 −0 WinLess/node_modules/less/test/browser/less/urls.less
  146. +139 −0 WinLess/node_modules/less/test/browser/phantom-runner.js
  147. +3 −0  WinLess/node_modules/less/test/browser/runner-browser.js
  148. +15 −0 WinLess/node_modules/less/test/browser/runner-main.js
  149. +4 −0 WinLess/node_modules/less/test/browser/runner-relative-urls.js
  150. +5 −0 WinLess/node_modules/less/test/browser/runner-rootpath-relative.js
  151. +4 −0 WinLess/node_modules/less/test/browser/runner-rootpath.js
  152. +10 −0 WinLess/node_modules/less/test/browser/template.htm
  153. +1 −0  WinLess/node_modules/less/test/css/charsets.css
  154. +3 −0  WinLess/node_modules/less/test/css/colors.css
  155. +7 −0 WinLess/node_modules/less/test/css/comments.css
  156. +17 −2 WinLess/node_modules/less/test/css/css-3.css
  157. +3 −14 WinLess/node_modules/less/test/css/css.css
  158. +7 −0 WinLess/node_modules/less/test/css/functions.css
  159. +0 −3  WinLess/node_modules/less/test/css/import-once.css
  160. +7 −9 WinLess/node_modules/less/test/css/import.css
  161. +19 −0 WinLess/node_modules/less/test/css/media.css
  162. +21 −0 WinLess/node_modules/less/test/css/mixins-args.css
  163. +3 −0  WinLess/node_modules/less/test/css/mixins-guards.css
  164. +21 −0 WinLess/node_modules/less/test/css/mixins-important.css
  165. +7 −0 WinLess/node_modules/less/test/css/mixins-named-args.css
  166. +7 −0 WinLess/node_modules/less/test/css/mixins.css
  167. +20 −0 WinLess/node_modules/less/test/css/scope.css
  168. +3 −0  WinLess/node_modules/less/test/css/selectors.css
  169. +42 −0 WinLess/node_modules/less/test/css/static-urls/urls.css
  170. +1 −1  WinLess/node_modules/less/test/css/strings.css
  171. +42 −0 WinLess/node_modules/less/test/css/urls.css
  172. +0 −1  WinLess/node_modules/less/test/css/variables.css
  173. +14 −6 WinLess/node_modules/less/test/less-test.js
  174. +3 −0  WinLess/node_modules/less/test/less/charsets.less
  175. +4 −0 WinLess/node_modules/less/test/less/colors.less
  176. +12 −0 WinLess/node_modules/less/test/less/comments.less
  177. +8 −3 WinLess/node_modules/less/test/less/css-3.less
  178. +4 −17 WinLess/node_modules/less/test/less/css.less
  179. +1 −0  WinLess/node_modules/less/test/less/errors/bad-variable-declaration1.less
  180. +2 −0  WinLess/node_modules/less/test/less/errors/bad-variable-declaration1.txt
  181. +1 −1  WinLess/node_modules/less/test/less/errors/import-subfolder2.txt
  182. +4 −0 WinLess/node_modules/less/test/less/errors/imports/import-test.less
  183. +6 −0 WinLess/node_modules/less/test/less/errors/mixed-mixin-definition-args-1.less
  184. +4 −0 WinLess/node_modules/less/test/less/errors/mixed-mixin-definition-args-1.txt
  185. +6 −0 WinLess/node_modules/less/test/less/errors/mixed-mixin-definition-args-2.less
  186. +4 −0 WinLess/node_modules/less/test/less/errors/mixed-mixin-definition-args-2.txt
  187. +6 −0 WinLess/node_modules/less/test/less/errors/mixin-not-matched.less
  188. +3 −0  WinLess/node_modules/less/test/less/errors/mixin-not-matched.txt
  189. +6 −0 WinLess/node_modules/less/test/less/errors/mixin-not-matched2.less
  190. +3 −0  WinLess/node_modules/less/test/less/errors/mixin-not-matched2.txt
  191. +1 −1  WinLess/node_modules/less/test/less/errors/parse-error-curly-bracket.txt
  192. +1 −1  WinLess/node_modules/less/test/less/errors/parse-error-missing-bracket.txt
  193. +13 −0 WinLess/node_modules/less/test/less/errors/parse-error-with-import.less
  194. +4 −0 WinLess/node_modules/less/test/less/errors/parse-error-with-import.txt
  195. +1 −0  WinLess/node_modules/less/test/less/errors/recursive-variable.less
  196. +2 −0  WinLess/node_modules/less/test/less/errors/recursive-variable.txt
  197. +9 −0 WinLess/node_modules/less/test/less/functions.less
  198. +2 −1  WinLess/node_modules/less/test/less/import-once.less
  199. +2 −1  WinLess/node_modules/less/test/less/import.less
  200. +1 −1  WinLess/node_modules/less/test/less/import/deeper/import-once-test-a.less
  201. +6 −0 WinLess/node_modules/less/test/less/import/import-and-relative-paths-test.less
  202. +1 −0  WinLess/node_modules/less/test/less/import/import-charset-test.less
  203. +0 −1  WinLess/node_modules/less/test/less/import/import-once-test-c.less
  204. +1 −0  WinLess/node_modules/less/test/less/import/import-test-a.less
  205. +0 −1  WinLess/node_modules/less/test/less/import/import-test-c.less
  206. +8 −0 WinLess/node_modules/less/test/less/import/imports/font.less
  207. +5 −0 WinLess/node_modules/less/test/less/import/imports/logo.less
  208. +1 −0  WinLess/node_modules/less/test/less/import/urls.less
  209. +20 −0 WinLess/node_modules/less/test/less/media.less
  210. +37 −0 WinLess/node_modules/less/test/less/mixins-args.less
  211. +11 −0 WinLess/node_modules/less/test/less/mixins-guards.less
  212. +4 −0 WinLess/node_modules/less/test/less/mixins-important.less
  213. +5 −0 WinLess/node_modules/less/test/less/mixins-named-args.less
  214. +14 −0 WinLess/node_modules/less/test/less/mixins.less
  215. +48 −1 WinLess/node_modules/less/test/less/scope.less
  216. +5 −0 WinLess/node_modules/less/test/less/selectors.less
  217. +33 −0 WinLess/node_modules/less/test/less/static-urls/urls.less
  218. +33 −0 WinLess/node_modules/less/test/less/urls.less
  219. +0 −1  WinLess/node_modules/less/test/less/variables.less
View
1  .gitignore
@@ -161,3 +161,4 @@ pip-log.txt
# Mac crap
.DS_Store
+/.svn
View
6 WinLess/node_modules/less/.npmignore
@@ -1,5 +1 @@
-node_modules
-.emacs*
-*.flymake
-*~
-.#*
+dist/*
View
64 WinLess/node_modules/less/CHANGELOG.md
@@ -1,3 +1,65 @@
+# 1.3.2
+
+2012-12-28
+
+ - browser and server url re-writing is now aligned to not re-write (previous lessc behaviour)
+ - url-rewriting can be made to re-write to be relative to the entry file using the relative-urls option (less.relativeUrls option)
+ - rootpath option can be used to add a base path to every url
+ - Support mixin argument seperator of ';' so you can pass comma seperated values. e.g. `.mixin(23px, 12px;);`
+ - Fix lots of problems with named arguments in corner cases, not behaving as expected
+ - hsv, hsva, unit functions
+ - fixed lots more bad error messages
+ - fix `@import-once` to use the full path, not the relative one for determining if an import has been imported already
+ - support `:not(:nth-child(3))`
+ - mixin guards take units into account
+ - support unicode descriptors (`U+00A1-00A9`)
+ - support calling mixins with a stack when using `&` (broken in 1.3.1)
+ - support `@namespace` and namespace combinators
+ - when using % with colour functions, take into account a colour is out of 256
+ - when doing maths with a % do not divide by 100 and keep the unit
+ - allow url to contain % (e.g. %20 for a space)
+ - if a mixin guard stops execution a default mixin is not required
+ - units are output in strings (use the unit function if you need to get the value without unit)
+ - do not infinite recurse when mixins call mixins of the same name
+ - fix issue on important on mixin calls
+ - fix issue with multiple comments being confused
+ - tolerate multiple semi-colons on rules
+ - ignore subsequant `@charset`
+ - syncImport option for node.js to read files syncronously
+ - write the output directory if it is missing
+ - change dependency on cssmin to ycssmin
+ - lessc can load files over http
+ - allow calling less.watch() in non dev mode
+ - don't cache in dev mode
+ - less files cope with query parameters better
+ - sass debug statements are now chrome compatible
+ - modifyVars function added to re-render with different root variables
+
+# 1.3.1
+
+2012-10-18
+
+- Support for comment and @media debugging statements
+- bug fix for async access in chrome extensions
+- new functions tint, shade, multiply, screen, overlay, hardlight, difference, exclusion, average, negation, softlight, red, green, blue, contrast
+- allow escaped characters in attributes
+- in selectors support @{a} directly, e.g. .a.@{a} { color: black; }
+- add fraction parameter to round function
+- much better support for & selector
+- preserve order of link statements client side
+- lessc has better help
+- rhino version fixed
+- fix bugs in clientside error handling
+- support dpi, vmin, vm, dppx, dpcm units
+- Fix ratios in media statements
+- in mixin guards allow comparing colors and strings
+- support for -*-keyframes (for -khtml but now supports any)
+- in mix function, default weight to 50%
+- support @import-once
+- remove duplicate rules in output
+- implement named parameters when calling mixins
+- many numerous bug fixes
+
# 1.3.0
2012-03-10
@@ -46,4 +108,4 @@
- Improve @import support with media features
- Improve error reports from imported files
- Improve function call error reporting
-- Improve error-reporting
+- Improve error-reporting
View
50 WinLess/node_modules/less/CONTRIBUTING.md
@@ -0,0 +1,50 @@
+## Bug Reports
+
+ - Please create a short test case
+ - Test with the latest version
+ - indicate how you use less - browser/lessc/external tool
+
+## Feature Requests
+
+ - Please search feature requests to see if something similar exists already
+ - include a use-case - we do not add language features without a reason
+ - consider whether your language feature would be better as a function
+
+## Pull Requests
+
+Thankyou! Please take the time to read these guidelines
+
+ - Consider adding a feature request first to see if people are pro or con
+ - do not change the dist/ folder - we do this when releasing
+ - tests - please add tests for your work. use `make test` to see if they pass
+ - spaces not tabs
+ - end lines in semi-colons - loosely aim towards jslint standards
+
+## Developing
+
+1. install cygwin - http://cygwin.com/install.html
+ - default options +
+ - Devel -> Make
+ -> Git
+2. install node.js - http://nodejs.org/
+3. install phantomJS - http://phantomjs.org/download.html
+ - copy to a directory of your choice
+ - (windows) modify the path directory to include whereever you have copied it
+4. clone the repository and download to local computer
+5. run `npm install -g diff` to get diffs in your tests
+
+`lessc or node bin/lessc`
+
+to run the less compiler
+
+`make test`
+
+runs the node tests
+
+`make browser-test`
+
+runs the headless browser tests
+
+`make browser-test-server`
+
+sets up the server for the headless tests.. then go to http://localhost:8081/browser/test-runner-main.htm or one of the other test runner pages created in /test/browser/
View
11 WinLess/node_modules/less/Makefile
@@ -21,6 +21,8 @@ DIST = dist/less-${VERSION}.js
RHINO = dist/less-rhino-${VERSION}.js
DIST_MIN = dist/less-${VERSION}.min.js
+browser-prepare: DIST := test/browser/less.js
+
less:
@@mkdir -p dist
@@touch ${DIST}
@@ -37,6 +39,15 @@ less:
build/amd.js >> ${DIST}
@@echo "})(window);" >> ${DIST}
@@echo ${DIST} built.
+
+browser-prepare: less
+ node test/browser-test-prepare.js
+
+browser-test: browser-prepare
+ phantomjs test/browser/phantom-runner.js
+
+browser-test-server: browser-prepare
+ phantomjs test/browser/phantom-runner.js --no-tests
rhino:
@@mkdir -p dist
View
217 WinLess/node_modules/less/lib/less/browser.js
@@ -23,41 +23,58 @@ less.fileAsync = less.fileAsync || false;
// Interval between watch polls
less.poll = less.poll || (isFileProtocol ? 1000 : 1500);
+//Setup user functions
+if (less.functions) {
+ for(var func in less.functions) {
+ less.tree.functions[func] = less.functions[func];
+ }
+}
+
+var dumpLineNumbers = /!dumpLineNumbers:(comments|mediaquery|all)/.exec(location.hash);
+if (dumpLineNumbers) {
+ less.dumpLineNumbers = dumpLineNumbers[1];
+}
+
//
// Watch mode
//
-less.watch = function () { return this.watchMode = true };
-less.unwatch = function () { return this.watchMode = false };
+less.watch = function () {
+ if (!less.watchMode ){
+ less.env = 'development';
+ initRunningMode();
+ }
+ return this.watchMode = true
+};
-if (less.env === 'development') {
- less.optimization = 0;
+less.unwatch = function () {clearInterval(less.watchTimer); return this.watchMode = false; };
+
+function initRunningMode(){
+ if (less.env === 'development') {
+ less.optimization = 0;
+ less.watchTimer = setInterval(function () {
+ if (less.watchMode) {
+ loadStyleSheets(function (e, root, _, sheet, env) {
+ if (root) {
+ createCSS(root.toCSS(), sheet, env.lastModified);
+ }
+ });
+ }
+ }, less.poll);
+ } else {
+ less.optimization = 3;
+ }
+}
- if (/!watch/.test(location.hash)) {
- less.watch();
- }
- var dumpLineNumbers = /!dumpLineNumbers:(comments|mediaquery|all)/.exec(location.hash);
- if (dumpLineNumbers) {
- less.dumpLineNumbers = dumpLineNumbers[1];
- }
- less.watchTimer = setInterval(function () {
- if (less.watchMode) {
- loadStyleSheets(function (e, root, _, sheet, env) {
- if (root) {
- createCSS(root.toCSS(), sheet, env.lastModified);
- }
- });
- }
- }, less.poll);
-} else {
- less.optimization = 3;
+if (/!watch/.test(location.hash)) {
+ less.watch();
}
-var cache;
+var cache = null;
-try {
- cache = (typeof(window.localStorage) === 'undefined') ? null : window.localStorage;
-} catch (_) {
- cache = null;
+if (less.env != 'development') {
+ try {
+ cache = (typeof(window.localStorage) === 'undefined') ? null : window.localStorage;
+ } catch (_) {}
}
//
@@ -75,6 +92,21 @@ for (var i = 0; i < links.length; i++) {
}
}
+//
+// With this function, it's possible to alter variables and re-render
+// CSS without reloading less-files
+//
+var session_cache = '';
+less.modifyVars = function(record) {
+ var str = session_cache;
+ for (name in record) {
+ str += ((name.slice(0,1) === '@')? '' : '@') + name +': '+
+ ((record[name].slice(-1) === ';')? record[name] : record[name] +';');
+ }
+ new(less.Parser)().parse(str, function (e, root) {
+ createCSS(root.toCSS(), less.sheets[less.sheets.length - 1]);
+ });
+};
less.refresh = function (reload) {
var startTime, endTime;
@@ -125,44 +157,139 @@ function loadStyleSheets(callback, reload) {
}
}
+function pathDiff(url, baseUrl) {
+ // diff between two paths to create a relative path
+
+ var urlParts = extractUrlParts(url),
+ baseUrlParts = extractUrlParts(baseUrl),
+ i, max, urlDirectories, baseUrlDirectories, diff = "";
+ if (urlParts.hostPart !== baseUrlParts.hostPart) {
+ return "";
+ }
+ max = Math.max(baseUrlParts.directories.length, urlParts.directories.length);
+ for(i = 0; i < max; i++) {
+ if (baseUrlParts.directories[i] !== urlParts.directories[i]) { break; }
+ }
+ baseUrlDirectories = baseUrlParts.directories.slice(i);
+ urlDirectories = urlParts.directories.slice(i);
+ for(i = 0; i < baseUrlDirectories.length-1; i++) {
+ diff += "../";
+ }
+ for(i = 0; i < urlDirectories.length-1; i++) {
+ diff += urlDirectories[i] + "/";
+ }
+ return diff;
+}
+
+function extractUrlParts(url, baseUrl) {
+ // urlParts[1] = protocol&hostname || /
+ // urlParts[2] = / if path relative to host base
+ // urlParts[3] = directories
+ // urlParts[4] = filename
+ // urlParts[5] = parameters
+
+ var urlPartsRegex = /^((?:[a-z-]+:)?\/\/(?:[^\/\?#]+\/)|([\/\\]))?((?:[^\/\\\?#]+[\/\\])*)([^\/\\\?#]*)([#\?].*)?$/,
+ urlParts = url.match(urlPartsRegex),
+ returner = {}, directories = [], i, baseUrlParts;
+
+ if (!urlParts) {
+ throw new Error("Could not parse sheet href - '"+url+"'");
+ }
+
+ // Stylesheets in IE don't always return the full path
+ if (!urlParts[1] || urlParts[2]) {
+ baseUrlParts = baseUrl.match(urlPartsRegex);
+ if (!baseUrlParts) {
+ throw new Error("Could not parse page url - '"+baseUrl+"'");
+ }
+ urlParts[1] = baseUrlParts[1];
+ if (!urlParts[2]) {
+ urlParts[3] = baseUrlParts[3] + urlParts[3];
+ }
+ }
+
+ if (urlParts[3]) {
+ directories = urlParts[3].replace("\\", "/").split("/");
+
+ for(i = 0; i < directories.length; i++) {
+ if (directories[i] === ".." && i > 0) {
+ directories.splice(i-1, 2);
+ i -= 2;
+ }
+ }
+ }
+
+ returner.hostPart = urlParts[1];
+ returner.directories = directories;
+ returner.path = urlParts[1] + directories.join("/");
+ returner.fileUrl = returner.path + (urlParts[4] || "");
+ returner.url = returner.fileUrl + (urlParts[5] || "");
+ return returner;
+}
+
function loadStyleSheet(sheet, callback, reload, remaining) {
- var contents = sheet.contents || {}; // Passing a ref to top importing parser content cache trough 'sheet' arg.
- var url = window.location.href.replace(/[#?].*$/, '');
- var href = sheet.href.replace(/\?.*$/, '');
+ // sheet may be set to the stylesheet for the initial load or a collection of properties including
+ // some env variables for imports
+ var contents = sheet.contents || {};
+ var files = sheet.files || {};
+ var hrefParts = extractUrlParts(sheet.href, window.location.href);
+ var href = hrefParts.url;
var css = cache && cache.getItem(href);
var timestamp = cache && cache.getItem(href + ':timestamp');
var styles = { css: css, timestamp: timestamp };
+ var rootpath;
- // Stylesheets in IE don't always return the full path
- if (! /^[a-z-]+:/.test(href)) {
- if (href.charAt(0) == "/") {
- href = window.location.protocol + "//" + window.location.host + href;
+ if (less.relativeUrls) {
+ if (less.rootpath) {
+ if (sheet.entryPath) {
+ rootpath = extractUrlParts(less.rootpath + pathDiff(hrefParts.path, sheet.entryPath)).path;
+ } else {
+ rootpath = less.rootpath;
+ }
} else {
- href = url.slice(0, url.lastIndexOf('/') + 1) + href;
+ rootpath = hrefParts.path;
+ }
+ } else {
+ if (less.rootpath) {
+ rootpath = less.rootpath;
+ } else {
+ if (sheet.entryPath) {
+ rootpath = sheet.entryPath;
+ } else {
+ rootpath = hrefParts.path;
+ }
}
}
- xhr(sheet.href, sheet.type, function (data, lastModified) {
+
+ xhr(href, sheet.type, function (data, lastModified) {
+ // Store data this session
+ session_cache += data.replace(/@import .+?;/ig, '');
+
if (!reload && styles && lastModified &&
(new(Date)(lastModified).valueOf() ===
new(Date)(styles.timestamp).valueOf())) {
// Use local copy
createCSS(styles.css, sheet);
- callback(null, null, data, sheet, { local: true, remaining: remaining });
+ callback(null, null, data, sheet, { local: true, remaining: remaining }, href);
} else {
// Use remote copy (re-parse)
try {
contents[href] = data; // Updating top importing parser content cache
new(less.Parser)({
optimization: less.optimization,
- paths: [href.replace(/[\w\.-]+$/, '')],
+ paths: [hrefParts.path],
+ entryPath: sheet.entryPath || hrefParts.path,
mime: sheet.type,
filename: href,
- 'contents': contents, // Passing top importing parser content cache ref down.
+ rootpath: rootpath,
+ relativeUrls: sheet.relativeUrls,
+ contents: contents, // Passing top importing parser content cache ref down.
+ files: files,
dumpLineNumbers: less.dumpLineNumbers
}).parse(data, function (e, root) {
if (e) { return error(e, href) }
try {
- callback(e, root, data, sheet, { local: false, lastModified: lastModified, remaining: remaining });
+ callback(e, root, data, sheet, { local: false, lastModified: lastModified, remaining: remaining }, href);
removeNode(document.getElementById('less-error-message:' + extractId(href)));
} catch (e) {
error(e, href);
@@ -180,8 +307,7 @@ function loadStyleSheet(sheet, callback, reload, remaining) {
function extractId(href) {
return href.replace(/^[a-z]+:\/\/?[^\/]+/, '' ) // Remove protocol & domain
.replace(/^\//, '' ) // Remove root /
- .replace(/\?.*$/, '' ) // Remove query
- .replace(/\.[^\.\/]+$/, '' ) // Remove file extension
+ .replace(/\.[a-zA-Z]+$/, '' ) // Remove simple extension
.replace(/[^\.\w-]+/g, '-') // Replace illegal characters
.replace(/\./g, ':'); // Replace dots with colons(for valid id)
}
@@ -190,7 +316,7 @@ function createCSS(styles, sheet, lastModified) {
var css;
// Strip the query-string
- var href = sheet.href ? sheet.href.replace(/\?.*$/, '') : '';
+ var href = sheet.href || '';
// If there is no title set, use the filename, minus the extension
var id = 'less:' + (sheet.title || extractId(href));
@@ -202,7 +328,7 @@ function createCSS(styles, sheet, lastModified) {
if( sheet.media ){ css.media = sheet.media; }
css.id = id;
var nextEl = sheet && sheet.nextSibling || null;
- document.getElementsByTagName('head')[0].insertBefore(css, nextEl);
+ (nextEl || document.getElementsByTagName('head')[0]).parentNode.insertBefore(css, nextEl);
}
if (css.styleSheet) { // IE
@@ -299,7 +425,7 @@ function error(e, href) {
var template = '<li><label>{line}</label><pre class="{class}">{content}</pre></li>';
var elem = document.createElement('div'), timer, content, error = [];
var filename = e.filename || href;
- var filenameNoPath = filename.match(/([^\/]+)$/)[1];
+ var filenameNoPath = filename.match(/([^\/]+(\?.*)?)$/)[1];
elem.id = id;
elem.className = "less-error-message";
@@ -391,4 +517,3 @@ function error(e, href) {
}, 10);
}
}
-
View
69 WinLess/node_modules/less/lib/less/functions.js
@@ -5,8 +5,8 @@ tree.functions = {
return this.rgba(r, g, b, 1.0);
},
rgba: function (r, g, b, a) {
- var rgb = [r, g, b].map(function (c) { return number(c) }),
- a = number(a);
+ var rgb = [r, g, b].map(function (c) { return scaled(c, 256); });
+ a = number(a);
return new(tree.Color)(rgb, a);
},
hsl: function (h, s, l) {
@@ -32,6 +32,36 @@ tree.functions = {
else return m1;
}
},
+
+ hsv: function(h, s, v) {
+ return this.hsva(h, s, v, 1.0);
+ },
+
+ hsva: function(h, s, v, a) {
+ h = ((number(h) % 360) / 360) * 360;
+ s = number(s); v = number(v); a = number(a);
+
+ var i, f;
+ i = Math.floor((h / 60) % 6);
+ f = (h / 60) - i;
+
+ var vs = [v,
+ v * (1 - s),
+ v * (1 - f * s),
+ v * (1 - (1 - f) * s)];
+ var perm = [[0, 3, 1],
+ [2, 0, 1],
+ [1, 0, 3],
+ [1, 2, 0],
+ [3, 1, 0],
+ [0, 1, 2]];
+
+ return this.rgba(vs[perm[i][0]] * 255,
+ vs[perm[i][1]] * 255,
+ vs[perm[i][2]] * 255,
+ a);
+ },
+
hue: function (color) {
return new(tree.Dimension)(Math.round(color.toHSL().h));
},
@@ -56,8 +86,8 @@ tree.functions = {
luma: function (color) {
return new(tree.Dimension)(Math.round((0.2126 * (color.rgb[0]/255) +
0.7152 * (color.rgb[1]/255) +
- 0.0722 * (color.rgb[2]/255))
- * color.alpha * 100), '%');
+ 0.0722 * (color.rgb[2]/255)) *
+ color.alpha * 100), '%');
},
saturate: function (color, amount) {
var hsl = color.toHSL();
@@ -179,27 +209,24 @@ tree.functions = {
str = str.replace(/%%/g, '%');
return new(tree.Quoted)('"' + str + '"', str);
},
+ unit: function (val, unit) {
+ return new(tree.Dimension)(val.value, unit ? unit.toCSS() : "");
+ },
round: function (n, f) {
var fraction = typeof(f) === "undefined" ? 0 : f.value;
- if (n instanceof tree.Dimension) {
- return new(tree.Dimension)(number(n).toFixed(fraction), n.unit);
- } else if (typeof(n) === 'number') {
- return n.toFixed(fraction);
- } else {
- throw { type: "Argument", message: "argument must be a number" };
- }
+ return this._math(function(num) { return num.toFixed(fraction); }, n);
},
ceil: function (n) {
- return this._math('ceil', n);
+ return this._math(Math.ceil, n);
},
floor: function (n) {
- return this._math('floor', n);
+ return this._math(Math.floor, n);
},
_math: function (fn, n) {
if (n instanceof tree.Dimension) {
- return new(tree.Dimension)(Math[fn](number(n)), n.unit);
+ return new(tree.Dimension)(fn(parseFloat(n.value)), n.unit);
} else if (typeof(n) === 'number') {
- return Math[fn](n);
+ return fn(n);
} else {
throw { type: "Argument", message: "argument must be a number" };
}
@@ -313,8 +340,16 @@ tree.functions = {
}
};
-function hsla(hsla) {
- return tree.functions.hsla(hsla.h, hsla.s, hsla.l, hsla.a);
+function hsla(color) {
+ return tree.functions.hsla(color.h, color.s, color.l, color.a);
+}
+
+function scaled(n, size) {
+ if (n instanceof tree.Dimension && n.unit == '%') {
+ return parseFloat(n.value * size / 100);
+ } else {
+ return number(n);
+ }
}
function number(n) {
View
138 WinLess/node_modules/less/lib/less/index.js
@@ -1,9 +1,11 @@
var path = require('path'),
sys = require('util'),
+ url = require('url'),
+ http = require('http'),
fs = require('fs');
var less = {
- version: [1, 3, 0],
+ version: [1, 3, 2],
Parser: require('./parser').Parser,
importer: require('./parser').importer,
tree: require('./tree'),
@@ -41,9 +43,10 @@ var less = {
var error = [];
var stylize = options.color ? require('./lessc_helper').stylize : function (str) { return str };
- if (ctx.stack) { return stylize(ctx.stack, 'red') }
+ // only output a stack if it isn't a less error
+ if (ctx.stack && !ctx.type) { return stylize(ctx.stack, 'red') }
- if (!ctx.hasOwnProperty('index')) {
+ if (!ctx.hasOwnProperty('index') || !extract) {
return ctx.stack || ctx.message;
}
@@ -88,48 +91,121 @@ var less = {
'call', 'url', 'alpha', 'import',
'mixin', 'comment', 'anonymous', 'value',
'javascript', 'assignment', 'condition', 'paren',
- 'media', 'ratio'
+ 'media', 'ratio', 'unicode-descriptor'
].forEach(function (n) {
require('./tree/' + n);
});
+
+var isUrlRe = /^(?:https?:)?\/\//i;
+
less.Parser.importer = function (file, paths, callback, env) {
- var pathname;
-
- // TODO: Undo this at some point,
- // or use different approach.
- var paths = [].concat(paths); // Avoid passing paths by reference down the import tree...
- paths.unshift('.'); // ...which results on a lot of repeated '.' paths.
-
- for (var i = 0; i < paths.length; i++) {
- try {
- pathname = path.join(paths[i], file);
- fs.statSync(pathname);
- break;
- } catch (e) {
- pathname = null;
+ var pathname, dirname, data;
+
+ function parseFile(e, data) {
+ if (e) return callback(e);
+
+ var rootpath = env.rootpath,
+ j = file.lastIndexOf('/');
+
+ // Pass on an updated rootpath if path of imported file is relative and file
+ // is in a (sub|sup) directory
+ //
+ // Examples:
+ // - If path of imported file is 'module/nav/nav.less' and rootpath is 'less/',
+ // then rootpath should become 'less/module/nav/'
+ // - If path of imported file is '../mixins.less' and rootpath is 'less/',
+ // then rootpath should become 'less/../'
+ if(env.relativeUrls && !/^(?:[a-z-]+:|\/)/.test(file) && j != -1) {
+ rootpath = rootpath + file.slice(0, j+1); // append (sub|sup) directory path of imported file
}
- }
- if (pathname) {
- fs.readFile(pathname, 'utf-8', function(e, data) {
- if (e) return callback(e);
-
- env.contents[pathname] = data; // Updating top importing parser content cache.
- new(less.Parser)({
- paths: [path.dirname(pathname)].concat(paths),
+ env.contents[pathname] = data; // Updating top importing parser content cache.
+ new(less.Parser)({
+ paths: [dirname].concat(paths),
filename: pathname,
contents: env.contents,
+ files: env.files,
+ syncImport: env.syncImport,
+ relativeUrls: env.relativeUrls,
+ rootpath: rootpath,
dumpLineNumbers: env.dumpLineNumbers
- }).parse(data, function (e, root) {
- callback(e, root);
+ }).parse(data, function (e, root) {
+ callback(e, root, pathname);
+ });
+ };
+
+ var isUrl = isUrlRe.test( file );
+ if (isUrl || isUrlRe.test(paths[0])) {
+
+ var urlStr = isUrl ? file : url.resolve(paths[0], file),
+ urlObj = url.parse(urlStr),
+ req = {
+ host: urlObj.hostname,
+ port: urlObj.port || 80,
+ path: urlObj.pathname + (urlObj.search||'')
+ };
+
+ http.get(req, function (res) {
+ var body = '';
+ res.on('data', function (chunk) {
+ body += chunk.toString();
+ });
+ res.on('end', function () {
+ if (res.statusCode === 404) {
+ callback({ type: 'File', message: "resource '" + urlStr + "' was not found\n" });
+ }
+ if (!body) {
+ sys.error( 'Warning: Empty body (HTTP '+ res.statusCode + ') returned by "' + urlStr +'"' );
+ }
+ pathname = urlStr;
+ dirname = urlObj.protocol +'//'+ urlObj.host + urlObj.pathname.replace(/[^\/]*$/, '');
+ parseFile(null, body);
});
+ }).on('error', function (err) {
+ callback({ type: 'File', message: "resource '" + urlStr + "' gave this Error:\n "+ err +"\n" });
});
+
} else {
- if (typeof(env.errback) === "function") {
- env.errback(file, paths, callback);
+
+ // TODO: Undo this at some point,
+ // or use different approach.
+ var paths = [].concat(paths);
+ paths.push('.');
+
+ for (var i = 0; i < paths.length; i++) {
+ try {
+ pathname = path.join(paths[i], file);
+ fs.statSync(pathname);
+ break;
+ } catch (e) {
+ pathname = null;
+ }
+ }
+
+ paths = paths.slice(0, paths.length - 1);
+
+ if (!pathname) {
+
+ if (typeof(env.errback) === "function") {
+ env.errback(file, paths, callback);
+ } else {
+ callback({ type: 'File', message: "'" + file + "' wasn't found.\n" });
+ }
+ return;
+ }
+
+ dirname = path.dirname(pathname);
+
+ if (env.syncImport) {
+ try {
+ data = fs.readFileSync(pathname, 'utf-8');
+ parseFile(null, data);
+ } catch (e) {
+ parseFile(e);
+ }
} else {
- callback({ type: 'File', message: "'" + file + "' wasn't found.\n" });
+ fs.readFile(pathname, 'utf-8', parseFile);
}
}
}
View
7 WinLess/node_modules/less/lib/less/lessc_helper.js
@@ -23,7 +23,7 @@ var lessc_helper = {
//Print command line options
printUsage: function() {
- sys.puts("usage: lessc [options] <source> [destination]");
+ sys.puts("usage: lessc [option option=parameter ...] <source> [destination]");
sys.puts("");
sys.puts("If source is set to `-' (dash or hyphen-minus), input is read from stdin.");
sys.puts("");
@@ -36,7 +36,7 @@ var lessc_helper = {
sys.puts(" --verbose Be verbose.");
sys.puts(" -v, --version Print version number and exit.");
sys.puts(" -x, --compress Compress output by removing some whitespaces.");
- sys.puts(" --yui-compress Compress output using cssmin.js.");
+ sys.puts(" --yui-compress Compress output using ycssmin");
sys.puts(" -O0, -O1, -O2 Set the parser's optimization level. The lower");
sys.puts(" the number, the less nodes it will create in the");
sys.puts(" tree. This could matter for debugging, or if you");
@@ -47,6 +47,9 @@ var lessc_helper = {
sys.puts(" that will output the information within a fake");
sys.puts(" media query which is compatible with the SASS");
sys.puts(" format, and 'all' which will do both.");
+ sys.puts(" -rp, --rootpath Set rootpath for url rewriting in relative imports and urls.");
+ sys.puts(" Works with or withour the relative-urls option.");
+ sys.puts(" -ru, --relative-urls re-write relative urls to the base less file.");
sys.puts("");
sys.puts("Report bugs to: http://github.com/cloudhead/less.js/issues");
sys.puts("Home page: <http://lesscss.org/>");
View
188 WinLess/node_modules/less/lib/less/parser.js
@@ -1,4 +1,4 @@
-var less, tree;
+var less, tree, charset;
if (typeof environment === "object" && ({}).toString.call(environment) === "[object Environment]") {
// Rhino
@@ -68,19 +68,22 @@ less.Parser = function Parser(env) {
// Top parser on an import tree must be sure there is one "env"
// which will then be passed arround by reference.
var env = env || { };
- if (!env.contents) { env.contents={}; } // env.contents must be passed arround with top env
+ // env.contents and files must be passed arround with top env
+ if (!env.contents) { env.contents = {}; }
+ env.rootpath = env.rootpath || ''; // env.rootpath must be initialized to '' if not provided
+ if (!env.files) { env.files = {}; }
// This function is called after all files
// have been imported through `@import`.
var finish = function () {};
var imports = this.imports = {
- paths: env && env.paths || [], // Search paths, when importing
- queue: [], // Files which haven't been imported yet
- files: {}, // Holds the imported parse trees
- contents: env.contents, // Holds the imported file contents
- mime: env && env.mime, // MIME type of .less files
- error: null, // Error in parsing/evaluating an import
+ paths: env.paths || [], // Search paths, when importing
+ queue: [], // Files which haven't been imported yet
+ files: env.files, // Holds the imported parse trees
+ contents: env.contents, // Holds the imported file contents
+ mime: env.mime, // MIME type of .less files
+ error: null, // Error in parsing/evaluating an import
push: function (path, callback) {
var that = this;
this.queue.push(path);
@@ -88,18 +91,18 @@ less.Parser = function Parser(env) {
//
// Import a file asynchronously
//
- less.Parser.importer(path, this.paths, function (e, root) {
+ less.Parser.importer(path, this.paths, function (e, root, fullPath) {
that.queue.splice(that.queue.indexOf(path), 1); // Remove the path from the queue
- var imported = path in that.files;
+ var imported = fullPath in that.files;
- that.files[path] = root; // Store the root
+ that.files[fullPath] = root; // Store the root
if (e && !that.error) { that.error = e }
callback(e, root, imported);
- if (that.queue.length === 0) { finish(e) } // Call `finish` if we're done importing
+ if (that.queue.length === 0) { finish(that.error) } // Call `finish` if we're done importing
}, env);
}
};
@@ -193,7 +196,10 @@ less.Parser = function Parser(env) {
}
function error(msg, type) {
- throw { index: i, type: type || 'Syntax', message: msg };
+ var e = new Error(msg);
+ e.index = i;
+ e.type = type || 'Syntax';
+ throw e;
}
// Same as $(), but don't change the state of the parser,
@@ -304,7 +310,7 @@ less.Parser = function Parser(env) {
chunk = chunks[0],
inParam;
- for (var i = 0, c, cc; i < input.length; i++) {
+ for (var i = 0, c, cc; i < input.length;) {
skip.lastIndex = i;
if (match = skip.exec(input)) {
if (match.index === i) {
@@ -319,7 +325,7 @@ less.Parser = function Parser(env) {
if (match.index === i) {
i += match[0].length;
chunk.push(match[0]);
- c = input.charAt(i);
+ continue;
}
}
@@ -330,7 +336,7 @@ less.Parser = function Parser(env) {
if (match.index === i) {
i += match[0].length;
chunk.push(match[0]);
- c = input.charAt(i);
+ continue;
}
}
}
@@ -343,12 +349,14 @@ less.Parser = function Parser(env) {
case ')': if ( inParam) { inParam = false; chunk.push(c); break }
default: chunk.push(c);
}
+
+ i++;
}
- if (level > 0) {
+ if (level != 0) {
error = new(LessError)({
- index: i,
+ index: i-1,
type: 'Parse',
- message: "missing closing `}`",
+ message: (level > 0) ? "missing closing `}`" : "missing opening `{`",
filename: env.filename
}, env);
}
@@ -357,7 +365,7 @@ less.Parser = function Parser(env) {
})([[]]);
if (error) {
- return callback(error);
+ return callback(error, env);
}
// Start with the primary rule.
@@ -419,7 +427,7 @@ less.Parser = function Parser(env) {
}
if (options.yuicompress && less.mode === 'node') {
- return require('./cssmin').compressor.cssmin(css);
+ return require('ycssmin').cssmin(css);
} else if (options.compress) {
return css.replace(/(\s)+/g, "$1");
} else {
@@ -460,6 +468,7 @@ less.Parser = function Parser(env) {
if (this.imports.queue.length > 0) {
finish = function (e) {
+ e = error || e;
if (e) callback(e);
else callback(null, root);
};
@@ -518,7 +527,7 @@ less.Parser = function Parser(env) {
while ((node = $(this.mixin.definition) || $(this.rule) || $(this.ruleset) ||
$(this.mixin.call) || $(this.comment) || $(this.directive))
- || $(/^[\s\n]+/)) {
+ || $(/^[\s\n]+/) || $(/^;+/)) {
node && root.push(node);
}
return root;
@@ -628,7 +637,8 @@ less.Parser = function Parser(env) {
return $(this.entities.ratio) ||
$(this.entities.dimension) ||
$(this.entities.color) ||
- $(this.entities.quoted);
+ $(this.entities.quoted) ||
+ $(this.entities.unicodeDescriptor);
},
// Assignments are argument entities for calls.
@@ -661,7 +671,7 @@ less.Parser = function Parser(env) {
expect(')');
return new(tree.URL)((value.value != null || value instanceof tree.Variable)
- ? value : new(tree.Anonymous)(value), imports.paths);
+ ? value : new(tree.Anonymous)(value), env.rootpath);
},
//
@@ -711,9 +721,10 @@ less.Parser = function Parser(env) {
//
dimension: function () {
var value, c = input.charCodeAt(i);
- if ((c > 57 || c < 45) || c === 47) return;
+ //Is the first char of the dimension 0-9, '.', '+' or '-'
+ if ((c > 57 || c < 43) || c === 47 || c == 44) return;
- if (value = $(/^(-?\d*\.?\d+)(px|%|em|pc|ex|in|deg|s|ms|pt|cm|mm|rad|grad|turn|dpi|dpcm|dppx|rem|vw|vh|vmin|vm|ch)?/)) {
+ if (value = $(/^([+-]?\d*\.?\d+)(px|%|em|pc|ex|in|deg|s|ms|pt|cm|mm|rad|grad|turn|dpi|dpcm|dppx|rem|vw|vh|vmin|vm|ch)?/)) {
return new(tree.Dimension)(value[1], value[2]);
}
},
@@ -731,6 +742,19 @@ less.Parser = function Parser(env) {
return new(tree.Ratio)(value[1]);
}
},
+
+ //
+ // A unicode descriptor, as is used in unicode-range
+ //
+ // U+0?? or U+00A1-00A9
+ //
+ unicodeDescriptor: function () {
+ var ud;
+
+ if (ud = $(/^U\+[0-9a-fA-F?]+(\-[0-9a-fA-F?]+)?/)) {
+ return new(tree.UnicodeDescriptor)(ud[0]);
+ }
+ },
//
// JavaScript code to be evaluated
@@ -799,7 +823,7 @@ less.Parser = function Parser(env) {
// selector for now.
//
call: function () {
- var elements = [], e, c, args = [], arg, index = i, s = input.charAt(i), name, value, important = false;
+ var elements = [], e, c, argsSemiColon = [], argsComma = [], args, delim, arg, nameLoop, expressions, isSemiColonSeperated, expressionContainsNamed, index = i, s = input.charAt(i), name, value, important = false;
if (s !== '.' && s !== '#') { return }
@@ -810,31 +834,60 @@ less.Parser = function Parser(env) {
c = $('>');
}
if ($('(')) {
+ expressions = [];
while (arg = $(this.expression)) {
+ nameLoop = null;
value = arg;
- name = null;
// Variable
if (arg.value.length == 1) {
var val = arg.value[0];
if (val instanceof tree.Variable) {
if ($(':')) {
- if (value = $(this.expression)) {
- name = val.name;
- } else {
- throw new(Error)("Expected value");
+ if (expressions.length > 0) {
+ if (isSemiColonSeperated) {
+ error("Cannot mix ; and , as delimiter types");
+ }
+ expressionContainsNamed = true;
}
+ value = expect(this.expression);
+ nameLoop = (name = val.name);
}
}
}
-
- args.push({ name: name, value: value });
-
- if (! $(',')) { break }
+
+ expressions.push(value);
+
+ argsComma.push({ name: nameLoop, value: value });
+
+ if ($(',')) {
+ continue;
+ }
+
+ if ($(';') || isSemiColonSeperated) {
+
+ if (expressionContainsNamed) {
+ error("Cannot mix ; and , as delimiter types");
+ }
+
+ isSemiColonSeperated = true;
+
+ if (expressions.length > 1) {
+ value = new(tree.Value)(expressions);
+ }
+ argsSemiColon.push({ name: name, value: value });
+
+ name = null;
+ expressions = [];
+ expressionContainsNamed = false;
+ }
}
- if (! $(')')) throw new(Error)("Expected )");
+
+ expect(')');
}
+ args = isSemiColonSeperated ? argsSemiColon : argsComma;
+
if ($(this.important)) {
important = true;
}
@@ -868,7 +921,7 @@ less.Parser = function Parser(env) {
definition: function () {
var name, params = [], match, ruleset, param, value, cond, variadic = false;
if ((input.charAt(i) !== '.' && input.charAt(i) !== '#') ||
- peek(/^[^{]*(;|})/)) return;
+ peek(/^[^{]*\}/)) return;
save();
@@ -876,8 +929,10 @@ less.Parser = function Parser(env) {
name = match[1];
do {
+ $(this.comment);
if (input.charAt(i) === '.' && $(/^\.{3}/)) {
variadic = true;
+ params.push({ variadic: true });
break;
} else if (param = $(this.entities.variable) || $(this.entities.literal)
|| $(this.entities.keyword)) {
@@ -899,7 +954,7 @@ less.Parser = function Parser(env) {
} else {
break;
}
- } while ($(','))
+ } while ($(',') || $(';'))
// .mixincall("@{a}");
// looks a bit like a mixin definition.. so we have to be nice and restore
@@ -907,6 +962,8 @@ less.Parser = function Parser(env) {
furthest = i;
restore();
}
+
+ $(this.comment);
if ($(/^when/)) { // Guard
cond = expect(this.conditions, 'expected condition');
@@ -929,7 +986,7 @@ less.Parser = function Parser(env) {
//
entity: function () {
return $(this.entities.literal) || $(this.entities.variable) || $(this.entities.url) ||
- $(this.entities.call) || $(this.entities.keyword) || $(this.entities.javascript) ||
+ $(this.entities.call) || $(this.entities.keyword) ||$(this.entities.javascript) ||
$(this.comment);
},
@@ -975,11 +1032,16 @@ less.Parser = function Parser(env) {
c = $(this.combinator);
e = $(/^(?:\d+\.\d+|\d+)%/) || $(/^(?:[.#]?|:*)(?:[\w-]|[^\x00-\x9f]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/) ||
- $('*') || $('&') || $(this.attribute) || $(/^\([^)@]+\)/) || $(/^[\.#](?=@)/) || $(this.entities.variableCurly);
+ $('*') || $('&') || $(this.attribute) || $(/^\([^()@]+\)/) || $(/^[\.#](?=@)/) || $(this.entities.variableCurly);
if (! e) {
- if ($('(') && (v = ($(this.entities.variableCurly) || $(this.entities.variable))) && $(')')) {
- e = new(tree.Paren)(v);
+ if ($('(')) {
+ if ((v = ($(this.entities.variableCurly) ||
+ $(this.entities.variable) ||
+ $(this.selector))) &&
+ $(')')) {
+ e = new(tree.Paren)(v);
+ }
}
}
@@ -998,7 +1060,7 @@ less.Parser = function Parser(env) {
combinator: function () {
var match, c = input.charAt(i);
- if (c === '>' || c === '+' || c === '~') {
+ if (c === '>' || c === '+' || c === '~' || c === '|') {
i++;
while (input.charAt(i).match(/\s/)) { i++ }
return new(tree.Combinator)(c);
@@ -1030,14 +1092,11 @@ less.Parser = function Parser(env) {
while (e = $(this.element)) {
c = input.charAt(i);
elements.push(e)
- if (c === '{' || c === '}' || c === ';' || c === ',') { break }
+ if (c === '{' || c === '}' || c === ';' || c === ',' || c === ')') { break }
}
if (elements.length > 0) { return new(tree.Selector)(elements) }
},
- tag: function () {
- return $(/^[A-Za-z][A-Za-z-]*[0-9]?/) || $('*');
- },
attribute: function () {
var attr = '', key, val, op;
@@ -1140,7 +1199,7 @@ less.Parser = function Parser(env) {
if (dir && (path = $(this.entities.quoted) || $(this.entities.url))) {
features = $(this.mediaFeatures);
if ($(';')) {
- return new(tree.Import)(path, imports, features, (dir[1] === 'once'), index);
+ return new(tree.Import)(path, imports, features, (dir[1] === 'once'), index, env.rootpath);
}
}
@@ -1214,7 +1273,7 @@ less.Parser = function Parser(env) {
//
directive: function () {
var name, value, rules, identifier, e, nodes, nonVendorSpecificName,
- hasBlock, hasIdentifier;
+ hasBlock, hasIdentifier, hasExpression;
if (input.charAt(i) !== '@') return;
@@ -1225,6 +1284,8 @@ less.Parser = function Parser(env) {
save();
name = $(/^@[a-z-]+/);
+
+ if (!name) return;
nonVendorSpecificName = name;
if (name.charAt(1) == '-' && name.indexOf('-', 2) > 0) {
@@ -1261,6 +1322,9 @@ less.Parser = function Parser(env) {
hasBlock = true;
hasIdentifier = true;
break;
+ case "@namespace":
+ hasExpression = true;
+ break;
}
if (hasIdentifier) {
@@ -1273,8 +1337,12 @@ less.Parser = function Parser(env) {
return new(tree.Directive)(name, rules);
}
} else {
- if ((value = $(this.entity)) && $(';')) {
- return new(tree.Directive)(name, value);
+ if ((value = hasExpression ? $(this.expression) : $(this.entity)) && $(';')) {
+ var directive = new(tree.Directive)(name, value);
+ if (env.dumpLineNumbers) {
+ directive.debugInfo = getDebugInfo(i, input, env);
+ }
+ return directive;
}
}
@@ -1332,7 +1400,7 @@ less.Parser = function Parser(env) {
multiplication: function () {
var m, a, op, operation;
if (m = $(this.operand)) {
- while (!peek(/^\/\*/) && (op = ($('/') || $('*'))) && (a = $(this.operand))) {
+ while (!peek(/^\/[*\/]/) && (op = ($('/') || $('*'))) && (a = $(this.operand))) {
operation = new(tree.Operation)(op, [operation || m, a]);
}
return operation || m;
@@ -1432,12 +1500,20 @@ if (less.mode === 'browser' || less.mode === 'rhino') {
// We pass `true` as 3rd argument, to force the reload of the import.
// This is so we can get the syntax tree as opposed to just the CSS output,
// as we need this to evaluate the current stylesheet.
- // __ Now using the hack of passing a ref to top parser's content cache in the 1st arg. __
- loadStyleSheet({ href: path, title: path, type: env.mime, contents: env.contents }, function (e) {
+ loadStyleSheet({
+ href: path,
+ title: path,
+ type: env.mime,
+ contents: env.contents,
+ files: env.files,
+ rootpath: env.rootpath,
+ entryPath: env.entryPath,
+ relativeUrls: env.relativeUrls },
+ function (e, root, data, sheet, _, path) {
if (e && typeof(env.errback) === "function") {
env.errback.call(null, path, paths, callback, env);
} else {
- callback.apply(null, arguments);
+ callback.call(null, e, root, path);
}
}, true);
};
View
2  WinLess/node_modules/less/lib/less/rhino.js
@@ -17,7 +17,7 @@ function loadStyleSheet(sheet, callback, reload, remaining) {
return error(e, sheetName);
}
try {
- callback(e, root, sheet, { local: false, lastModified: 0, remaining: remaining });
+ callback(e, root, input, sheet, { local: false, lastModified: 0, remaining: remaining }, sheetName);
} catch(e) {
error(e, sheetName);
}
View
4 WinLess/node_modules/less/lib/less/tree.js
@@ -23,7 +23,9 @@ tree.debugInfo.asComment = function(ctx) {
};
tree.debugInfo.asMediaQuery = function(ctx) {
- return '@media -sass-debug-info{filename{font-family:"' + ctx.debugInfo.fileName + '";}line{font-family:"' + ctx.debugInfo.lineNumber + '";}}\n';
+ return '@media -sass-debug-info{filename{font-family:' +
+ ('file://' + ctx.debugInfo.fileName).replace(/[\/:.]/g, '\\$&') +
+ '}line{font-family:\\00003' + ctx.debugInfo.lineNumber + '}}\n';
};
tree.find = function (obj, fun) {
View
4 WinLess/node_modules/less/lib/less/tree/dimension.js
@@ -30,7 +30,6 @@ tree.Dimension.prototype = {
this.unit || other.unit);
},
- // TODO: Perform unit conversion before comparing
compare: function (other) {
if (other instanceof tree.Dimension) {
if (other.value > this.value) {
@@ -38,6 +37,9 @@ tree.Dimension.prototype = {
} else if (other.value < this.value) {
return 1;
} else {
+ if (other.unit && this.unit !== other.unit) {
+ return -1;
+ }
return 0;
}
} else {
View
3  WinLess/node_modules/less/lib/less/tree/element.js
@@ -41,7 +41,8 @@ tree.Combinator.prototype.toCSS = function (env) {
':' : ' :',
'+' : env.compress ? '+' : ' + ',
'~' : env.compress ? '~' : ' ~ ',
- '>' : env.compress ? '>' : ' > '
+ '>' : env.compress ? '>' : ' > ',
+ '|' : env.compress ? '|' : ' | '
}[this.value];
};
View
23 WinLess/node_modules/less/lib/less/tree/import.js
@@ -11,22 +11,23 @@
// `import,push`, we also pass it a callback, which it'll call once
// the file has been fetched, and parsed.
//
-tree.Import = function (path, imports, features, once, index) {
+tree.Import = function (path, imports, features, once, index, rootpath) {
var that = this;
this.once = once;
this.index = index;
this._path = path;
this.features = features && new(tree.Value)(features);
-
+ this.rootpath = rootpath;
+
// The '.less' extension is optional
if (path instanceof tree.Quoted) {
- this.path = /\.(le?|c)ss(\?.*)?$/.test(path.value) ? path.value : path.value + '.less';
+ this.path = /(\.[a-z]*$)|([\?;].*)$/.test(path.value) ? path.value : path.value + '.less';
} else {
this.path = path.value.value || path.value;
}
- this.css = /css(\?.*)?$/.test(this.path);
+ this.css = /css([\?;].*)?$/.test(this.path);
// Only pre-compile .less files
if (! this.css) {
@@ -52,6 +53,10 @@ tree.Import.prototype = {
var features = this.features ? ' ' + this.features.toCSS(env) : '';
if (this.css) {
+ // Add the base path if the import is relative
+ if (typeof this._path.value === "string" && !/^(?:[a-z-]+:|\/)/.test(this._path.value)) {
+ this._path.value = this.rootpath + this._path.value;
+ }
return "@import " + this._path.toCSS() + features + ';\n';
} else {
return "";
@@ -67,14 +72,8 @@ tree.Import.prototype = {
} else {
ruleset = new(tree.Ruleset)([], this.root.rules.slice(0));
- for (var i = 0; i < ruleset.rules.length; i++) {
- if (ruleset.rules[i] instanceof tree.Import) {
- Array.prototype
- .splice
- .apply(ruleset.rules,
- [i, 1].concat(ruleset.rules[i].eval(env)));
- }
- }
+ ruleset.evalImports(env);
+
return this.features ? new(tree.Media)(ruleset.rules, this.features.value) : ruleset.rules;
}
}
View
8 WinLess/node_modules/less/lib/less/tree/media.js
@@ -22,10 +22,6 @@ tree.Media.prototype = {
env.mediaPath = [];
}
- var blockIndex = env.mediaBlocks.length;
- env.mediaPath.push(this);
- env.mediaBlocks.push(this);
-
var media = new(tree.Media)([], []);
if(this.debugInfo) {
this.ruleset.debugInfo = this.debugInfo;
@@ -33,11 +29,13 @@ tree.Media.prototype = {
}
media.features = this.features.eval(env);
+ env.mediaPath.push(media);
+ env.mediaBlocks.push(media);
+
env.frames.unshift(this.ruleset);
media.ruleset = this.ruleset.eval(env);
env.frames.shift();
- env.mediaBlocks[blockIndex] = media;
env.mediaPath.pop();
return env.mediaPath.length === 0 ? media.evalTop(env) :
View
174 WinLess/node_modules/less/lib/less/tree/mixin.js
@@ -10,40 +10,66 @@ tree.mixin.Call = function (elements, args, index, filename, important) {
};
tree.mixin.Call.prototype = {
eval: function (env) {
- var mixins, args, rules = [], match = false;
+ var mixins, mixin, args, rules = [], match = false, i, m, f, isRecursive, isOneFound;
- for (var i = 0; i < env.frames.length; i++) {
+ args = this.arguments && this.arguments.map(function (a) {
+ return { name: a.name, value: a.value.eval(env) };
+ });
+
+ for (i = 0; i < env.frames.length; i++) {
if ((mixins = env.frames[i].find(this.selector)).length > 0) {
- args = this.arguments && this.arguments.map(function (a) {
- return { name: a.name, value: a.value.eval(env) };
- });
- for (var m = 0; m < mixins.length; m++) {
- if (mixins[m].match(args, env)) {
- try {
- Array.prototype.push.apply(
- rules, mixins[m].eval(env, this.arguments, this.important).rules);
- match = true;
- } catch (e) {
- throw { message: e.message, index: this.index, filename: this.filename, stack: e.stack };
+ isOneFound = true;
+ for (m = 0; m < mixins.length; m++) {
+ mixin = mixins[m];
+ isRecursive = false;
+ for(f = 0; f < env.frames.length; f++) {
+ if ((!(mixin instanceof tree.mixin.Definition)) && mixin === (env.frames[f].originalRuleset || env.frames[f])) {
+ isRecursive = true;
+ break;
}
}
+ if (isRecursive) {
+ continue;
+ }
+ if (mixin.matchArgs(args, env)) {
+ if (!mixin.matchCondition || mixin.matchCondition(args, env)) {
+ try {
+ Array.prototype.push.apply(
+ rules, mixin.eval(env, args, this.important).rules);
+ } catch (e) {
+ throw { message: e.message, index: this.index, filename: this.filename, stack: e.stack };
+ }
+ }
+ match = true;
+ }
}
if (match) {
return rules;
- } else {
- throw { type: 'Runtime',
- message: 'No matching definition was found for `' +
- this.selector.toCSS().trim() + '(' +
- this.arguments.map(function (a) {
- return a.toCSS();
- }).join(', ') + ")`",
- index: this.index, filename: this.filename };
}
}
}
- throw { type: 'Name',
+ if (isOneFound) {
+ throw { type: 'Runtime',
+ message: 'No matching definition was found for `' +
+ this.selector.toCSS().trim() + '(' +
+ (args ? args.map(function (a) {
+ var argValue = "";
+ if (a.name) {
+ argValue += a.name + ":";
+ }
+ if (a.value.toCSS) {
+ argValue += a.value.toCSS();
+ } else {
+ argValue += "???";
+ }
+ return argValue;
+ }).join(', ') : "") + ")`",
+ index: this.index, filename: this.filename };
+ } else {
+ throw { type: 'Name',
message: this.selector.toCSS().trim() + " is undefined",
index: this.index, filename: this.filename };
+ }
}
};
@@ -70,54 +96,98 @@ tree.mixin.Definition.prototype = {
find: function () { return this.parent.find.apply(this, arguments) },
rulesets: function () { return this.parent.rulesets.apply(this) },
- evalParams: function (env, args) {
- var frame = new(tree.Ruleset)(null, []), varargs, arg;
+ evalParams: function (env, mixinEnv, args, evaldArguments) {
+ var frame = new(tree.Ruleset)(null, []), varargs, arg, params = this.params.slice(0), i, j, val, name, isNamedFound, argIndex;
+
+ if (args) {
+ args = args.slice(0);
- for (var i = 0, val, name; i < this.params.length; i++) {
- arg = args && args[i]
-
- if (arg && arg.name) {
- frame.rules.unshift(new(tree.Rule)(arg.name, arg.value.eval(env)));
- args.splice(i, 1);
- i--;
- continue;
+ for(i = 0; i < args.length; i++) {
+ arg = args[i];
+ if (name = (arg && arg.name)) {
+ isNamedFound = false;
+ for(j = 0; j < params.length; j++) {
+ if (!evaldArguments[j] && name === params[j].name) {
+ evaldArguments[j] = arg.value.eval(env);
+ frame.rules.unshift(new(tree.Rule)(name, arg.value.eval(env)));
+ isNamedFound = true;
+ break;
+ }
+ }
+ if (isNamedFound) {
+ args.splice(i, 1);
+ i--;
+ continue;
+ } else {
+ throw { type: 'Runtime', message: "Named argument for " + this.name +
+ ' ' + args[i].name + ' not found' };
+ }
+ }
}
-
- if (name = this.params[i].name) {
- if (this.params[i].variadic && args) {
+ }
+ argIndex = 0;
+ for (i = 0; i < params.length; i++) {
+ if (evaldArguments[i]) continue;
+
+ arg = args && args[argIndex];
+
+ if (name = params[i].name) {
+ if (params[i].variadic && args) {
varargs = [];
- for (var j = i; j < args.length; j++) {
+ for (j = argIndex; j < args.length; j++) {
varargs.push(args[j].value.eval(env));
}
frame.rules.unshift(new(tree.Rule)(name, new(tree.Expression)(varargs).eval(env)));
- } else if (val = (arg && arg.value) || this.params[i].value) {
- frame.rules.unshift(new(tree.Rule)(name, val.eval(env)));
} else {
- throw { type: 'Runtime', message: "wrong number of arguments for " + this.name +
+ val = arg && arg.value;
+ if (val) {
+ val = val.eval(env);
+ } else if (params[i].value) {
+ val = params[i].value.eval(mixinEnv);
+ } else {
+ throw { type: 'Runtime', message: "wrong number of arguments for " + this.name +
' (' + args.length + ' for ' + this.arity + ')' };
+ }
+
+ frame.rules.unshift(new(tree.Rule)(name, val));
+ evaldArguments[i] = val;
+ }
+ }
+
+ if (params[i].variadic && args) {
+ for (j = argIndex; j < args.length; j++) {
+ evaldArguments[j] = args[j].value.eval(env);
}
}
+ argIndex++;
}
+
return frame;
},
eval: function (env, args, important) {
- var frame = this.evalParams(env, args), context, _arguments = [], rules, start;
+ var _arguments = [],
+ mixinFrames = this.frames.concat(env.frames),
+ frame = this.evalParams(env, {frames: mixinFrames}, args, _arguments),
+ context, rules, start, ruleset;
- for (var i = 0; i < Math.max(this.params.length, args && args.length); i++) {
- _arguments.push((args[i] && args[i].value) || this.params[i].value);
- }
frame.rules.unshift(new(tree.Rule)('@arguments', new(tree.Expression)(_arguments).eval(env)));
rules = important ?
- this.rules.map(function (r) {
- return new(tree.Rule)(r.name, r.value, '!important', r.index);
- }) : this.rules.slice(0);
+ this.parent.makeImportant.apply(this).rules : this.rules.slice(0);
- return new(tree.Ruleset)(null, rules).eval({
- frames: [this, frame].concat(this.frames, env.frames)
+ ruleset = new(tree.Ruleset)(null, rules).eval({
+ frames: [this, frame].concat(mixinFrames)
});
+ ruleset.originalRuleset = this;
+ return ruleset;
},
- match: function (args, env) {
+ matchCondition: function (args, env) {
+ if (this.condition && !this.condition.eval({
+ frames: [this.evalParams(env, {frames: this.frames.concat(env.frames)}, args, [])].concat(env.frames)
+ })) { return false }
+ return true;
+ },
+ matchArgs: function (args, env) {
var argsLength = (args && args.length) || 0, len, frame;
if (! this.variadic) {
@@ -126,14 +196,10 @@ tree.mixin.Definition.prototype = {
if ((this.required > 0) && (argsLength > this.params.length)) { return false }
}
- if (this.condition && !this.condition.eval({
- frames: [this.evalParams(env, args)].concat(env.frames)
- })) { return false }
-
len = Math.min(argsLength, this.arity);
for (var i = 0; i < len; i++) {
- if (!this.params[i].name) {
+ if (!this.params[i].name && !this.params[i].variadic) {
if (args[i].value.eval(env).toCSS() != this.params[i].value.eval(env).toCSS()) {
return false;
}
View
5 WinLess/node_modules/less/lib/less/tree/operation.js
@@ -17,6 +17,11 @@ tree.Operation.prototype.eval = function (env) {
message: "Can't substract or divide a color from a number" };
}
}
+ if (!a.operate) {
+ throw { name: "OperationError",
+ message: "Operation on an invalid type" };
+ }
+
return a.operate(this.op, b);
};
View
2  WinLess/node_modules/less/lib/less/tree/quoted.js
@@ -20,7 +20,7 @@ tree.Quoted.prototype = {
return new(tree.JavaScript)(exp, that.index, true).eval(env).value;
}).replace(/@\{([\w-]+)\}/g, function (_, name) {
var v = new(tree.Variable)('@' + name, that.index).eval(env);
- return ('value' in v) ? v.value : v.toCSS();
+ return (v instanceof tree.Quoted) ? v.value : v.toCSS();
});
return new(tree.Quoted)(this.quote + value + this.quote, value, this.escaped, this.index);
},
View
7 WinLess/node_modules/less/lib/less/tree/rule.js