google / elemental2

Type checked access to browser APIs for Java code.
Apache License 2.0
150 stars 38 forks source link

CSSProperties no LeftUnionType, TopUnionType, etc #161

Open aeromac opened 10 months ago

aeromac commented 10 months ago

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

zbynek commented 9 months ago

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:

jDramaix commented 9 months ago

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 commented 9 months ago

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

jDramaix commented 9 months ago

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