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