Skip to content

Commit

Permalink
[fix] Set the correct this context
Browse files Browse the repository at this point in the history
  • Loading branch information
3rd-Eden committed Feb 27, 2015
1 parent e13ec07 commit d64703c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@ function transform(tpl, config, options) {
, start = rdom.indexOf('React.createElement');

return new Function('data', 'config', [
'data = data || {};',

'var nodes = (function jsx() {',
rdom.slice(0, start),
'with (data || {}) return '+ rdom.slice(start),
'})(), options = '+ JSON.stringify(options || {}) +';',
'with (data) return '+ rdom.slice(start),
'}).call(this.props ? this : data),',
'options = '+ JSON.stringify(options || {}) +';',

'if ("DOM" === options.render || !(config || {}).html) return nodes;',
'return React[options.render](nodes);'
Expand Down

0 comments on commit d64703c

Please sign in to comment.