leonidas / transparency

Transparency is a semantic template engine for the browser. It maps JSON objects to DOM elements by id, class and data-bind attributes.
http://leonidas.github.com/transparency/
MIT License
969 stars 112 forks source link

Style attribute using directives #97

Open dannyc opened 11 years ago

dannyc commented 11 years ago

Even though you only list the attributes class, href, and src as attributes that can be updated with directives, style attribute also works. But only in IE9 and Chrome but does not work in IE8 (which I unfortunately still need to support). It's failing on the current dist js dist line 406.

Attribute.prototype.set = function(value) {
      this.el[this.name] = value; //<-- failing here
      return this.el.setAttribute(this.name, value.toString());
    };

See this fiddle: http://jsfiddle.net/8fRPG/ Is there any way to check for style and then add another level of support? Something along these lines:

var directives = {
        activity: {
            style: {
                left: function(params){
                    return "left: " + (left * params.index) + "px;";
                }
            }
        }
    };

I would think dynamic style is a pretty common use case. Changing classes just isn't flexible enough. Thoughts? Thanks.