W3C home > Mailing lists > Public > www-html@w3.org > January 2003

Re: XHTML 2.0 considered harmful

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Wed, 15 Jan 2003 14:18:06 -0500
Message-Id: <200301151918.OAA22527@no-knife.mit.edu>
To: Mikko Rantalainen <mira@cc.jyu.fi>
cc: www-html@w3.org

> IMO, if we drop style attribute the respective part of DOM should drop the
> style attribute too so there's no problem.

Sure there is and a major one.  Compare the following two chunks of ECMAScript:

  document.getElementById("myMovableDiv").style.left = "50px";

and

  var set = false;
  var rules = document.styleSheets[0].cssRules;
  var len = rules.length;
  while (var i = 0; i < len; ++i) {
    var rule = rules[i];
    if (rule.selectorText == "#myMovableDiv") {
      rule.style.left = "50px";
      set = true;
      break;
  }
  if (!set) {
    document.styleSheets[0].insertRule("#myMovableDiv { left: 50px }", rules.length);
  }

You claim that the two are equivalent, since a rule with an id selector is
equivalent to an inline style rule.  Here are some reasons they are not
equivalent:

1)  The DOM code needed to manipulate the sheet is much more complicated.  This
    could be abstracted away in some fashion either in the DOM CSS spec or in a
    commonly-used library of some sort (though when a library is used by
    _everyone_ using this part of the DOM, that's strong reason to include the
    capability in the spec).

2)  Inline style and id rules lie at different points in the cascade.  The
    second chunk above should really search all sheets (not just the first
    sheet), find the rule that matches this element that has highest weight,
    get its selector, modify it by possibly adding the ID, etc.  Consider for
    instance the rule:

    #divContainer div { left: 0px }

    Combined with the markup:

    <div id="divContainer">
       <div id="myMovableDiv">Text to move </div>
    </div>

    And note that the above script fails to deal with this situation.

I have no particular liking for the style attribute and style property in the
DOM, as long as the functionality they provide is provided in some other way.
Dropping the style property from the DOM without providing a reasonable
alternative that will not force authors to write hundreds of lines of code
where they can write one today would be a bad idea, I would think.

Let's not make the mistake that that DOM working group has already made with
DOM 2 CSS -- that of creating a spec so cumbersome to use that no one in their
right mind will use it.

Boris
-- 
Windows 95:
   (noun): 32 bit extensions and a graphical shell for
a 16 bit patch to an 8 bit operating system originally
coded for a 4 bit microprocessor, written by a 2 bit
company, that can't stand 1 bit of competition.
Received on Wednesday, 15 January 2003 14:18:44 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 27 March 2012 18:15:54 GMT