On Mon, May 16, 2011 at 9:45 PM, Zach Smith <[email protected]> wrote:
> I would parse the xml with javascript and create a xhtml DOM equivalent,
> then hide the original xml.
> (...)
> Basically, you want to be working with xhtml not xml.

On Wed, May 18, 2011 at 4:33 PM, Steve Esson <[email protected]> wrote:
> Will this technique (document.createElement("tab")) work for you?
>
> http://ejohn.org/blog/html5-shiv/
>
> Steve

I really do want to work with XML, not (X)HTML.

The problem with (X)HTML is that it is intended to be used for
describing hipertext documents, not application UIs. I admit that
HTML5 introduces some additional syntax useful for web applications,
but still it is very far from specifications such as XUL.

With custom XML namespace I can create my own XUL-like syntax that is
easier to maintain than (X)HTML tag soup. Even more, I can target my
widgets with namespaced CSS rules which gives me full confidency that
my widgets will look exactly the same no matter where I'm embedding
them.

Regarding my original question, I realize now that manipulation of DOM
attributes is very slow, especially if it's done every 60ms. So
instead I came up with this solution where attribute is set only once
for a given element and everything else is done via CSSOM, works like
a charm:

/*
* Usage:
* > header.setStyle('color', 'blue');
* > $0.setStyle('font-size', '20px');
*/

var styleElement = document.createElement("style");
document.querySelector("head").appendChild(styleElement);

var counter = 0;

Element.prototype.setStyle = function(property, value) {
  // Unique identifier used for targetting the element with CSS
  var cssID = this.getAttribute('cssID');

  if (cssID === null) {
    cssID = counter++;
    this.setAttribute('cssID', cssID);
    styleElement.sheet.insertRule( '[cssID="' + cssID + '"] {' +
property + ':' + value + ';}', styleElement.sheet.cssRules.length);
  }

  else {
    for (var i in styleElement.sheet.rules) {
      if (styleElement.sheet.rules[i].selectorText === '[cssID="' +
cssID + '"]') {
        styleElement.sheet.rules[i].style.setProperty(property, value);
      }
    }
  }

}

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to