web-platform-tests / wpt

Test suites for Web platform specs — including WHATWG, W3C, and others
https://web-platform-tests.org/
Other
4.91k stars 3.06k forks source link

css/css-animations/animation-important-001.html assumes custom properties are not animated discretely #34600

Open graouts opened 2 years ago

graouts commented 2 years ago

The test css/css-animations/animation-important-001.html assumes that custom properties interpolate non-discretely. For instance:

test(() => {
  getComputedStyle(target7).getPropertyValue('--length-1');

  let animation = target7.animate([
    { '--length-1': '100px' },
    { '--length-1': '200px' },
  ], {
    duration: 1000000,
    delay: -500000,
    easing: 'steps(2, end)'
  });

  assert_equals(getComputedStyle(target7).getPropertyValue('--length-1'), '150px');
 , 'Custom property animations appearing via setKeyframes do not override important declarations');

But the CSS Custom Properties for Cascading Variables Module Level 1 specification clearly states "Animation type: discrete".

This would mean that the assertion above is incorrect and that it should be 200px.

graouts commented 2 years ago

Cc @andruud who authored this test.

graouts commented 2 years ago

I do see this other spec text in the animation behavior section of CSS Properties and Values API Level 1:

When referenced by animations and transitions, custom property values interpolate by computed value, in accordance with the type that they parsed as.

That seems to me to be in contradiction with the previously-cited specification.

However, that seems to be more in line with what an author would expect, it would make sense that a custom property defined as a <length> is animatable. It seems to me like it should be possible to let the author define that property as discrete still for cases where a value does not make sense to animate.

andruud commented 2 years ago

Yeah, this is intentional. Registered custom properties (can) get a non-discrete animation type.