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

CSS property value of 'opacity' is handled in pixels #1277

Open
StarpTech opened this issue Mar 9, 2019 · 2 comments
Open

CSS property value of 'opacity' is handled in pixels #1277

StarpTech opened this issue Mar 9, 2019 · 2 comments
Labels
type:feature A feature request

Comments

@StarpTech
Copy link
Contributor

Marko Version: 4.15.2

You can also try it in the online playground

Repro

<div style={ opacity: 1 }/>

Output

<div style="opacity:1px;"></div>
@DylanPiercey
Copy link
Contributor

Currently we automatically (and blindly) cast all numbers in the style object as pixels. The main reason for this is to avoid creating a map of values that should be in px vs not since this would increase the bundle size.

In any case I think it is acceptable that the opt out is simply to use strings in the styles eg <div style={ opacity: "1" }/>. However it might make sense to show warnings in development.

cc @mlrawlings

@tigt
Copy link
Contributor

tigt commented Aug 12, 2019

I would rather Marko not cast integers to pixels at all:

  • Pixels aren’t great practice in CSS: rems, ems, and percentages are preferred except for certain properties (like borders). I’m not banning pixels, but they shouldn’t be the convenient path — not more convenient than the flexible units, at least.

  • Not treating units specially would align Marko more with vanilla CSSOM code, which will only get more relevant with Houdini, custom properties, TypedOM, etc.

@DylanPiercey DylanPiercey added the type:feature A feature request label Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:feature A feature request
Projects
None yet
Development

No branches or pull requests

3 participants