Recently, we had to change the design on one of the old sites where javascript was used to draw elements. In particular, there is such a moment. Incoming data should be added using javascript to the table. Moreover, each element (cells, rows), etc. There were some attributes. Such elements were drawn with standard DOM functions (createElement, appendChild, etc.). When changing the design, I had to go into javascript code (set other styles, etc.). I think a familiar situation.
Naturally, I did not like this situation and came up with the idea to provide a change of design without changing javascript. For this, I tried to create a template in html, and then using cloneNode, try to insert it in the right place and replace the tags with data. Here's what came of it:
www.pastebin.ca/931592 .
Now imagine that the design changes:
www.pastebin.ca/931593')
If the mapping is quite complicated, this approach simplifies support.
Minus - the possible loss of speed.
To reduce losses, the set of attributes in which tags are replaced is limited. This set will periodically have to be clarified.
ps. Tested in IE6 and Firefox2