cssstyle 1.1.1 → 1.3.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 (527) hide show
  1. package/.eslintignore +4 -0
  2. package/.eslintrc.js +55 -0
  3. package/.travis.yml +17 -0
  4. package/AUTHORS +31 -0
  5. package/{MIT-LICENSE.txt → LICENSE} +0 -0
  6. package/README.md +7 -19
  7. package/coverage/clover.xml +2150 -0
  8. package/coverage/coverage-final.json +86 -0
  9. package/coverage/lcov-report/base.css +224 -0
  10. package/coverage/lcov-report/block-navigation.js +79 -0
  11. package/coverage/lcov-report/index.html +123 -0
  12. package/coverage/lcov-report/lib/CSSStyleDeclaration.js.html +834 -0
  13. package/coverage/lcov-report/lib/allExtraProperties.js.html +813 -0
  14. package/coverage/lcov-report/lib/allProperties.js.html +1560 -0
  15. package/coverage/lcov-report/lib/constants.js.html +87 -0
  16. package/coverage/lcov-report/lib/index.html +149 -0
  17. package/coverage/lcov-report/lib/parsers.js.html +2193 -0
  18. package/coverage/lcov-report/lib/properties/azimuth.js.html +270 -0
  19. package/coverage/lcov-report/lib/properties/background.js.html +126 -0
  20. package/coverage/lcov-report/lib/properties/backgroundAttachment.js.html +141 -0
  21. package/coverage/lcov-report/lib/properties/backgroundColor.js.html +177 -0
  22. package/coverage/lcov-report/lib/properties/backgroundImage.js.html +165 -0
  23. package/coverage/lcov-report/lib/properties/backgroundPosition.js.html +243 -0
  24. package/coverage/lcov-report/lib/properties/backgroundRepeat.js.html +165 -0
  25. package/coverage/lcov-report/lib/properties/border.js.html +168 -0
  26. package/coverage/lcov-report/lib/properties/borderBottom.js.html +120 -0
  27. package/coverage/lcov-report/lib/properties/borderBottomColor.js.html +117 -0
  28. package/coverage/lcov-report/lib/properties/borderBottomStyle.js.html +132 -0
  29. package/coverage/lcov-report/lib/properties/borderBottomWidth.js.html +117 -0
  30. package/coverage/lcov-report/lib/properties/borderCollapse.js.html +147 -0
  31. package/coverage/lcov-report/lib/properties/borderColor.js.html +159 -0
  32. package/coverage/lcov-report/lib/properties/borderLeft.js.html +120 -0
  33. package/coverage/lcov-report/lib/properties/borderLeftColor.js.html +117 -0
  34. package/coverage/lcov-report/lib/properties/borderLeftStyle.js.html +132 -0
  35. package/coverage/lcov-report/lib/properties/borderLeftWidth.js.html +117 -0
  36. package/coverage/lcov-report/lib/properties/borderRight.js.html +120 -0
  37. package/coverage/lcov-report/lib/properties/borderRightColor.js.html +117 -0
  38. package/coverage/lcov-report/lib/properties/borderRightStyle.js.html +132 -0
  39. package/coverage/lcov-report/lib/properties/borderRightWidth.js.html +117 -0
  40. package/coverage/lcov-report/lib/properties/borderSpacing.js.html +192 -0
  41. package/coverage/lcov-report/lib/properties/borderStyle.js.html +183 -0
  42. package/coverage/lcov-report/lib/properties/borderTop.js.html +120 -0
  43. package/coverage/lcov-report/lib/properties/borderTopColor.js.html +117 -0
  44. package/coverage/lcov-report/lib/properties/borderTopStyle.js.html +132 -0
  45. package/coverage/lcov-report/lib/properties/borderTopWidth.js.html +120 -0
  46. package/coverage/lcov-report/lib/properties/borderWidth.js.html +207 -0
  47. package/coverage/lcov-report/lib/properties/bottom.js.html +111 -0
  48. package/coverage/lcov-report/lib/properties/clear.js.html +117 -0
  49. package/coverage/lcov-report/lib/properties/clip.js.html +210 -0
  50. package/coverage/lcov-report/lib/properties/color.js.html +111 -0
  51. package/coverage/lcov-report/lib/properties/cssFloat.js.html +105 -0
  52. package/coverage/lcov-report/lib/properties/flex.js.html +204 -0
  53. package/coverage/lcov-report/lib/properties/flexBasis.js.html +153 -0
  54. package/coverage/lcov-report/lib/properties/flexGrow.js.html +126 -0
  55. package/coverage/lcov-report/lib/properties/flexShrink.js.html +126 -0
  56. package/coverage/lcov-report/lib/properties/float.js.html +105 -0
  57. package/coverage/lcov-report/lib/properties/floodColor.js.html +111 -0
  58. package/coverage/lcov-report/lib/properties/font.js.html +198 -0
  59. package/coverage/lcov-report/lib/properties/fontFamily.js.html +168 -0
  60. package/coverage/lcov-report/lib/properties/fontSize.js.html +183 -0
  61. package/coverage/lcov-report/lib/properties/fontStyle.js.html +123 -0
  62. package/coverage/lcov-report/lib/properties/fontVariant.js.html +123 -0
  63. package/coverage/lcov-report/lib/properties/fontWeight.js.html +168 -0
  64. package/coverage/lcov-report/lib/properties/height.js.html +141 -0
  65. package/coverage/lcov-report/lib/properties/index.html +1111 -0
  66. package/coverage/lcov-report/lib/properties/left.js.html +111 -0
  67. package/coverage/lcov-report/lib/properties/lightingColor.js.html +111 -0
  68. package/coverage/lcov-report/lib/properties/lineHeight.js.html +147 -0
  69. package/coverage/lcov-report/lib/properties/margin.js.html +273 -0
  70. package/coverage/lcov-report/lib/properties/marginBottom.js.html +108 -0
  71. package/coverage/lcov-report/lib/properties/marginLeft.js.html +108 -0
  72. package/coverage/lcov-report/lib/properties/marginRight.js.html +108 -0
  73. package/coverage/lcov-report/lib/properties/marginTop.js.html +108 -0
  74. package/coverage/lcov-report/lib/properties/opacity.js.html +111 -0
  75. package/coverage/lcov-report/lib/properties/outlineColor.js.html +111 -0
  76. package/coverage/lcov-report/lib/properties/padding.js.html +252 -0
  77. package/coverage/lcov-report/lib/properties/paddingBottom.js.html +108 -0
  78. package/coverage/lcov-report/lib/properties/paddingLeft.js.html +108 -0
  79. package/coverage/lcov-report/lib/properties/paddingRight.js.html +108 -0
  80. package/coverage/lcov-report/lib/properties/paddingTop.js.html +108 -0
  81. package/coverage/lcov-report/lib/properties/right.js.html +111 -0
  82. package/coverage/lcov-report/lib/properties/stopColor.js.html +111 -0
  83. package/coverage/lcov-report/lib/properties/textLineThroughColor.js.html +111 -0
  84. package/coverage/lcov-report/lib/properties/textOverlineColor.js.html +111 -0
  85. package/coverage/lcov-report/lib/properties/textUnderlineColor.js.html +111 -0
  86. package/coverage/lcov-report/lib/properties/top.js.html +111 -0
  87. package/coverage/lcov-report/lib/properties/webkitBorderAfterColor.js.html +111 -0
  88. package/coverage/lcov-report/lib/properties/webkitBorderBeforeColor.js.html +111 -0
  89. package/coverage/lcov-report/lib/properties/webkitBorderEndColor.js.html +111 -0
  90. package/coverage/lcov-report/lib/properties/webkitBorderStartColor.js.html +111 -0
  91. package/coverage/lcov-report/lib/properties/webkitColumnRuleColor.js.html +111 -0
  92. package/coverage/lcov-report/lib/properties/webkitMatchNearestMailBlockquoteColor.js.html +111 -0
  93. package/coverage/lcov-report/lib/properties/webkitTapHighlightColor.js.html +111 -0
  94. package/coverage/lcov-report/lib/properties/webkitTextEmphasisColor.js.html +111 -0
  95. package/coverage/lcov-report/lib/properties/webkitTextFillColor.js.html +111 -0
  96. package/coverage/lcov-report/lib/properties/webkitTextStrokeColor.js.html +111 -0
  97. package/coverage/lcov-report/lib/properties/width.js.html +141 -0
  98. package/coverage/lcov-report/lib/utils/getBasicPropertyDescriptor.js.html +111 -0
  99. package/coverage/lcov-report/lib/utils/index.html +97 -0
  100. package/coverage/lcov-report/prettify.css +1 -0
  101. package/coverage/lcov-report/prettify.js +2 -0
  102. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  103. package/coverage/lcov-report/sorter.js +170 -0
  104. package/coverage/lcov.info +3711 -0
  105. package/jest.config.js +10 -0
  106. package/lib/CSSStyleDeclaration.js +224 -202
  107. package/lib/CSSStyleDeclaration.test.js +521 -0
  108. package/lib/allExtraProperties.js +248 -0
  109. package/lib/allProperties.js +497 -0
  110. package/lib/constants.js +6 -0
  111. package/lib/implementedProperties.js +90 -0
  112. package/lib/named_colors.json +152 -0
  113. package/lib/parsers.js +572 -534
  114. package/lib/parsers.test.js +98 -0
  115. package/lib/properties/azimuth.js +59 -57
  116. package/lib/properties/background.js +9 -14
  117. package/lib/properties/backgroundAttachment.js +17 -15
  118. package/lib/properties/backgroundColor.js +24 -21
  119. package/lib/properties/backgroundImage.js +20 -17
  120. package/lib/properties/backgroundPosition.js +40 -38
  121. package/lib/properties/backgroundRepeat.js +20 -13
  122. package/lib/properties/border.js +20 -36
  123. package/lib/properties/borderBottom.js +7 -13
  124. package/lib/properties/borderBottomColor.js +11 -11
  125. package/lib/properties/borderBottomStyle.js +14 -14
  126. package/lib/properties/borderBottomWidth.js +11 -11
  127. package/lib/properties/borderCollapse.js +17 -16
  128. package/lib/properties/borderColor.js +17 -15
  129. package/lib/properties/borderLeft.js +7 -13
  130. package/lib/properties/borderLeftColor.js +11 -11
  131. package/lib/properties/borderLeftStyle.js +14 -14
  132. package/lib/properties/borderLeftWidth.js +11 -11
  133. package/lib/properties/borderRight.js +7 -13
  134. package/lib/properties/borderRightColor.js +11 -11
  135. package/lib/properties/borderRightStyle.js +14 -14
  136. package/lib/properties/borderRightWidth.js +11 -11
  137. package/lib/properties/borderSpacing.js +26 -30
  138. package/lib/properties/borderStyle.js +24 -13
  139. package/lib/properties/borderTop.js +7 -12
  140. package/lib/properties/borderTopColor.js +11 -11
  141. package/lib/properties/borderTopStyle.js +14 -14
  142. package/lib/properties/borderTopWidth.js +10 -10
  143. package/lib/properties/borderWidth.js +29 -30
  144. package/lib/properties/bottom.js +8 -8
  145. package/lib/properties/clear.js +9 -9
  146. package/lib/properties/clip.js +37 -39
  147. package/lib/properties/color.js +8 -8
  148. package/lib/properties/cssFloat.js +8 -8
  149. package/lib/properties/flex.js +45 -0
  150. package/lib/properties/flexBasis.js +28 -0
  151. package/lib/properties/flexGrow.js +19 -0
  152. package/lib/properties/flexShrink.js +19 -0
  153. package/lib/properties/float.js +12 -0
  154. package/lib/properties/floodColor.js +8 -8
  155. package/lib/properties/font.js +27 -24
  156. package/lib/properties/fontFamily.js +21 -21
  157. package/lib/properties/fontSize.js +26 -13
  158. package/lib/properties/fontStyle.js +10 -10
  159. package/lib/properties/fontVariant.js +9 -9
  160. package/lib/properties/fontWeight.js +25 -10
  161. package/lib/properties/height.js +15 -15
  162. package/lib/properties/left.js +8 -8
  163. package/lib/properties/lightingColor.js +8 -8
  164. package/lib/properties/lineHeight.js +16 -11
  165. package/lib/properties/margin.js +49 -40
  166. package/lib/properties/marginBottom.js +6 -6
  167. package/lib/properties/marginLeft.js +6 -6
  168. package/lib/properties/marginRight.js +6 -6
  169. package/lib/properties/marginTop.js +6 -6
  170. package/lib/properties/opacity.js +8 -8
  171. package/lib/properties/outlineColor.js +8 -8
  172. package/lib/properties/padding.js +42 -33
  173. package/lib/properties/paddingBottom.js +6 -6
  174. package/lib/properties/paddingLeft.js +6 -6
  175. package/lib/properties/paddingRight.js +6 -6
  176. package/lib/properties/paddingTop.js +6 -6
  177. package/lib/properties/right.js +8 -8
  178. package/lib/properties/stopColor.js +8 -8
  179. package/lib/properties/textLineThroughColor.js +8 -8
  180. package/lib/properties/textOverlineColor.js +8 -8
  181. package/lib/properties/textUnderlineColor.js +8 -8
  182. package/lib/properties/top.js +8 -8
  183. package/lib/properties/webkitBorderAfterColor.js +8 -8
  184. package/lib/properties/webkitBorderBeforeColor.js +8 -8
  185. package/lib/properties/webkitBorderEndColor.js +8 -8
  186. package/lib/properties/webkitBorderStartColor.js +8 -8
  187. package/lib/properties/webkitColumnRuleColor.js +8 -8
  188. package/lib/properties/webkitMatchNearestMailBlockquoteColor.js +8 -8
  189. package/lib/properties/webkitTapHighlightColor.js +8 -8
  190. package/lib/properties/webkitTextEmphasisColor.js +8 -8
  191. package/lib/properties/webkitTextFillColor.js +8 -8
  192. package/lib/properties/webkitTextStrokeColor.js +8 -8
  193. package/lib/properties/width.js +15 -15
  194. package/lib/properties.js +224 -4343
  195. package/lib/utils/getBasicPropertyDescriptor.js +14 -0
  196. package/package.json +34 -22
  197. package/scripts/download_latest_properties.js +88 -0
  198. package/scripts/generate_implemented_properties.js +61 -0
  199. package/scripts/generate_properties.js +107 -117
  200. package/lib/properties/alignContent.js +0 -12
  201. package/lib/properties/alignItems.js +0 -12
  202. package/lib/properties/alignmentBaseline.js +0 -12
  203. package/lib/properties/backgroundClip.js +0 -12
  204. package/lib/properties/backgroundOrigin.js +0 -12
  205. package/lib/properties/backgroundPositionX.js +0 -12
  206. package/lib/properties/backgroundPositionY.js +0 -12
  207. package/lib/properties/backgroundRepeatX.js +0 -12
  208. package/lib/properties/backgroundRepeatY.js +0 -12
  209. package/lib/properties/backgroundSize.js +0 -12
  210. package/lib/properties/baselineShift.js +0 -12
  211. package/lib/properties/borderBottomLeftRadius.js +0 -12
  212. package/lib/properties/borderBottomRightRadius.js +0 -12
  213. package/lib/properties/borderImage.js +0 -12
  214. package/lib/properties/borderImageOutset.js +0 -12
  215. package/lib/properties/borderImageRepeat.js +0 -12
  216. package/lib/properties/borderImageSlice.js +0 -12
  217. package/lib/properties/borderImageSource.js +0 -12
  218. package/lib/properties/borderImageWidth.js +0 -12
  219. package/lib/properties/borderRadius.js +0 -12
  220. package/lib/properties/borderTopLeftRadius.js +0 -12
  221. package/lib/properties/borderTopRightRadius.js +0 -12
  222. package/lib/properties/boxShadow.js +0 -12
  223. package/lib/properties/boxSizing.js +0 -12
  224. package/lib/properties/captionSide.js +0 -12
  225. package/lib/properties/colorInterpolation.js +0 -12
  226. package/lib/properties/colorInterpolationFilters.js +0 -12
  227. package/lib/properties/colorProfile.js +0 -12
  228. package/lib/properties/colorRendering.js +0 -12
  229. package/lib/properties/content.js +0 -12
  230. package/lib/properties/counterIncrement.js +0 -12
  231. package/lib/properties/counterReset.js +0 -12
  232. package/lib/properties/cue.js +0 -12
  233. package/lib/properties/cueAfter.js +0 -12
  234. package/lib/properties/cueBefore.js +0 -12
  235. package/lib/properties/cursor.js +0 -12
  236. package/lib/properties/direction.js +0 -12
  237. package/lib/properties/display.js +0 -12
  238. package/lib/properties/dominantBaseline.js +0 -12
  239. package/lib/properties/elevation.js +0 -12
  240. package/lib/properties/emptyCells.js +0 -12
  241. package/lib/properties/enableBackground.js +0 -12
  242. package/lib/properties/fill.js +0 -12
  243. package/lib/properties/fillOpacity.js +0 -12
  244. package/lib/properties/fillRule.js +0 -12
  245. package/lib/properties/filter.js +0 -12
  246. package/lib/properties/flexDirection.js +0 -12
  247. package/lib/properties/flexFlow.js +0 -12
  248. package/lib/properties/flexWrap.js +0 -12
  249. package/lib/properties/floodOpacity.js +0 -12
  250. package/lib/properties/fontSizeAdjust.js +0 -12
  251. package/lib/properties/fontStretch.js +0 -12
  252. package/lib/properties/glyphOrientationHorizontal.js +0 -12
  253. package/lib/properties/glyphOrientationVertical.js +0 -12
  254. package/lib/properties/imageRendering.js +0 -12
  255. package/lib/properties/justifyContent.js +0 -12
  256. package/lib/properties/kerning.js +0 -12
  257. package/lib/properties/letterSpacing.js +0 -12
  258. package/lib/properties/listStyle.js +0 -12
  259. package/lib/properties/listStyleImage.js +0 -12
  260. package/lib/properties/listStylePosition.js +0 -12
  261. package/lib/properties/listStyleType.js +0 -12
  262. package/lib/properties/marker.js +0 -12
  263. package/lib/properties/markerEnd.js +0 -12
  264. package/lib/properties/markerMid.js +0 -12
  265. package/lib/properties/markerOffset.js +0 -12
  266. package/lib/properties/markerStart.js +0 -12
  267. package/lib/properties/marks.js +0 -12
  268. package/lib/properties/mask.js +0 -12
  269. package/lib/properties/maxHeight.js +0 -12
  270. package/lib/properties/maxWidth.js +0 -12
  271. package/lib/properties/minHeight.js +0 -12
  272. package/lib/properties/minWidth.js +0 -12
  273. package/lib/properties/orphans.js +0 -12
  274. package/lib/properties/outline.js +0 -12
  275. package/lib/properties/outlineOffset.js +0 -12
  276. package/lib/properties/outlineStyle.js +0 -12
  277. package/lib/properties/outlineWidth.js +0 -12
  278. package/lib/properties/overflow.js +0 -12
  279. package/lib/properties/overflowX.js +0 -12
  280. package/lib/properties/overflowY.js +0 -12
  281. package/lib/properties/page.js +0 -12
  282. package/lib/properties/pageBreakAfter.js +0 -12
  283. package/lib/properties/pageBreakBefore.js +0 -12
  284. package/lib/properties/pageBreakInside.js +0 -12
  285. package/lib/properties/pause.js +0 -12
  286. package/lib/properties/pauseAfter.js +0 -12
  287. package/lib/properties/pauseBefore.js +0 -12
  288. package/lib/properties/pitch.js +0 -12
  289. package/lib/properties/pitchRange.js +0 -12
  290. package/lib/properties/playDuring.js +0 -12
  291. package/lib/properties/pointerEvents.js +0 -12
  292. package/lib/properties/position.js +0 -12
  293. package/lib/properties/quotes.js +0 -12
  294. package/lib/properties/resize.js +0 -12
  295. package/lib/properties/richness.js +0 -12
  296. package/lib/properties/shapeRendering.js +0 -12
  297. package/lib/properties/size.js +0 -12
  298. package/lib/properties/speak.js +0 -12
  299. package/lib/properties/speakHeader.js +0 -12
  300. package/lib/properties/speakNumeral.js +0 -12
  301. package/lib/properties/speakPunctuation.js +0 -12
  302. package/lib/properties/speechRate.js +0 -12
  303. package/lib/properties/src.js +0 -12
  304. package/lib/properties/stopOpacity.js +0 -12
  305. package/lib/properties/stress.js +0 -12
  306. package/lib/properties/stroke.js +0 -12
  307. package/lib/properties/strokeDasharray.js +0 -12
  308. package/lib/properties/strokeDashoffset.js +0 -12
  309. package/lib/properties/strokeLinecap.js +0 -12
  310. package/lib/properties/strokeLinejoin.js +0 -12
  311. package/lib/properties/strokeMiterlimit.js +0 -12
  312. package/lib/properties/strokeOpacity.js +0 -12
  313. package/lib/properties/strokeWidth.js +0 -12
  314. package/lib/properties/tableLayout.js +0 -12
  315. package/lib/properties/textAlign.js +0 -12
  316. package/lib/properties/textAnchor.js +0 -12
  317. package/lib/properties/textDecoration.js +0 -12
  318. package/lib/properties/textIndent.js +0 -12
  319. package/lib/properties/textLineThrough.js +0 -12
  320. package/lib/properties/textLineThroughMode.js +0 -12
  321. package/lib/properties/textLineThroughStyle.js +0 -12
  322. package/lib/properties/textLineThroughWidth.js +0 -12
  323. package/lib/properties/textOverflow.js +0 -12
  324. package/lib/properties/textOverline.js +0 -12
  325. package/lib/properties/textOverlineMode.js +0 -12
  326. package/lib/properties/textOverlineStyle.js +0 -12
  327. package/lib/properties/textOverlineWidth.js +0 -12
  328. package/lib/properties/textRendering.js +0 -12
  329. package/lib/properties/textShadow.js +0 -12
  330. package/lib/properties/textTransform.js +0 -12
  331. package/lib/properties/textUnderline.js +0 -12
  332. package/lib/properties/textUnderlineMode.js +0 -12
  333. package/lib/properties/textUnderlineStyle.js +0 -12
  334. package/lib/properties/textUnderlineWidth.js +0 -12
  335. package/lib/properties/transform.js +0 -12
  336. package/lib/properties/unicodeBidi.js +0 -12
  337. package/lib/properties/unicodeRange.js +0 -12
  338. package/lib/properties/vectorEffect.js +0 -12
  339. package/lib/properties/verticalAlign.js +0 -12
  340. package/lib/properties/visibility.js +0 -12
  341. package/lib/properties/voiceFamily.js +0 -12
  342. package/lib/properties/volume.js +0 -12
  343. package/lib/properties/webkitAnimation.js +0 -12
  344. package/lib/properties/webkitAnimationDelay.js +0 -12
  345. package/lib/properties/webkitAnimationDirection.js +0 -12
  346. package/lib/properties/webkitAnimationDuration.js +0 -12
  347. package/lib/properties/webkitAnimationFillMode.js +0 -12
  348. package/lib/properties/webkitAnimationIterationCount.js +0 -12
  349. package/lib/properties/webkitAnimationName.js +0 -12
  350. package/lib/properties/webkitAnimationPlayState.js +0 -12
  351. package/lib/properties/webkitAnimationTimingFunction.js +0 -12
  352. package/lib/properties/webkitAppearance.js +0 -12
  353. package/lib/properties/webkitAspectRatio.js +0 -12
  354. package/lib/properties/webkitBackfaceVisibility.js +0 -12
  355. package/lib/properties/webkitBackgroundClip.js +0 -12
  356. package/lib/properties/webkitBackgroundComposite.js +0 -12
  357. package/lib/properties/webkitBackgroundOrigin.js +0 -12
  358. package/lib/properties/webkitBackgroundSize.js +0 -12
  359. package/lib/properties/webkitBorderAfter.js +0 -12
  360. package/lib/properties/webkitBorderAfterStyle.js +0 -12
  361. package/lib/properties/webkitBorderAfterWidth.js +0 -12
  362. package/lib/properties/webkitBorderBefore.js +0 -12
  363. package/lib/properties/webkitBorderBeforeStyle.js +0 -12
  364. package/lib/properties/webkitBorderBeforeWidth.js +0 -12
  365. package/lib/properties/webkitBorderEnd.js +0 -12
  366. package/lib/properties/webkitBorderEndStyle.js +0 -12
  367. package/lib/properties/webkitBorderEndWidth.js +0 -12
  368. package/lib/properties/webkitBorderFit.js +0 -12
  369. package/lib/properties/webkitBorderHorizontalSpacing.js +0 -12
  370. package/lib/properties/webkitBorderImage.js +0 -12
  371. package/lib/properties/webkitBorderRadius.js +0 -12
  372. package/lib/properties/webkitBorderStart.js +0 -12
  373. package/lib/properties/webkitBorderStartStyle.js +0 -12
  374. package/lib/properties/webkitBorderStartWidth.js +0 -12
  375. package/lib/properties/webkitBorderVerticalSpacing.js +0 -12
  376. package/lib/properties/webkitBoxAlign.js +0 -12
  377. package/lib/properties/webkitBoxDirection.js +0 -12
  378. package/lib/properties/webkitBoxFlex.js +0 -12
  379. package/lib/properties/webkitBoxFlexGroup.js +0 -12
  380. package/lib/properties/webkitBoxLines.js +0 -12
  381. package/lib/properties/webkitBoxOrdinalGroup.js +0 -12
  382. package/lib/properties/webkitBoxOrient.js +0 -12
  383. package/lib/properties/webkitBoxPack.js +0 -12
  384. package/lib/properties/webkitBoxReflect.js +0 -12
  385. package/lib/properties/webkitBoxShadow.js +0 -12
  386. package/lib/properties/webkitColorCorrection.js +0 -12
  387. package/lib/properties/webkitColumnAxis.js +0 -12
  388. package/lib/properties/webkitColumnBreakAfter.js +0 -12
  389. package/lib/properties/webkitColumnBreakBefore.js +0 -12
  390. package/lib/properties/webkitColumnBreakInside.js +0 -12
  391. package/lib/properties/webkitColumnCount.js +0 -12
  392. package/lib/properties/webkitColumnGap.js +0 -12
  393. package/lib/properties/webkitColumnRule.js +0 -12
  394. package/lib/properties/webkitColumnRuleStyle.js +0 -12
  395. package/lib/properties/webkitColumnRuleWidth.js +0 -12
  396. package/lib/properties/webkitColumnSpan.js +0 -12
  397. package/lib/properties/webkitColumnWidth.js +0 -12
  398. package/lib/properties/webkitColumns.js +0 -12
  399. package/lib/properties/webkitFilter.js +0 -12
  400. package/lib/properties/webkitFlexAlign.js +0 -12
  401. package/lib/properties/webkitFlexDirection.js +0 -12
  402. package/lib/properties/webkitFlexFlow.js +0 -12
  403. package/lib/properties/webkitFlexItemAlign.js +0 -12
  404. package/lib/properties/webkitFlexLinePack.js +0 -12
  405. package/lib/properties/webkitFlexOrder.js +0 -12
  406. package/lib/properties/webkitFlexPack.js +0 -12
  407. package/lib/properties/webkitFlexWrap.js +0 -12
  408. package/lib/properties/webkitFlowFrom.js +0 -12
  409. package/lib/properties/webkitFlowInto.js +0 -12
  410. package/lib/properties/webkitFontFeatureSettings.js +0 -12
  411. package/lib/properties/webkitFontKerning.js +0 -12
  412. package/lib/properties/webkitFontSizeDelta.js +0 -12
  413. package/lib/properties/webkitFontSmoothing.js +0 -12
  414. package/lib/properties/webkitFontVariantLigatures.js +0 -12
  415. package/lib/properties/webkitHighlight.js +0 -12
  416. package/lib/properties/webkitHyphenateCharacter.js +0 -12
  417. package/lib/properties/webkitHyphenateLimitAfter.js +0 -12
  418. package/lib/properties/webkitHyphenateLimitBefore.js +0 -12
  419. package/lib/properties/webkitHyphenateLimitLines.js +0 -12
  420. package/lib/properties/webkitHyphens.js +0 -12
  421. package/lib/properties/webkitLineAlign.js +0 -12
  422. package/lib/properties/webkitLineBoxContain.js +0 -12
  423. package/lib/properties/webkitLineBreak.js +0 -12
  424. package/lib/properties/webkitLineClamp.js +0 -12
  425. package/lib/properties/webkitLineGrid.js +0 -12
  426. package/lib/properties/webkitLineSnap.js +0 -12
  427. package/lib/properties/webkitLocale.js +0 -12
  428. package/lib/properties/webkitLogicalHeight.js +0 -12
  429. package/lib/properties/webkitLogicalWidth.js +0 -12
  430. package/lib/properties/webkitMarginAfter.js +0 -12
  431. package/lib/properties/webkitMarginAfterCollapse.js +0 -12
  432. package/lib/properties/webkitMarginBefore.js +0 -12
  433. package/lib/properties/webkitMarginBeforeCollapse.js +0 -12
  434. package/lib/properties/webkitMarginBottomCollapse.js +0 -12
  435. package/lib/properties/webkitMarginCollapse.js +0 -12
  436. package/lib/properties/webkitMarginEnd.js +0 -12
  437. package/lib/properties/webkitMarginStart.js +0 -12
  438. package/lib/properties/webkitMarginTopCollapse.js +0 -12
  439. package/lib/properties/webkitMarquee.js +0 -12
  440. package/lib/properties/webkitMarqueeDirection.js +0 -12
  441. package/lib/properties/webkitMarqueeIncrement.js +0 -12
  442. package/lib/properties/webkitMarqueeRepetition.js +0 -12
  443. package/lib/properties/webkitMarqueeSpeed.js +0 -12
  444. package/lib/properties/webkitMarqueeStyle.js +0 -12
  445. package/lib/properties/webkitMask.js +0 -12
  446. package/lib/properties/webkitMaskAttachment.js +0 -12
  447. package/lib/properties/webkitMaskBoxImage.js +0 -12
  448. package/lib/properties/webkitMaskBoxImageOutset.js +0 -12
  449. package/lib/properties/webkitMaskBoxImageRepeat.js +0 -12
  450. package/lib/properties/webkitMaskBoxImageSlice.js +0 -12
  451. package/lib/properties/webkitMaskBoxImageSource.js +0 -12
  452. package/lib/properties/webkitMaskBoxImageWidth.js +0 -12
  453. package/lib/properties/webkitMaskClip.js +0 -12
  454. package/lib/properties/webkitMaskComposite.js +0 -12
  455. package/lib/properties/webkitMaskImage.js +0 -12
  456. package/lib/properties/webkitMaskOrigin.js +0 -12
  457. package/lib/properties/webkitMaskPosition.js +0 -12
  458. package/lib/properties/webkitMaskPositionX.js +0 -12
  459. package/lib/properties/webkitMaskPositionY.js +0 -12
  460. package/lib/properties/webkitMaskRepeat.js +0 -12
  461. package/lib/properties/webkitMaskRepeatX.js +0 -12
  462. package/lib/properties/webkitMaskRepeatY.js +0 -12
  463. package/lib/properties/webkitMaskSize.js +0 -12
  464. package/lib/properties/webkitMaxLogicalHeight.js +0 -12
  465. package/lib/properties/webkitMaxLogicalWidth.js +0 -12
  466. package/lib/properties/webkitMinLogicalHeight.js +0 -12
  467. package/lib/properties/webkitMinLogicalWidth.js +0 -12
  468. package/lib/properties/webkitNbspMode.js +0 -12
  469. package/lib/properties/webkitOverflowScrolling.js +0 -12
  470. package/lib/properties/webkitPaddingAfter.js +0 -12
  471. package/lib/properties/webkitPaddingBefore.js +0 -12
  472. package/lib/properties/webkitPaddingEnd.js +0 -12
  473. package/lib/properties/webkitPaddingStart.js +0 -12
  474. package/lib/properties/webkitPerspective.js +0 -12
  475. package/lib/properties/webkitPerspectiveOrigin.js +0 -12
  476. package/lib/properties/webkitPerspectiveOriginX.js +0 -12
  477. package/lib/properties/webkitPerspectiveOriginY.js +0 -12
  478. package/lib/properties/webkitPrintColorAdjust.js +0 -12
  479. package/lib/properties/webkitRegionBreakAfter.js +0 -12
  480. package/lib/properties/webkitRegionBreakBefore.js +0 -12
  481. package/lib/properties/webkitRegionBreakInside.js +0 -12
  482. package/lib/properties/webkitRegionOverflow.js +0 -12
  483. package/lib/properties/webkitRtlOrdering.js +0 -12
  484. package/lib/properties/webkitSvgShadow.js +0 -12
  485. package/lib/properties/webkitTextCombine.js +0 -12
  486. package/lib/properties/webkitTextDecorationsInEffect.js +0 -12
  487. package/lib/properties/webkitTextEmphasis.js +0 -12
  488. package/lib/properties/webkitTextEmphasisPosition.js +0 -12
  489. package/lib/properties/webkitTextEmphasisStyle.js +0 -12
  490. package/lib/properties/webkitTextOrientation.js +0 -12
  491. package/lib/properties/webkitTextSecurity.js +0 -12
  492. package/lib/properties/webkitTextSizeAdjust.js +0 -12
  493. package/lib/properties/webkitTextStroke.js +0 -12
  494. package/lib/properties/webkitTextStrokeWidth.js +0 -12
  495. package/lib/properties/webkitTransform.js +0 -12
  496. package/lib/properties/webkitTransformOrigin.js +0 -12
  497. package/lib/properties/webkitTransformOriginX.js +0 -12
  498. package/lib/properties/webkitTransformOriginY.js +0 -12
  499. package/lib/properties/webkitTransformOriginZ.js +0 -12
  500. package/lib/properties/webkitTransformStyle.js +0 -12
  501. package/lib/properties/webkitTransition.js +0 -12
  502. package/lib/properties/webkitTransitionDelay.js +0 -12
  503. package/lib/properties/webkitTransitionDuration.js +0 -12
  504. package/lib/properties/webkitTransitionProperty.js +0 -12
  505. package/lib/properties/webkitTransitionTimingFunction.js +0 -12
  506. package/lib/properties/webkitUserDrag.js +0 -12
  507. package/lib/properties/webkitUserModify.js +0 -12
  508. package/lib/properties/webkitUserSelect.js +0 -12
  509. package/lib/properties/webkitWrap.js +0 -12
  510. package/lib/properties/webkitWrapFlow.js +0 -12
  511. package/lib/properties/webkitWrapMargin.js +0 -12
  512. package/lib/properties/webkitWrapPadding.js +0 -12
  513. package/lib/properties/webkitWrapShapeInside.js +0 -12
  514. package/lib/properties/webkitWrapShapeOutside.js +0 -12
  515. package/lib/properties/webkitWrapThrough.js +0 -12
  516. package/lib/properties/webkitWritingMode.js +0 -12
  517. package/lib/properties/whiteSpace.js +0 -12
  518. package/lib/properties/widows.js +0 -12
  519. package/lib/properties/wordBreak.js +0 -12
  520. package/lib/properties/wordSpacing.js +0 -12
  521. package/lib/properties/wordWrap.js +0 -12
  522. package/lib/properties/writingMode.js +0 -12
  523. package/lib/properties/zIndex.js +0 -12
  524. package/lib/properties/zoom.js +0 -12
  525. package/lib/validProperties.js +0 -410
  526. package/scripts/generate_valid_properties.js +0 -62
  527. package/tests/tests.js +0 -450
package/lib/parsers.js CHANGED
@@ -4,117 +4,116 @@
4
4
  ********************************************************************/
5
5
  'use strict';
6
6
 
7
+ const namedColors = require('./named_colors.json');
8
+
7
9
  exports.TYPES = {
8
- INTEGER: 1,
9
- NUMBER: 2,
10
- LENGTH: 3,
11
- PERCENT: 4,
12
- URL: 5,
13
- COLOR: 6,
14
- STRING: 7,
15
- ANGLE: 8,
16
- KEYWORD: 9,
17
- NULL_OR_EMPTY_STR: 10
10
+ INTEGER: 1,
11
+ NUMBER: 2,
12
+ LENGTH: 3,
13
+ PERCENT: 4,
14
+ URL: 5,
15
+ COLOR: 6,
16
+ STRING: 7,
17
+ ANGLE: 8,
18
+ KEYWORD: 9,
19
+ NULL_OR_EMPTY_STR: 10,
18
20
  };
19
21
 
20
- /*jslint regexp: true*/
21
22
  // rough regular expressions
22
- var integerRegEx = /^[\-+]?[0-9]+$/;
23
- var numberRegEx = /^[\-+]?[0-9]*\.[0-9]+$/;
24
- var lengthRegEx = /^(0|[\-+]?[0-9]*\.?[0-9]+(in|cm|em|mm|pt|pc|px|ex|rem|vh|vw))$/;
25
- var percentRegEx = /^[\-+]?[0-9]*\.?[0-9]+%$/;
26
- var urlRegEx = /^url\(\s*([^\)]*)\s*\)$/;
27
- var stringRegEx = /^(\"[^\"]*\"|\'[^\']*\')$/;
28
- var colorRegEx1 = /^#[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]([0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])?$/;
29
- var colorRegEx2 = /^rgb\(([^\)]*)\)$/;
30
- var colorRegEx3 = /^rgba\(([^\)]*)\)$/;
31
- var angleRegEx = /^([\-+]?[0-9]*\.?[0-9]+)(deg|grad|rad)$/;
32
- /*jslint regexp: false*/
23
+ var integerRegEx = /^[-+]?[0-9]+$/;
24
+ var numberRegEx = /^[-+]?[0-9]*\.?[0-9]+$/;
25
+ var lengthRegEx = /^(0|[-+]?[0-9]*\.?[0-9]+(in|cm|em|mm|pt|pc|px|ex|rem|vh|vw))$/;
26
+ var percentRegEx = /^[-+]?[0-9]*\.?[0-9]+%$/;
27
+ var urlRegEx = /^url\(\s*([^)]*)\s*\)$/;
28
+ var stringRegEx = /^("[^"]*"|'[^']*')$/;
29
+ var colorRegEx1 = /^#([0-9a-fA-F]{3,4}){1,2}$/;
30
+ var colorRegEx2 = /^rgb\(([^)]*)\)$/;
31
+ var colorRegEx3 = /^rgba\(([^)]*)\)$/;
32
+ var colorRegEx4 = /^hsla?\(\s*(-?\d+|-?\d*.\d+)\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)%\s*(,\s*(-?\d+|-?\d*.\d+)\s*)?\)/;
33
+ var angleRegEx = /^([-+]?[0-9]*\.?[0-9]+)(deg|grad|rad)$/;
33
34
 
34
35
  // This will return one of the above types based on the passed in string
35
36
  exports.valueType = function valueType(val) {
36
- if (val === '' || val === null) {
37
- return exports.TYPES.NULL_OR_EMPTY_STR;
37
+ if (val === '' || val === null) {
38
+ return exports.TYPES.NULL_OR_EMPTY_STR;
39
+ }
40
+ if (typeof val === 'number') {
41
+ val = val.toString();
42
+ }
43
+
44
+ if (typeof val !== 'string') {
45
+ return undefined;
46
+ }
47
+
48
+ if (integerRegEx.test(val)) {
49
+ return exports.TYPES.INTEGER;
50
+ }
51
+ if (numberRegEx.test(val)) {
52
+ return exports.TYPES.NUMBER;
53
+ }
54
+ if (lengthRegEx.test(val)) {
55
+ return exports.TYPES.LENGTH;
56
+ }
57
+ if (percentRegEx.test(val)) {
58
+ return exports.TYPES.PERCENT;
59
+ }
60
+ if (urlRegEx.test(val)) {
61
+ return exports.TYPES.URL;
62
+ }
63
+ if (stringRegEx.test(val)) {
64
+ return exports.TYPES.STRING;
65
+ }
66
+ if (angleRegEx.test(val)) {
67
+ return exports.TYPES.ANGLE;
68
+ }
69
+ if (colorRegEx1.test(val)) {
70
+ return exports.TYPES.COLOR;
71
+ }
72
+ var res = colorRegEx2.exec(val);
73
+ var parts;
74
+ if (res !== null) {
75
+ parts = res[1].split(/\s*,\s*/);
76
+ if (parts.length !== 3) {
77
+ return undefined;
78
+ }
79
+ if (
80
+ parts.every(percentRegEx.test.bind(percentRegEx)) ||
81
+ parts.every(integerRegEx.test.bind(integerRegEx))
82
+ ) {
83
+ return exports.TYPES.COLOR;
38
84
  }
39
- if (typeof val === 'number') {
40
- val = val.toString();
85
+ return undefined;
86
+ }
87
+ res = colorRegEx3.exec(val);
88
+ if (res !== null) {
89
+ parts = res[1].split(/\s*,\s*/);
90
+ if (parts.length !== 4) {
91
+ return undefined;
92
+ }
93
+ if (
94
+ parts.slice(0, 3).every(percentRegEx.test.bind(percentRegEx)) ||
95
+ parts.every(integerRegEx.test.bind(integerRegEx))
96
+ ) {
97
+ if (numberRegEx.test(parts[3])) {
98
+ return exports.TYPES.COLOR;
99
+ }
41
100
  }
101
+ return undefined;
102
+ }
42
103
 
43
- if (typeof val !== 'string') {
44
- return undefined;
45
- }
104
+ if (colorRegEx4.test(val)) {
105
+ return exports.TYPES.COLOR;
106
+ }
46
107
 
47
- if (integerRegEx.test(val)) {
48
- return exports.TYPES.INTEGER;
49
- }
50
- if (numberRegEx.test(val)) {
51
- return exports.TYPES.NUMBER;
52
- }
53
- if (lengthRegEx.test(val)) {
54
- return exports.TYPES.LENGTH;
55
- }
56
- if (percentRegEx.test(val)) {
57
- return exports.TYPES.PERCENT;
58
- }
59
- if (urlRegEx.test(val)) {
60
- return exports.TYPES.URL;
61
- }
62
- if (stringRegEx.test(val)) {
63
- return exports.TYPES.STRING;
64
- }
65
- if (angleRegEx.test(val)) {
66
- return exports.TYPES.ANGLE;
67
- }
68
- if (colorRegEx1.test(val)) {
69
- return exports.TYPES.COLOR;
70
- }
71
- var res = colorRegEx2.exec(val);
72
- var parts;
73
- if (res !== null) {
74
- parts = res[1].split(/\s*,\s*/);
75
- if (parts.length !== 3) {
76
- return undefined;
77
- }
78
- if (parts.every(percentRegEx.test.bind(percentRegEx)) || parts.every(integerRegEx.test.bind(integerRegEx))) {
79
- return exports.TYPES.COLOR;
80
- }
81
- return undefined;
82
- }
83
- res = colorRegEx3.exec(val);
84
- if (res !== null) {
85
- parts = res[1].split(/\s*,\s*/);
86
- if (parts.length !== 4) {
87
- return undefined;
88
- }
89
- if (parts.slice(0, 3).every(percentRegEx.test.bind(percentRegEx)) || parts.every(integerRegEx.test.bind(integerRegEx))) {
90
- if (numberRegEx.test(parts[3])) {
91
- return exports.TYPES.COLOR;
92
- }
93
- }
94
- return undefined;
95
- }
108
+ // could still be a color, one of the standard keyword colors
109
+ val = val.toLowerCase();
96
110
 
97
- // could still be a color, one of the standard keyword colors
98
- val = val.toLowerCase();
99
- switch (val) {
100
- case 'maroon':
101
- case 'red':
102
- case 'orange':
103
- case 'yellow':
104
- case 'olive':
105
- case 'purple':
106
- case 'fuchsia':
107
- case 'white':
108
- case 'lime':
109
- case 'green':
110
- case 'navy':
111
- case 'blue':
112
- case 'aqua':
113
- case 'teal':
114
- case 'black':
115
- case 'silver':
116
- case 'gray':
117
- // the following are deprecated in CSS3
111
+ if (namedColors.includes(val)) {
112
+ return exports.TYPES.COLOR;
113
+ }
114
+
115
+ switch (val) {
116
+ // the following are deprecated in CSS3
118
117
  case 'activeborder':
119
118
  case 'activecaption':
120
119
  case 'appworkspace':
@@ -143,320 +142,359 @@ exports.valueType = function valueType(val) {
143
142
  case 'window':
144
143
  case 'windowframe':
145
144
  case 'windowtext':
146
- return exports.TYPES.COLOR;
145
+ return exports.TYPES.COLOR;
147
146
  default:
148
- return exports.TYPES.KEYWORD;
149
- }
147
+ return exports.TYPES.KEYWORD;
148
+ }
150
149
  };
151
150
 
152
151
  exports.parseInteger = function parseInteger(val) {
153
- var type = exports.valueType(val);
154
- if (type === exports.TYPES.NULL_OR_EMPTY_STR) {
155
- return val;
156
- }
157
- if (type !== exports.TYPES.INTEGER) {
158
- return undefined;
159
- }
160
- return String(parseInt(val, 10));
152
+ var type = exports.valueType(val);
153
+ if (type === exports.TYPES.NULL_OR_EMPTY_STR) {
154
+ return val;
155
+ }
156
+ if (type !== exports.TYPES.INTEGER) {
157
+ return undefined;
158
+ }
159
+ return String(parseInt(val, 10));
161
160
  };
162
161
 
163
162
  exports.parseNumber = function parseNumber(val) {
164
- var type = exports.valueType(val);
165
- if (type === exports.TYPES.NULL_OR_EMPTY_STR) {
166
- return val;
167
- }
168
- if (type !== exports.TYPES.NUMBER && type !== exports.TYPES.INTEGER) {
169
- return undefined;
170
- }
171
- return String(parseFloat(val));
163
+ var type = exports.valueType(val);
164
+ if (type === exports.TYPES.NULL_OR_EMPTY_STR) {
165
+ return val;
166
+ }
167
+ if (type !== exports.TYPES.NUMBER && type !== exports.TYPES.INTEGER) {
168
+ return undefined;
169
+ }
170
+ return String(parseFloat(val));
172
171
  };
173
172
 
174
173
  exports.parseLength = function parseLength(val) {
175
- if (val === 0 || val === '0') {
176
- return '0px';
177
- }
178
- var type = exports.valueType(val);
179
- if (type === exports.TYPES.NULL_OR_EMPTY_STR) {
180
- return val;
181
- }
182
- if (type !== exports.TYPES.LENGTH) {
183
- return undefined;
184
- }
174
+ if (val === 0 || val === '0') {
175
+ return '0px';
176
+ }
177
+ var type = exports.valueType(val);
178
+ if (type === exports.TYPES.NULL_OR_EMPTY_STR) {
185
179
  return val;
180
+ }
181
+ if (type !== exports.TYPES.LENGTH) {
182
+ return undefined;
183
+ }
184
+ return val;
186
185
  };
187
186
 
188
187
  exports.parsePercent = function parsePercent(val) {
189
- if (val === 0 || val === '0') {
190
- return '0%';
191
- }
192
- var type = exports.valueType(val);
193
- if (type === exports.TYPES.NULL_OR_EMPTY_STR) {
194
- return val;
195
- }
196
- if (type !== exports.TYPES.PERCENT) {
197
- return undefined;
198
- }
188
+ if (val === 0 || val === '0') {
189
+ return '0%';
190
+ }
191
+ var type = exports.valueType(val);
192
+ if (type === exports.TYPES.NULL_OR_EMPTY_STR) {
199
193
  return val;
194
+ }
195
+ if (type !== exports.TYPES.PERCENT) {
196
+ return undefined;
197
+ }
198
+ return val;
200
199
  };
201
200
 
202
201
  // either a length or a percent
203
202
  exports.parseMeasurement = function parseMeasurement(val) {
204
- var length = exports.parseLength(val);
205
- if (length !== undefined) {
206
- return length;
207
- }
208
- return exports.parsePercent(val);
203
+ var length = exports.parseLength(val);
204
+ if (length !== undefined) {
205
+ return length;
206
+ }
207
+ return exports.parsePercent(val);
209
208
  };
210
209
 
211
210
  exports.parseUrl = function parseUrl(val) {
212
- var type = exports.valueType(val);
213
- if (type === exports.TYPES.NULL_OR_EMPTY_STR) {
214
- return val;
215
- }
216
- var res = urlRegEx.exec(val);
217
- // does it match the regex?
218
- if (!res) {
219
- return undefined;
220
- }
221
- var str = res[1];
222
- // if it starts with single or double quotes, does it end with the same?
223
- if ((str[0] === '"' || str[0] === "'") && str[0] !== str[str.length - 1]) {
211
+ var type = exports.valueType(val);
212
+ if (type === exports.TYPES.NULL_OR_EMPTY_STR) {
213
+ return val;
214
+ }
215
+ var res = urlRegEx.exec(val);
216
+ // does it match the regex?
217
+ if (!res) {
218
+ return undefined;
219
+ }
220
+ var str = res[1];
221
+ // if it starts with single or double quotes, does it end with the same?
222
+ if ((str[0] === '"' || str[0] === "'") && str[0] !== str[str.length - 1]) {
223
+ return undefined;
224
+ }
225
+ if (str[0] === '"' || str[0] === "'") {
226
+ str = str.substr(1, str.length - 2);
227
+ }
228
+
229
+ var i;
230
+ for (i = 0; i < str.length; i++) {
231
+ switch (str[i]) {
232
+ case '(':
233
+ case ')':
234
+ case ' ':
235
+ case '\t':
236
+ case '\n':
237
+ case "'":
238
+ case '"':
224
239
  return undefined;
240
+ case '\\':
241
+ i++;
242
+ break;
225
243
  }
226
- if (str[0] === '"' || str[0] === "'") {
227
- str = str.substr(1, str.length - 2);
228
- }
229
-
230
- var i;
231
- for (i = 0; i < str.length; i++) {
232
- switch (str[i]) {
233
- case '(':
234
- case ')':
235
- case ' ':
236
- case '\t':
237
- case '\n':
238
- case "'":
239
- case '"':
240
- return undefined;
241
- case '\\':
242
- i++;
243
- break;
244
- }
245
- }
244
+ }
246
245
 
247
- return 'url(' + str + ')';
246
+ return 'url(' + str + ')';
248
247
  };
249
248
 
250
249
  exports.parseString = function parseString(val) {
251
- var type = exports.valueType(val);
252
- if (type === exports.TYPES.NULL_OR_EMPTY_STR) {
253
- return val;
254
- }
255
- if (type !== exports.TYPES.STRING) {
250
+ var type = exports.valueType(val);
251
+ if (type === exports.TYPES.NULL_OR_EMPTY_STR) {
252
+ return val;
253
+ }
254
+ if (type !== exports.TYPES.STRING) {
255
+ return undefined;
256
+ }
257
+ var i;
258
+ for (i = 1; i < val.length - 1; i++) {
259
+ switch (val[i]) {
260
+ case val[0]:
256
261
  return undefined;
257
- }
258
- var i;
259
- for (i = 1; i < val.length - 1; i++) {
260
- switch (val[i]) {
261
- case val[0]:
262
- return undefined;
263
- case '\\':
264
- i++;
265
- while (i < val.length - 1 && /[0-9A-Fa-f]/.test(val[i])) {
266
- i++;
267
- }
268
- break;
262
+ case '\\':
263
+ i++;
264
+ while (i < val.length - 1 && /[0-9A-Fa-f]/.test(val[i])) {
265
+ i++;
269
266
  }
267
+ break;
270
268
  }
271
- if (i >= val.length) {
272
- return undefined;
273
- }
274
- return val;
269
+ }
270
+ if (i >= val.length) {
271
+ return undefined;
272
+ }
273
+ return val;
275
274
  };
276
275
 
277
276
  exports.parseColor = function parseColor(val) {
278
- var type = exports.valueType(val);
279
- if (type === exports.TYPES.NULL_OR_EMPTY_STR) {
280
- return val;
281
- }
282
- var red, green, blue, alpha = 1;
283
- var parts;
284
- var res = colorRegEx1.exec(val);
285
- // is it #aaa or #ababab
286
- if (res) {
287
- var hex = val.substr(1);
288
- if (hex.length === 3) {
289
- hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
290
- }
291
- red = parseInt(hex.substr(0, 2), 16);
292
- green = parseInt(hex.substr(2, 2), 16);
293
- blue = parseInt(hex.substr(4, 2), 16);
294
- return 'rgb(' + red + ', ' + green + ', ' + blue + ')';
295
- }
296
-
297
- res = colorRegEx2.exec(val);
298
- if (res) {
299
- parts = res[1].split(/\s*,\s*/);
300
- if (parts.length !== 3) {
301
- return undefined;
302
- }
303
- if (parts.every(percentRegEx.test.bind(percentRegEx))) {
304
- red = Math.floor(parseFloat(parts[0].slice(0, -1)) * 255 / 100);
305
- green = Math.floor(parseFloat(parts[1].slice(0, -1)) * 255 / 100);
306
- blue = Math.floor(parseFloat(parts[2].slice(0, -1)) * 255 / 100);
307
- } else if (parts.every(integerRegEx.test.bind(integerRegEx))) {
308
- red = parseInt(parts[0], 10);
309
- green = parseInt(parts[1], 10);
310
- blue = parseInt(parts[2], 10);
311
- } else {
312
- return undefined;
313
- }
314
- red = Math.min(255, Math.max(0, red));
315
- green = Math.min(255, Math.max(0, green));
316
- blue = Math.min(255, Math.max(0, blue));
317
- return 'rgb(' + red + ', ' + green + ', ' + blue + ')';
318
- }
319
-
320
- res = colorRegEx3.exec(val);
321
- if (res) {
322
- parts = res[1].split(/\s*,\s*/);
323
- if (parts.length !== 4) {
324
- return undefined;
325
- }
326
- if (parts.slice(0, 3).every(percentRegEx.test.bind(percentRegEx))) {
327
- red = Math.floor(parseFloat(parts[0].slice(0, -1)) * 255 / 100);
328
- green = Math.floor(parseFloat(parts[1].slice(0, -1)) * 255 / 100);
329
- blue = Math.floor(parseFloat(parts[2].slice(0, -1)) * 255 / 100);
330
- alpha = parseFloat(parts[3]);
331
- } else if (parts.slice(0, 3).every(integerRegEx.test.bind(integerRegEx))) {
332
- red = parseInt(parts[0], 10);
333
- green = parseInt(parts[1], 10);
334
- blue = parseInt(parts[2], 10);
335
- alpha = parseFloat(parts[3]);
336
- } else {
337
- return undefined;
338
- }
339
- if (isNaN(alpha)) {
340
- alpha = 1;
341
- }
342
- red = Math.min(255, Math.max(0, red));
343
- green = Math.min(255, Math.max(0, green));
344
- blue = Math.min(255, Math.max(0, blue));
345
- alpha = Math.min(1, Math.max(0, alpha));
346
- if (alpha === 1) {
347
- return 'rgb(' + red + ', ' + green + ', ' + blue + ')';
348
- }
349
- return 'rgba(' + red + ', ' + green + ', ' + blue + ', ' + alpha + ')';
350
- }
351
-
352
- if (type === exports.TYPES.COLOR) {
353
- return val;
354
- }
355
- return undefined;
277
+ var type = exports.valueType(val);
278
+ if (type === exports.TYPES.NULL_OR_EMPTY_STR) {
279
+ return val;
280
+ }
281
+ var red,
282
+ green,
283
+ blue,
284
+ hue,
285
+ saturation,
286
+ lightness,
287
+ alpha = 1;
288
+ var parts;
289
+ var res = colorRegEx1.exec(val);
290
+ // is it #aaa, #ababab, #aaaa, #abababaa
291
+ if (res) {
292
+ var defaultHex = val.substr(1);
293
+ var hex = val.substr(1);
294
+ if (hex.length === 3 || hex.length === 4) {
295
+ hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
296
+
297
+ if (defaultHex.length === 4) {
298
+ hex = hex + defaultHex[3] + defaultHex[3];
299
+ }
300
+ }
301
+ red = parseInt(hex.substr(0, 2), 16);
302
+ green = parseInt(hex.substr(2, 2), 16);
303
+ blue = parseInt(hex.substr(4, 2), 16);
304
+ if (hex.length === 8) {
305
+ var hexAlpha = hex.substr(6, 2);
306
+ var hexAlphaToRgbaAlpha = Number((parseInt(hexAlpha, 16) / 255).toFixed(3));
307
+
308
+ return 'rgba(' + red + ', ' + green + ', ' + blue + ', ' + hexAlphaToRgbaAlpha + ')';
309
+ }
310
+ return 'rgb(' + red + ', ' + green + ', ' + blue + ')';
311
+ }
312
+
313
+ res = colorRegEx2.exec(val);
314
+ if (res) {
315
+ parts = res[1].split(/\s*,\s*/);
316
+ if (parts.length !== 3) {
317
+ return undefined;
318
+ }
319
+ if (parts.every(percentRegEx.test.bind(percentRegEx))) {
320
+ red = Math.floor((parseFloat(parts[0].slice(0, -1)) * 255) / 100);
321
+ green = Math.floor((parseFloat(parts[1].slice(0, -1)) * 255) / 100);
322
+ blue = Math.floor((parseFloat(parts[2].slice(0, -1)) * 255) / 100);
323
+ } else if (parts.every(integerRegEx.test.bind(integerRegEx))) {
324
+ red = parseInt(parts[0], 10);
325
+ green = parseInt(parts[1], 10);
326
+ blue = parseInt(parts[2], 10);
327
+ } else {
328
+ return undefined;
329
+ }
330
+ red = Math.min(255, Math.max(0, red));
331
+ green = Math.min(255, Math.max(0, green));
332
+ blue = Math.min(255, Math.max(0, blue));
333
+ return 'rgb(' + red + ', ' + green + ', ' + blue + ')';
334
+ }
335
+
336
+ res = colorRegEx3.exec(val);
337
+ if (res) {
338
+ parts = res[1].split(/\s*,\s*/);
339
+ if (parts.length !== 4) {
340
+ return undefined;
341
+ }
342
+ if (parts.slice(0, 3).every(percentRegEx.test.bind(percentRegEx))) {
343
+ red = Math.floor((parseFloat(parts[0].slice(0, -1)) * 255) / 100);
344
+ green = Math.floor((parseFloat(parts[1].slice(0, -1)) * 255) / 100);
345
+ blue = Math.floor((parseFloat(parts[2].slice(0, -1)) * 255) / 100);
346
+ alpha = parseFloat(parts[3]);
347
+ } else if (parts.slice(0, 3).every(integerRegEx.test.bind(integerRegEx))) {
348
+ red = parseInt(parts[0], 10);
349
+ green = parseInt(parts[1], 10);
350
+ blue = parseInt(parts[2], 10);
351
+ alpha = parseFloat(parts[3]);
352
+ } else {
353
+ return undefined;
354
+ }
355
+ if (isNaN(alpha)) {
356
+ alpha = 1;
357
+ }
358
+ red = Math.min(255, Math.max(0, red));
359
+ green = Math.min(255, Math.max(0, green));
360
+ blue = Math.min(255, Math.max(0, blue));
361
+ alpha = Math.min(1, Math.max(0, alpha));
362
+ if (alpha === 1) {
363
+ return 'rgb(' + red + ', ' + green + ', ' + blue + ')';
364
+ }
365
+ return 'rgba(' + red + ', ' + green + ', ' + blue + ', ' + alpha + ')';
366
+ }
367
+
368
+ res = colorRegEx4.exec(val);
369
+ if (res) {
370
+ const [, _hue, _saturation, _lightness, _alphaString = ''] = res;
371
+ const _alpha = parseFloat(_alphaString.replace(',', '').trim());
372
+ if (!_hue || !_saturation || !_lightness) {
373
+ return undefined;
374
+ }
375
+ hue = parseFloat(_hue);
376
+ saturation = parseInt(_saturation, 10);
377
+ lightness = parseInt(_lightness, 10);
378
+ if (_alpha && numberRegEx.test(_alpha)) {
379
+ alpha = parseFloat(_alpha);
380
+ }
381
+ if (!_alphaString || alpha === 1) {
382
+ return 'hsl(' + hue + ', ' + saturation + '%, ' + lightness + '%)';
383
+ }
384
+ return 'hsla(' + hue + ', ' + saturation + '%, ' + lightness + '%, ' + alpha + ')';
385
+ }
386
+
387
+ if (type === exports.TYPES.COLOR) {
388
+ return val;
389
+ }
390
+ return undefined;
356
391
  };
357
392
 
358
393
  exports.parseAngle = function parseAngle(val) {
359
- var type = exports.valueType(val);
360
- if (type === exports.TYPES.NULL_OR_EMPTY_STR) {
361
- return val;
362
- }
363
- if (type !== exports.TYPES.ANGLE) {
364
- return undefined;
365
- }
366
- var res = angleRegEx.exec(val);
367
- var flt = parseFloat(res[1]);
368
- if (res[2] === 'rad') {
369
- flt *= 180 / Math.PI;
370
- } else if (res[2] === 'grad') {
371
- flt *= 360 / 400;
372
- }
373
-
374
- while (flt < 0) {
375
- flt += 360;
376
- }
377
- while (flt > 360) {
378
- flt -= 360;
379
- }
380
- return flt + 'deg';
394
+ var type = exports.valueType(val);
395
+ if (type === exports.TYPES.NULL_OR_EMPTY_STR) {
396
+ return val;
397
+ }
398
+ if (type !== exports.TYPES.ANGLE) {
399
+ return undefined;
400
+ }
401
+ var res = angleRegEx.exec(val);
402
+ var flt = parseFloat(res[1]);
403
+ if (res[2] === 'rad') {
404
+ flt *= 180 / Math.PI;
405
+ } else if (res[2] === 'grad') {
406
+ flt *= 360 / 400;
407
+ }
408
+
409
+ while (flt < 0) {
410
+ flt += 360;
411
+ }
412
+ while (flt > 360) {
413
+ flt -= 360;
414
+ }
415
+ return flt + 'deg';
381
416
  };
382
417
 
383
418
  exports.parseKeyword = function parseKeyword(val, valid_keywords) {
384
- var type = exports.valueType(val);
385
- if (type === exports.TYPES.NULL_OR_EMPTY_STR) {
386
- return val;
387
- }
388
- if (type !== exports.TYPES.KEYWORD) {
389
- return undefined;
390
- }
391
- val = val.toString().toLowerCase();
392
- var i;
393
- for (i = 0; i < valid_keywords.length; i++) {
394
- if (valid_keywords[i].toLowerCase() === val) {
395
- return valid_keywords[i];
396
- }
397
- }
419
+ var type = exports.valueType(val);
420
+ if (type === exports.TYPES.NULL_OR_EMPTY_STR) {
421
+ return val;
422
+ }
423
+ if (type !== exports.TYPES.KEYWORD) {
398
424
  return undefined;
425
+ }
426
+ val = val.toString().toLowerCase();
427
+ var i;
428
+ for (i = 0; i < valid_keywords.length; i++) {
429
+ if (valid_keywords[i].toLowerCase() === val) {
430
+ return valid_keywords[i];
431
+ }
432
+ }
433
+ return undefined;
399
434
  };
400
435
 
401
436
  // utility to translate from border-width to borderWidth
402
- var dashedToCamelCase = function (dashed) {
403
- var i;
404
- var camel = '';
405
- var nextCap = false;
406
- for (i = 0; i < dashed.length; i++) {
407
- if (dashed[i] !== '-') {
408
- camel += nextCap ? dashed[i].toUpperCase() : dashed[i];
409
- nextCap = false;
410
- } else {
411
- nextCap = true;
412
- }
413
- }
414
- return camel;
437
+ var dashedToCamelCase = function(dashed) {
438
+ var i;
439
+ var camel = '';
440
+ var nextCap = false;
441
+ for (i = 0; i < dashed.length; i++) {
442
+ if (dashed[i] !== '-') {
443
+ camel += nextCap ? dashed[i].toUpperCase() : dashed[i];
444
+ nextCap = false;
445
+ } else {
446
+ nextCap = true;
447
+ }
448
+ }
449
+ return camel;
415
450
  };
416
451
  exports.dashedToCamelCase = dashedToCamelCase;
417
452
 
418
453
  var is_space = /\s/;
419
- var opening_deliminators = ['"', '\'', '('];
420
- var closing_deliminators = ['"', '\'', ')'];
454
+ var opening_deliminators = ['"', "'", '('];
455
+ var closing_deliminators = ['"', "'", ')'];
421
456
  // this splits on whitespace, but keeps quoted and parened parts together
422
- var getParts = function (str) {
423
- var deliminator_stack = [];
424
- var length = str.length;
425
- var i;
426
- var parts = [];
427
- var current_part = '';
428
- var opening_index;
429
- var closing_index;
430
- for (i = 0; i < length; i++) {
431
- opening_index = opening_deliminators.indexOf(str[i]);
432
- closing_index = closing_deliminators.indexOf(str[i]);
433
- if (is_space.test(str[i])) {
434
- if (deliminator_stack.length === 0) {
435
- if (current_part !== '') {
436
- parts.push(current_part);
437
- }
438
- current_part = '';
439
- } else {
440
- current_part += str[i];
441
- }
442
- } else {
443
- if (str[i] === '\\') {
444
- i++;
445
- current_part += str[i];
446
- } else {
447
- current_part += str[i];
448
- if (closing_index !== -1 && closing_index === deliminator_stack[deliminator_stack.length - 1]) {
449
- deliminator_stack.pop();
450
- } else if (opening_index !== -1) {
451
- deliminator_stack.push(opening_index);
452
- }
453
- }
454
- }
455
- }
456
- if (current_part !== '') {
457
- parts.push(current_part);
458
- }
459
- return parts;
457
+ var getParts = function(str) {
458
+ var deliminator_stack = [];
459
+ var length = str.length;
460
+ var i;
461
+ var parts = [];
462
+ var current_part = '';
463
+ var opening_index;
464
+ var closing_index;
465
+ for (i = 0; i < length; i++) {
466
+ opening_index = opening_deliminators.indexOf(str[i]);
467
+ closing_index = closing_deliminators.indexOf(str[i]);
468
+ if (is_space.test(str[i])) {
469
+ if (deliminator_stack.length === 0) {
470
+ if (current_part !== '') {
471
+ parts.push(current_part);
472
+ }
473
+ current_part = '';
474
+ } else {
475
+ current_part += str[i];
476
+ }
477
+ } else {
478
+ if (str[i] === '\\') {
479
+ i++;
480
+ current_part += str[i];
481
+ } else {
482
+ current_part += str[i];
483
+ if (
484
+ closing_index !== -1 &&
485
+ closing_index === deliminator_stack[deliminator_stack.length - 1]
486
+ ) {
487
+ deliminator_stack.pop();
488
+ } else if (opening_index !== -1) {
489
+ deliminator_stack.push(opening_index);
490
+ }
491
+ }
492
+ }
493
+ }
494
+ if (current_part !== '') {
495
+ parts.push(current_part);
496
+ }
497
+ return parts;
460
498
  };
461
499
 
462
500
  /*
@@ -466,93 +504,96 @@ var getParts = function (str) {
466
504
  * on them
467
505
  */
468
506
  exports.shorthandParser = function parse(v, shorthand_for) {
469
- var obj = {};
470
- var type = exports.valueType(v);
471
- if (type === exports.TYPES.NULL_OR_EMPTY_STR) {
472
- Object.keys(shorthand_for).forEach(function (property) {
473
- obj[property] = '';
474
- });
475
- return obj;
476
- }
477
-
478
- if (typeof v === 'number') {
479
- v = v.toString();
480
- }
507
+ var obj = {};
508
+ var type = exports.valueType(v);
509
+ if (type === exports.TYPES.NULL_OR_EMPTY_STR) {
510
+ Object.keys(shorthand_for).forEach(function(property) {
511
+ obj[property] = '';
512
+ });
513
+ return obj;
514
+ }
481
515
 
482
- if (typeof v !== 'string') {
483
- return undefined;
484
- }
516
+ if (typeof v === 'number') {
517
+ v = v.toString();
518
+ }
485
519
 
486
- if (v.toLowerCase() === 'inherit') {
487
- return {};
488
- }
489
- var parts = getParts(v);
490
- var valid = true;
491
- parts.forEach(function (part) {
492
- var part_valid = false;
493
- Object.keys(shorthand_for).forEach(function (property) {
494
- if (shorthand_for[property].isValid(part)) {
495
- part_valid = true;
496
- obj[property] = part;
497
- }
498
- });
499
- valid = valid && part_valid;
520
+ if (typeof v !== 'string') {
521
+ return undefined;
522
+ }
523
+
524
+ if (v.toLowerCase() === 'inherit') {
525
+ return {};
526
+ }
527
+ var parts = getParts(v);
528
+ var valid = true;
529
+ parts.forEach(function(part, i) {
530
+ var part_valid = false;
531
+ Object.keys(shorthand_for).forEach(function(property) {
532
+ if (shorthand_for[property].isValid(part, i)) {
533
+ part_valid = true;
534
+ obj[property] = part;
535
+ }
500
536
  });
501
- if (!valid) {
502
- return undefined;
503
- }
504
- return obj;
537
+ valid = valid && part_valid;
538
+ });
539
+ if (!valid) {
540
+ return undefined;
541
+ }
542
+ return obj;
505
543
  };
506
544
 
507
- exports.shorthandSetter = function (property, shorthand_for) {
508
- return function (v) {
509
- var obj = exports.shorthandParser(v, shorthand_for);
510
- if (obj === undefined) {
511
- return;
512
- }
513
- //console.log('shorthandSetter for:', property, 'obj:', obj);
514
- Object.keys(obj).forEach(function (subprop) {
515
- // in case subprop is an implicit property, this will clear
516
- // *its* subpropertiesX
517
- var camel = dashedToCamelCase(subprop);
518
- this[camel] = obj[subprop];
519
- // in case it gets translated into something else (0 -> 0px)
520
- obj[subprop] = this[camel];
521
- this.removeProperty(subprop);
522
- // don't add in empty properties
523
- if (obj[subprop] !== '') {
524
- this._values[subprop] = obj[subprop];
525
- }
526
- }, this);
527
- Object.keys(shorthand_for).forEach(function (subprop) {
528
- if (!obj.hasOwnProperty(subprop)) {
529
- this.removeProperty(subprop);
530
- delete this._values[subprop];
531
- }
532
- }, this);
533
- // in case the value is something like 'none' that removes all values,
534
- // check that the generated one is not empty, first remove the property
535
- // if it already exists, then call the shorthandGetter, if it's an empty
536
- // string, don't set the property
537
- this.removeProperty(property);
538
- var calculated = exports.shorthandGetter(property, shorthand_for).call(this);
539
- if (calculated !== '') {
540
- this._setProperty(property, calculated);
541
- }
542
- };
545
+ exports.shorthandSetter = function(property, shorthand_for) {
546
+ return function(v) {
547
+ var obj = exports.shorthandParser(v, shorthand_for);
548
+ if (obj === undefined) {
549
+ return;
550
+ }
551
+ //console.log('shorthandSetter for:', property, 'obj:', obj);
552
+ Object.keys(obj).forEach(function(subprop) {
553
+ // in case subprop is an implicit property, this will clear
554
+ // *its* subpropertiesX
555
+ var camel = dashedToCamelCase(subprop);
556
+ this[camel] = obj[subprop];
557
+ // in case it gets translated into something else (0 -> 0px)
558
+ obj[subprop] = this[camel];
559
+ this.removeProperty(subprop);
560
+ // don't add in empty properties
561
+ if (obj[subprop] !== '') {
562
+ this._values[subprop] = obj[subprop];
563
+ }
564
+ }, this);
565
+ Object.keys(shorthand_for).forEach(function(subprop) {
566
+ if (!obj.hasOwnProperty(subprop)) {
567
+ this.removeProperty(subprop);
568
+ delete this._values[subprop];
569
+ }
570
+ }, this);
571
+ // in case the value is something like 'none' that removes all values,
572
+ // check that the generated one is not empty, first remove the property
573
+ // if it already exists, then call the shorthandGetter, if it's an empty
574
+ // string, don't set the property
575
+ this.removeProperty(property);
576
+ var calculated = exports.shorthandGetter(property, shorthand_for).call(this);
577
+ if (calculated !== '') {
578
+ this._setProperty(property, calculated);
579
+ }
580
+ };
543
581
  };
544
582
 
545
- exports.shorthandGetter = function (property, shorthand_for) {
546
- return function () {
547
- if (this._values[property] !== undefined) {
548
- return this.getPropertyValue(property);
549
- }
550
- return Object.keys(shorthand_for).map(function (subprop) {
551
- return this.getPropertyValue(subprop);
552
- }, this).filter(function (value) {
553
- return value !== '';
554
- }).join(' ');
555
- };
583
+ exports.shorthandGetter = function(property, shorthand_for) {
584
+ return function() {
585
+ if (this._values[property] !== undefined) {
586
+ return this.getPropertyValue(property);
587
+ }
588
+ return Object.keys(shorthand_for)
589
+ .map(function(subprop) {
590
+ return this.getPropertyValue(subprop);
591
+ }, this)
592
+ .filter(function(value) {
593
+ return value !== '';
594
+ })
595
+ .join(' ');
596
+ };
556
597
  };
557
598
 
558
599
  // isValid(){1,4} | inherit
@@ -560,57 +601,57 @@ exports.shorthandGetter = function (property, shorthand_for) {
560
601
  // if two, the first applies to the top and bottom, and the second to left and right
561
602
  // if three, the first applies to the top, the second to left and right, the third bottom
562
603
  // if four, top, right, bottom, left
563
- exports.implicitSetter = function (property_before, property_after, isValid, parser) {
564
- property_after = property_after || '';
565
- if (property_after !== '') {
566
- property_after = '-' + property_after;
604
+ exports.implicitSetter = function(property_before, property_after, isValid, parser) {
605
+ property_after = property_after || '';
606
+ if (property_after !== '') {
607
+ property_after = '-' + property_after;
608
+ }
609
+ var part_names = ['top', 'right', 'bottom', 'left'];
610
+
611
+ return function(v) {
612
+ if (typeof v === 'number') {
613
+ v = v.toString();
614
+ }
615
+ if (typeof v !== 'string') {
616
+ return undefined;
617
+ }
618
+ var parts;
619
+ if (v.toLowerCase() === 'inherit' || v === '') {
620
+ parts = [v];
621
+ } else {
622
+ parts = getParts(v);
623
+ }
624
+ if (parts.length < 1 || parts.length > 4) {
625
+ return undefined;
567
626
  }
568
- var part_names = ["top","right","bottom","left"];
569
-
570
- return function (v) {
571
- if (typeof v === 'number') {
572
- v = v.toString();
573
- }
574
- if (typeof v !== 'string') {
575
- return undefined;
576
- }
577
- var parts;
578
- if (v.toLowerCase() === 'inherit' || v === '') {
579
- parts = [v];
580
- } else {
581
- parts = getParts(v);
582
- }
583
- if (parts.length < 1 || parts.length > 4) {
584
- return undefined;
585
- }
586
627
 
587
- if (!parts.every(isValid)) {
588
- return undefined;
589
- }
628
+ if (!parts.every(isValid)) {
629
+ return undefined;
630
+ }
590
631
 
591
- parts = parts.map(function (part) {
592
- return parser(part);
593
- });
594
- this._setProperty(property_before + property_after, parts.join(' '));
595
- if (parts.length === 1) {
596
- parts[1] = parts[0];
597
- }
598
- if (parts.length === 2) {
599
- parts[2] = parts[0];
600
- }
601
- if (parts.length === 3) {
602
- parts[3] = parts[1];
603
- }
632
+ parts = parts.map(function(part) {
633
+ return parser(part);
634
+ });
635
+ this._setProperty(property_before + property_after, parts.join(' '));
636
+ if (parts.length === 1) {
637
+ parts[1] = parts[0];
638
+ }
639
+ if (parts.length === 2) {
640
+ parts[2] = parts[0];
641
+ }
642
+ if (parts.length === 3) {
643
+ parts[3] = parts[1];
644
+ }
604
645
 
605
- for (var i = 0; i < 4; i++) {
606
- var property = property_before + "-" + part_names[i] + property_after;
607
- this.removeProperty(property);
608
- if (parts[i] !== '') {
609
- this._values[property] = parts[i];
610
- }
611
- }
612
- return v;
613
- };
646
+ for (var i = 0; i < 4; i++) {
647
+ var property = property_before + '-' + part_names[i] + property_after;
648
+ this.removeProperty(property);
649
+ if (parts[i] !== '') {
650
+ this._values[property] = parts[i];
651
+ }
652
+ }
653
+ return v;
654
+ };
614
655
  };
615
656
 
616
657
  //
@@ -619,52 +660,49 @@ exports.implicitSetter = function (property_before, property_after, isValid, par
619
660
  // sub-parts are set. If so, it sets the shorthand version and removes
620
661
  // the individual parts from the cssText.
621
662
  //
622
- exports.subImplicitSetter = function (prefix, part, isValid, parser) {
623
- var property = prefix + '-' + part;
624
- var subparts = [prefix+"-top", prefix+"-right", prefix+"-bottom", prefix+"-left"];
663
+ exports.subImplicitSetter = function(prefix, part, isValid, parser) {
664
+ var property = prefix + '-' + part;
665
+ var subparts = [prefix + '-top', prefix + '-right', prefix + '-bottom', prefix + '-left'];
625
666
 
626
- return function (v) {
627
- if (typeof v === 'number') {
628
- v = v.toString();
629
- }
630
- if (typeof v !== 'string') {
631
- return undefined;
632
- }
633
- if (!isValid(v)) {
634
- return undefined;
635
- }
636
- v = parser(v);
637
- this._setProperty(property,v);
638
- var parts = [];
639
- for (var i = 0; i < 4; i++) {
640
- if (this._values[subparts[i]] == null || this._values[subparts[i]] === '') {
641
- break;
642
- }
643
- parts.push(this._values[subparts[i]]);
644
- }
645
- if (parts.length === 4) {
646
- for (i = 0; i < 4; i++) {
647
- this.removeProperty(subparts[i]);
648
- this._values[subparts[i]] = parts[i];
649
- }
650
- this._setProperty(prefix,parts.join(" "));
651
- }
652
- return v;
653
- };
667
+ return function(v) {
668
+ if (typeof v === 'number') {
669
+ v = v.toString();
670
+ }
671
+ if (typeof v !== 'string') {
672
+ return undefined;
673
+ }
674
+ if (!isValid(v)) {
675
+ return undefined;
676
+ }
677
+ v = parser(v);
678
+ this._setProperty(property, v);
679
+ var parts = [];
680
+ for (var i = 0; i < 4; i++) {
681
+ if (this._values[subparts[i]] == null || this._values[subparts[i]] === '') {
682
+ break;
683
+ }
684
+ parts.push(this._values[subparts[i]]);
685
+ }
686
+ if (parts.length === 4) {
687
+ for (i = 0; i < 4; i++) {
688
+ this.removeProperty(subparts[i]);
689
+ this._values[subparts[i]] = parts[i];
690
+ }
691
+ this._setProperty(prefix, parts.join(' '));
692
+ }
693
+ return v;
694
+ };
654
695
  };
655
696
 
656
-
657
697
  var camel_to_dashed = /[A-Z]/g;
658
- /*jslint regexp: true*/
659
- var first_segment = /^\([^\-]\)-/;
660
- /*jslint regexp: false*/
698
+ var first_segment = /^\([^-]\)-/;
661
699
  var vendor_prefixes = ['o', 'moz', 'ms', 'webkit'];
662
- exports.camelToDashed = function (camel_case) {
663
- var match;
664
- var dashed = camel_case.replace(camel_to_dashed, '-$&').toLowerCase();
665
- match = dashed.match(first_segment);
666
- if (match && vendor_prefixes.indexOf(match[1]) !== -1) {
667
- dashed = '-' + dashed;
668
- }
669
- return dashed;
700
+ exports.camelToDashed = function(camel_case) {
701
+ var match;
702
+ var dashed = camel_case.replace(camel_to_dashed, '-$&').toLowerCase();
703
+ match = dashed.match(first_segment);
704
+ if (match && vendor_prefixes.indexOf(match[1]) !== -1) {
705
+ dashed = '-' + dashed;
706
+ }
707
+ return dashed;
670
708
  };