W3C home > Mailing lists > Public > www-dom@w3.org > July to September 2012

Re: Element.style setter

From: Ojan Vafai <ojan@chromium.org>
Date: Wed, 5 Sep 2012 13:51:50 -0700
Message-ID: <CANMdWTvCmNxvyAAvo7tXeFbQR8K=U6JZBqG03cP+qx6DZFsBeg@mail.gmail.com>
To: Jonas Sicking <jonas@sicking.cc>
Cc: Boris Zbarsky <bzbarsky@mit.edu>, www-dom@w3.org
On Fri, Aug 31, 2012 at 9:03 AM, Jonas Sicking <jonas@sicking.cc> wrote:

> On Fri, Aug 31, 2012 at 12:26 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote:
> > On 8/31/12 8:24 AM, Bjoern Hoehrmann wrote:
> >>
> >> Allowing this results in odd situations like `a != b` right
> >> after setting `a = b`
> >
> >
> > This is already all over the web platform.  First of all, every case with
> > [PutForwards] (which is how one would implement the behavior in
> question).
> > An existing example:
> >
> >   window.location = "http://something";
> >   alert(window.location);  // alerts "object"
> >
> > Or even in the CSSOM:
> >
> >   div.style.color = "red";
> >   div.style.color = "oh, you want equality?"
> >   alert(div.style.color); // alerts "red"
> >
> > or in the DOM:
> >
> >   div.innerHTML = "<span>foo"
> >   alert(div.innerHTML); // alerts "<span>foo</span>"
> >
> > Just saying.  If we really wanted to do this, implementing it in the web
> > platform would be pretty straightforward: toss [PutForwards=cssText] on
> the
> > .style attribute, and WebIDL will take care of the rest....
>
> For what it's worth. This is the reason that I think that
> [PutsForwards] is a really bad idea. It makes the platform more
> complicated for relatively little gain. And so I think we should have
> left it as a document.location legacy quirk.
>
> I've so far always lost this argument though as it keeps being added
> to new APIs.
>

I think this is already a lost cause for style given the example Boris
pointed out. Also, you can already do this with style.cssText and it has
the same issue. I can't tell you how many times I've seen web developers do
bloated, hard to read code because they didn't realize cssText existed and
setting style didn't work.
Received on Wednesday, 5 September 2012 20:52:40 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 5 September 2012 20:52:46 GMT