Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions tests/filter-effects-1.js
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The syntax for the filter() function is:

filter() = filter( [ <image> | <string> ], <filter-value-list> )

So three annotations:

  1. The first parameter can also be a <string>. Though that's a bit strange, because the spec. doesn't define what this value refers to. I'll try to dig deeper and may create a spec. issue for that.
  2. The second parameter is a <filter-value-list>. That means we should have at least one test for multiple filters.
  3. <image> includes more than just gradients and URLs. So maybe we should add a few tests regarding those other values.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,33 @@ export default {
status: {
stability: 'stable',
},
values: {
properties: ['background-image', 'list-style-image', 'border-image-source', 'cursor', 'mask-image', 'mask-border-source', 'shape-outside', 'content'],
// https://caniuse.com/css-filter-function
// There was a bug in Safari before 18.4,
// https://bugs.webkit.org/show_bug.cgi?id=250303
'filter()': {
links: {
tr: '#FilterCSSImageValue',
dev: '#FilterCSSImageValue',
},
tests: [
// filter() = filter( [ <image> | <string> ], <filter-value-list> )
'filter(conic-gradient(red), invert(1))',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Single-stop gradients were only added recently, as far as I know. So I wouldn't include those in the tests for filter().

Generally, I don't think it is necessary to test (so many) different gradient syntaxes here. One basic test per gradient function or even just one for gradients in general should be fine.

'filter(conic-gradient(red, orange), invert(1))',
'filter(conic-gradient(red 0 0), invert(1))',
'filter(conic-gradient(red 0 100%), invert(1))',
'filter(linear-gradient(red, orange), invert(1))',
'filter(radial-gradient(red, orange), invert(1))',
'filter(repeating-conic-gradient(red, red 5%, black 5%, black 10%), invert(1))',
'filter(repeating-linear-gradient(red, red 10px, black 10px, black 20px), invert(1))',
'filter(repeating-radial-gradient(red, red 10px, black 10px, black 20px), invert(1))',
'filter(url("#foo"), blur(8px))',
'filter(url(#foo), blur(8px))',
'filter(url(foo.png), blur(8px))',
],
},
},
properties: {
filter: {
links: {
Expand Down