elemental2 icon indicating copy to clipboard operation
elemental2 copied to clipboard

CSSProperties no LeftUnionType, TopUnionType, etc

Open aeromac opened this issue 1 year ago • 4 comments

Hi, I was just wondering why properties such as Width use types such as WidthUnionType which allows setting a double or String, however, Left does not have a similar type and is instead declared as a String type.

Thank you

aeromac avatar Feb 02 '24 10:02 aeromac

Elemental takes these from Closure (specifically https://github.com/google/closure-compiler/blob/e6957b2a68b522a2483ab268cd835b8c706aca36/externs/browser/w3c_css.js#L1734 is a string and other properties are number|string, which gets converted to *UnionType when generating the Java code). This changed in https://github.com/google/closure-compiler/commit/7bd79871e81d1115fcb44800d98eb918e2630e20 , but I couldn't find any more info. You can ask the Closure community :shrug:

zbynek avatar Feb 20 '24 20:02 zbynek

This is to avoid bugs. Although it's valid to assign 0 to element.style.left/right/top/bottom, any other numbers without units are silently ignored.

jDramaix avatar Feb 27 '24 07:02 jDramaix

And I think they should do the same for others properties with unit, but it may break too many internal code.

jDramaix avatar Feb 27 '24 07:02 jDramaix

Reopening the issue, the Closure extern file could could be improved.

jDramaix avatar Feb 27 '24 07:02 jDramaix