Re: Element.style setter

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 UTC