Skip to content

Commit d64703c

Browse files
committed
[fix] Set the correct this context
1 parent e13ec07 commit d64703c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,13 @@ function transform(tpl, config, options) {
2727
, start = rdom.indexOf('React.createElement');
2828

2929
return new Function('data', 'config', [
30+
'data = data || {};',
31+
3032
'var nodes = (function jsx() {',
3133
rdom.slice(0, start),
32-
'with (data || {}) return '+ rdom.slice(start),
33-
'})(), options = '+ JSON.stringify(options || {}) +';',
34+
'with (data) return '+ rdom.slice(start),
35+
'}).call(this.props ? this : data),',
36+
'options = '+ JSON.stringify(options || {}) +';',
3437

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

0 commit comments

Comments
 (0)