cssinjs / jss

JSS is an authoring tool for CSS which uses JavaScript as a host language.
https://cssinjs.org
MIT License
7.06k stars 397 forks source link

[jss-default-unit] transition-delay requires a unit even for a zero value #863

Closed timsnadden closed 5 years ago

timsnadden commented 5 years ago

I was surprised to see that browsers (tested in chrome, firefox) treat a unitless 0 value for transition-delay as invalid. jss-default-unit only appends a unit to non-zero numbers leading to transition-delay not being set when I specify transitionDelay: 0.

cursor_and_bank_of_new_zealand
HenriBeck commented 5 years ago

Interestingly the same applies to animation-delay.

Is this a big problem? Because if the property is invalid, it will behave the same as it's not applied which means it works the same as 0ms.

timsnadden commented 5 years ago

The reason it came up for us is that we wanted to override an existing setting on hover and it didn't take effect unless the value was set with a unit ('0ms')

On Mon, 24 Sep 2018 at 19:48, Henri notifications@github.com wrote:

Interestingly the same applies to animation-delay.

Is this a big problem? Because if the property is invalid, it will behave the same as it's not applied which means it works the same as 0ms.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/cssinjs/jss/issues/863#issuecomment-423897805, or mute the thread https://github.com/notifications/unsubscribe-auth/AANhZbi3Ya530UWyyMowih69v4XcO6J8ks5ueI5QgaJpZM4W2BsH .

kof commented 5 years ago

The amount of inconsistencies in CSS is crazy.

HenriBeck commented 5 years ago

We could just simply add units to 0 as well.

kof commented 5 years ago

Not that simple, because some units actually require to be unitless, for e.g. opacity. If we implement #687 we will solve this issue as well.

kof commented 5 years ago

We need to maintain 2 lists: unitless and non-px props. Ideally we should generate them from mdn data like we do for the vendor prefixer.

kof commented 5 years ago

tbc in #687

HenriBeck commented 5 years ago

We would just need to remove the value !== 0 from: https://github.com/cssinjs/jss/blob/master/packages/jss-plugin-syntax-default-unit/src/index.js#L38

kof commented 5 years ago

That would convert everything to '0', I would try to keep numeric values as they are where possible.

kof commented 5 years ago

I think #687 will solve this case automatically, once it handles a unitless value with numbers and uses strings for the rest

HenriBeck commented 5 years ago

And it would convert everything to '0ms' for example where we have a default unit. This would solve the issue.

kof commented 5 years ago

you mean default unit? yes