evanmoran / oj

Unified web templating for the people. Thirsty people.
MIT License
444 stars 7 forks source link

Support `use strict`: Change with(oj) to oj.extendInto(this) #20

Open IngwiePhoenix opened 9 years ago

IngwiePhoenix commented 9 years ago

https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Statements/with

Many scripts and libraries use "use strict";. In order to not run into complications, OJ probably should extend into the scope that it wants to. In the case of a rendering sequence:

(function(){try{ oj.extendInto(this); (function(){
    h1("Foo bar");
}).apply(this);}catch(e){ handle_error(e); }})();

Just a thought, since I just read the article.

evanmoran commented 6 years ago

This is a great idea, thank you! In addition to this, there are a couple secret things that OJ does that may not be compatible with use strict, for example the way OJ creates dynamic prototypes is pretty fancy :). That said, I think it's a worthy goal that OJ v2.0 supports use strict. Let's do this!