W3C home > Mailing lists > Public > www-style@w3.org > December 2014

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

From: L. David Baron <dbaron@dbaron.org>
Date: Sat, 20 Dec 2014 19:07:06 -0500
To: Cameron McCormack <cam@mcc.id.au>
Cc: "Tab Atkins Jr." <jackalmage@gmail.com>, www-style list <www-style@w3.org>
Message-ID: <20141221000706.GA29471@crum.dbaron.org>
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, 
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.)


𝄞   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

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:51:52 UTC