Re: [css-logical-props] do shorthands have logical component longhands?

On Sunday 2014-12-21 10:22 +1100, Cameron McCormack wrote:
> (2) Here is a case where assigning to a shorthand gives you (what I
> think might be) unintuitive results:
> 
>   div { margin: 1px;
>         margin-inline-start: 0px; margin-inline-end: 0px;
>         margin-block-start: 0px; margin-block-end: 0px; }
> 
>   decl.style.margin = "2px";
> 
> Since the declaration has all of the component longhands already, we
> just overwrite each one with either 2px (for the physical ones) or
> 0px (for the logical ones).  The result is that you'll still have
> 0px margins, as the logical properties still appear after the
> physical ones.

Well, I wish setProperty always had append semantics (which I should
perhaps call remove-and-append semantics), but it may be too late to
go back to that.

I believe it had remove-and-append semantics in Gecko prior to:
https://bugzilla.mozilla.org/show_bug.cgi?id=288574 which switched
to replace-or-append, although we've since added additional
optimizations that depend on the replace-or-append semantics in:
https://bugzilla.mozilla.org/show_bug.cgi?id=498562 .

(By replace-or-append, I mean the algorithm in
http://dev.w3.org/csswg/cssom/#set-a-css-declaration .
Remove-or-append semantics would mean changing step 1 of that
algorithm to remove the existing declaration, and then dropping the
"Otherwise" from step 2.)

(This is related to the debate we had last year about !important, 
http://lists.w3.org/Archives/Public/www-style/2013Sep/thread.html#msg201
http://lists.w3.org/Archives/Public/www-style/2013Oct/thread.html#msg2
in which I eventually gave in.)

> Should we make assigning to 'margin' move the physical properties to
> the end of the declaration?  (And if we do so, we'll need to ensure
> that the empty string is returned when getting 'margin' if logical
> properties appear after physical ones.)

Well, it would probably need to move the physical and logical
properties, once the 'logical' keyword is introduced.

This is a bit of a mess; I don't see a good solution unless we can
switch to append semantics for setProperty instead of
replace-or-append.  (I'm curious if the current replace-or-append is
fully interoperable.  Gecko did once do remove-and-append.)

-David

-- 
𝄞   L. David Baron                         http://dbaron.org/   𝄂
𝄢   Mozilla                          https://www.mozilla.org/   𝄂
             Before I built a wall I'd ask to know
             What I was walling in or walling out,
             And to whom I was like to give offense.
               - Robert Frost, Mending Wall (1914)

Received on Sunday, 21 December 2014 00:07:52 UTC