Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto detect CSS property handling #92

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Auto detect CSS property handling #92

wants to merge 4 commits into from

Conversation

alancutter
Copy link
Contributor

Attach handlers to properties according to whether they accept the type of CSS value.

Properties auto discovered:

Chrome

color-handler.js

background, backgroundColor, border, borderBottom, borderBottomColor, borderColor, borderLeft, borderLeftColor, borderRight, borderRightColor, borderTop, borderTopColor, color, fill, floodColor, lightingColor, outline, outlineColor, stopColor, stroke, textLineThroughColor, textOverlineColor, textUnderlineColor

dimension-handler.js

backgroundPositionX, backgroundPositionY, backgroundSize, baselineShift, border, borderBottom, borderBottomLeftRadius, borderBottomRightRadius, borderBottomWidth, borderImageOutset, borderImageWidth, borderLeft, borderLeftWidth, borderRadius, borderRight, borderRightWidth, borderSpacing, borderTop, borderTopLeftRadius, borderTopRightRadius, borderTopWidth, borderWidth, bottom, flexBasis, fontSize, height, left, letterSpacing, lineHeight, margin, marginBottom, marginLeft, marginRight, marginTop, maxHeight, maxWidth, minHeight, minWidth, outline, outlineOffset, outlineWidth, padding, paddingBottom, paddingLeft, paddingRight, paddingTop, perspective, right, size, strokeDasharray, strokeDashoffset, strokeWidth, textIndent, textLineThroughWidth, textOverlineWidth, textUnderlineWidth, top, verticalAlign, width, wordSpacing

number-handler.js

borderImageOutset, borderImageWidth, fillOpacity, flexGrow, flexShrink, floodOpacity, lineHeight, opacity, stopOpacity, strokeMiterlimit, strokeOpacity, textLineThroughWidth, textOverlineWidth, textUnderlineWidth, zoom

transform-handler.js

transform

Firefox

color-handler.js

backgroundColor, borderBottomColor, borderColor, borderLeftColor, borderRightColor, borderTopColor, color, outlineColor, fill, floodColor, lightingColor, stopColor, stroke

dimension-handler.js

borderBottomWidth, borderLeftWidth, borderRightWidth, borderSpacing, borderTopWidth, borderWidth, borderRadius, borderTopLeftRadius, borderTopRightRadius, borderBottomRightRadius, borderBottomLeftRadius, bottom, flexBasis, fontSize, height, left, letterSpacing, lineHeight, margin, marginBottom, marginLeft, marginRight, marginTop, markerOffset, maxHeight, maxWidth, minHeight, minWidth, outlineWidth, outlineOffset, padding, paddingBottom, paddingLeft, paddingRight, paddingTop, right, size, textIndent, perspective, top, verticalAlign, width, wordSpacing, strokeDasharray, strokeDashoffset, strokeWidth

number-handler.js

flexGrow, flexShrink, fontSizeAdjust, lineHeight, opacity, fillOpacity, floodOpacity, stopOpacity, strokeDasharray, strokeDashoffset, strokeOpacity, strokeWidth

transform-handler.js

transform

Internet Explorer

color-handler.js

scrollbar3dLightColor, scrollbarArrowColor, scrollbarBaseColor, scrollbarDarkShadowColor, scrollbarFaceColor, scrollbarHighlightColor, scrollbarShadowColor, scrollbarTrackColor, background, backgroundColor, border, borderBottom, borderBottomColor, borderColor, borderLeft, borderLeftColor, borderRight, borderRightColor, borderSpacing, borderTop, borderTopColor, color, columnRule, columnRuleColor, fill, floodColor, fontFamily, lightingColor, outline, outlineColor, stopColor, stroke

dimension-handler.js

backgroundPositionX, backgroundPositionY, layoutGridChar, layoutGridLine, zoom, background, backgroundPosition, backgroundSize, baselineShift, borderBottomLeftRadius, borderBottomRightRadius, borderBottomWidth, borderLeftWidth, borderRadius, borderRightWidth, borderSpacing, borderTopLeftRadius, borderTopRightRadius, borderTopWidth, borderWidth, bottom, columnGap, columnRuleWidth, columnWidth, flexBasis, fontFamily, fontSize, height, kerning, left, letterSpacing, lineHeight, margin, marginBottom, marginLeft, marginRight, marginTop, maxHeight, maxWidth, minHeight, minWidth, outline, outlineWidth, padding, paddingBottom, paddingLeft, paddingRight, paddingTop, perspective, right, strokeDasharray, strokeDashoffset, strokeWidth, textIndent, top, verticalAlign, width, wordSpacing

number-handler.js

zoom, borderImage, borderImageOutset, borderImageSlice, borderImageWidth, borderSpacing, fillOpacity, flexGrow, flexShrink, floodOpacity, fontFamily, kerning, lineHeight, opacity, stopOpacity, strokeDasharray, strokeDashoffset, strokeMiterlimit, strokeOpacity, strokeWidth

transform-handler.js

borderSpacing, fontFamily, transform

@@ -192,7 +192,7 @@
}];
}

scope.addPropertiesHandler(parseTransform, mergeTransforms, ['transform']);
scope.addCSSValueHandler(parseTransform, mergeTransforms, 'rotate(10deg) scale(2)');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which property other than 'transform' would support transform values?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None, it's just more code to support an alternate way to specify property handling that's not really necessary.

@dstoc
Copy link
Contributor

dstoc commented Jun 24, 2014

animationIterationCount

Need to skip animation/transitions properties.

@dstoc
Copy link
Contributor

dstoc commented Jun 24, 2014

Can you get results for IE too?

@shans
Copy link
Contributor

shans commented Jun 24, 2014

I really like this approach overall. How expensive is it to run through all the properties?

@alancutter
Copy link
Contributor Author

Skipping animation properties.
Added IE results.
propertiesAcceptingCssValue() takes 1.6ms on my 3.1GHz Windows computer running Chrome.

@dstoc
Copy link
Contributor

dstoc commented Jun 24, 2014

propertiesAcceptingCssValue() takes 1.6ms

This seems too expensive. How many different property types are we going to have? Is it any better using CSS.supports (probably not supported in IE)?

None, it's just more code to support an alternate way to specify property handling that's not really necessary.

Seems like it's a time/size tradeoff now.

Added IE results.

The results for transform seem a bit strange.

function propertiesAcceptingCssValue(cssValue) {
var properties = [];
var style = document.createElement('div').style;
for (var property in style) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compute the list of possible properties once, outside of propertiesAcceptingCssValues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants