-
Notifications
You must be signed in to change notification settings - Fork 636
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-images-4] Allow gradients with a single color stop and 0-1 positions #10092
Comments
Requiring two meaningless positions does seem like a waste of time. This seems a lot cleaner. |
Yeah, the restriction was just because you're defining a gradient, and by definition that requires two colors to interpolate between. But there's nothing wrong with allowing a single color, certainly. And if browsers are already allowing a single stop when it has two positions, contrary to the spec grammar (probably because they expand that at parse-time into two stops in their internal representation, and then just check that the internal list is at least 2 items), then I really don't see an issue. |
So far no-one is arguing against this change and everyone who has commented agrees that this is reasonable, desirable, and easily implementable. @astearns this seems like a candidate for async resolution, therefore. |
The CSSWG will automatically accept this resolution one week from now if no objections are raised here. Anyone can add an emoji to this comment to express support. If you do not support this resolution, please add a new comment. Proposed Resolution: Relax gradient syntax to allow a single color stop with 0-1 positions |
This sounds reasonable as long as we're reasonably confident it's not going to add too much complexity to any future gradient interpolation rules. (I also thought about the object model, but I don't see any ways that it would add complexity to the object model that existing gradient features don't already require. However, the current interpolation rules draft isn't clear on how it handles stops without positions.) |
It shouldn't, no; the interpolation rules work just as well for a single stop as infinity stops. I've filed the position-less stop issue as #10374. |
RESOLVED: Relax gradient syntax to allow a single color stop with 0-1 positions |
This came up in #10077 but I’m opening a new issue since I proposed a different path but then the change qualifies as substantive.
So currently, CSS Images 4 has prose and grammar that disallows single color stop gradients. However, all UAs have implemented a syntax that allows a gradient with a single color stop as long as it has two positions, e.g.
linear-gradient(red 0% 100%)
.What purpose does this restriction serve? You get a single color anyway and the positions are meaningless, they could be anything at all and as long as they parse, they produce the same result. E.g.
linear-gradient(red 50% 50%)
,linear-gradient(red -100% -200%)
,linear-gradient(red 50% 50%)
,linear-gradient(red 300% 1000%)
all produce the same result. So what's the harm in simply allowing a single color stop, even if it has one position — or even none? You get a single color anyway!The benefits of that are small, but not inconsequential:
The only argument against this is that implementations seem to agree on the current state (of requiring two stops) so we may as well adopt that in the spec. However, given the spec already differs from implementations, I see no harm in changing it in a way that makes it more permissive than implementations. Having it be less permissive (the current situation) is a much bigger issue.
The text was updated successfully, but these errors were encountered: