-
Notifications
You must be signed in to change notification settings - Fork 711
[css-backgrounds-4] Using logical keywords in background-position shorthand with multiple backgrounds #12132
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
Comments
Adding an explicit keyword for this situation seems the best we can do in this case. Being explicit avoids confusion and makes it easier for authors to get to know about the reason behind this. I just wonder if one keyword is enough for all cases in which logical and physical property names and values are mixed or if there are use cases requiring distinct keywords. Sebastian |
This really only applies to properties that operate on lists, I’m not sure it’s a general problem. |
The issue isn't restricted to properties that operate on lists, as far as I understand. Though it applies to position properties that are restricted to either physical or logical positions. Sebastian |
I apologize but I don’t follow. Can you give me an example test case of a non list property showing this issue? |
It looks like I expressed myself unclear. What I meant was that it is not the fact that So, even if I think, there is currently only one other case that'll need this, namely Sebastian |
I guess I don't quite understand why the hypothetical Taking the example above and trying both values separately, this is what I assume the results would be:
and
With the shorthand parser just picking one pair or the other to use. Where would this break down? |
My point was, the behavior should be the same in case of a hypothetical <div id="test3" style="background-position: left bottom;">...</div> assert(document.getElementById("test3").style.backgroundPositionX == "left");
assert(document.getElementById("test3").style.backgroundPositionY == "bottom");
assert(document.getElementById("test3").style.backgroundPositionBlock == "defer");
assert(document.getElementById("test3").style.backgroundPositionInline == "defer"); and <div id="test4" style="background-position: block-start inline-end;">...</div> assert(document.getElementById("test4").style.backgroundPositionX == "defer");
assert(document.getElementById("test4").style.backgroundPositionY == "defer");
assert(document.getElementById("test4").style.backgroundPositionBlock == "block-start");
assert(document.getElementById("test4").style.backgroundPositionInline == "inline-end"); Though this discussion is moot, anyway, as we currently only have list-valued properties that are affected by this issue. So, apologies for the confusion! My original point was to go with option 2, i.e. use an explicit keyword. Using an empty value might be confusing to authors and looks strange, especially if you have multiple of them. Also, it makes sense to distinguish the case of being set to a later-resolved value vs. not being set at all. One question that just came to my mind is, what happens when you explicitly set the longhands to <div id="test5" style="background-position-x: defer, left; background-position-y: defer, bottom;">...</div> assert(document.getElementById("test5").style.backgroundPosition == ???);
assert(document.getElementById("test5").style.backgroundPositionBlock == ???);
assert(document.getElementById("test5").style.backgroundPositionInline == ???); One possible solution would be to fall back to the initial value, i.e. assert(document.getElementById("test5").style.backgroundPosition == '0% 0%, left bottom');
assert(document.getElementById("test5").style.backgroundPositionBlock == '0%, defer');
assert(document.getElementById("test5").style.backgroundPositionInline == '0%, defer'); and <div id="test6" style="background-position-block: defer, start; background-position-inline: defer, end;">...</div> the result would be assert(document.getElementById("test5").style.backgroundPosition == '0% 0%, block-start inline-end');
assert(document.getElementById("test5").style.backgroundPositionX == '0%, defer');
assert(document.getElementById("test5").style.backgroundPositionY == '0%, defer'); Also note that in your initial examples you had a little error. The logical longhands don't use the assert(document.getElementById("test2").style.backgroundPositionBlock == "start");
assert(document.getElementById("test2").style.backgroundPositionInline == "end"); not assert(document.getElementById("test2").style.backgroundPositionBlock == "block-start");
assert(document.getElementById("test2").style.backgroundPositionInline == "inline-end"); Sebastian |
When trying to implement support for
background-position-block
/background-position-inline
and the new logical keywords added to<position>
in CSS Values 5, I ran into an issue with the fact thatbackground-position
(andbackground
) operate on lists of backgrounds.To explain the issue, let's start with an existing example where you have the following usage:
In this example, the following assertions hold:
Simple. When processing the shorthand, the parser split each
background-position
pair into anx
andy
component and created lists with them.Now, consider a case using the new logical keywords along with the old physical keywords:
What should the following assertions be?
Internally in the engine, we would probably be modeling this as with some placeholder value that tells the style building to not do anything for that specific value:
But its not clear how that would serialize.
Two ideas, both from @fantasai, are:
defer
keyword for the same purpose:I prefer the explicitness of the
defer
keyword.The text was updated successfully, but these errors were encountered: