jsguy / mithril.sugartags

Sugar for mithril templating system
MIT License
20 stars 1 forks source link

Remove use of `with()` #3

Closed Zolmeister closed 10 years ago

Zolmeister commented 10 years ago

The use of with() in JavaScript it an antipattern.

There are many issues with using it, but the most indisputable is the fact that it drastically reduces runtime performance (functions will not be optimized)

jsguy commented 10 years ago

Good point - fixed.

jsguy commented 10 years ago

Note: I originally thought adding the functions to global scope is a bad idea, but looking at other frameworks, eg: Domo, it's probably ok for the sake of convenience. I've also added a feature to make it local, should anyone want to do that - simply set m.localSugarTags = true; before loading sugar tags.