Skip to content

Commit 5712dae

Browse files
update ctx.js : adding strict mode in code inside
the string
1 parent 2620426 commit 5712dae

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/ctx.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
class Ctx {
2-
constructor(template) {
3-
this._temp = "";
4-
this._parentTemp = `return @temp;`;
2+
constructor() {
3+
this._temp = '';
4+
this._parentTemp = `"use strict";return @temp;`;
55
this._defaultCom = null;
66
this._com = null;
77
this._b = window.Babel;
8-
this._babelpresets = ["react"];
9-
this.updateTemplate(template);
8+
this._babelpresets = ['react'];
109
}
1110
_transpile() {
1211
return this._b.transform(this._temp, {
1312
presets: this._babelpresets,
1413
}).code;
1514
}
1615
_generateCom() {
17-
this._com = this._temp
18-
? Function(this._parentTemp.replace("@temp", this._transpile()))()
19-
: this._defaultCom;
16+
this._com = this._temp ? Function(this._parentTemp.replace('@temp', this._transpile()))() : this._defaultCom;
2017
}
2118
updateTemplate(template) {
22-
template = template || "";
19+
template = template || '';
2320
if (template !== this._temp) {
2421
this._temp = template;
2522
this._generateCom();

0 commit comments

Comments
 (0)