Skip to content

Commit 061768f

Browse files
committed
- by default update ctx via functional ctx before rendering
1 parent da3200d commit 061768f

File tree

6 files changed

+58
-32
lines changed

6 files changed

+58
-32
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
- remove `setContext()` and `setCtx()`, in favor of `ctx()`.
88

99

10+
## v1.4.0
11+
12+
- by default update ctx via functional ctx before rendering
13+
14+
1015
## v1.3.2
1116

1217
- remove unnecessary log

dist/index.js

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,6 @@
4141
this.root.textContent = '';
4242
this.root.appendChild(this.template.cloneNode(true));
4343
}
44-
if (typeof this._ctx === 'function') {
45-
this._ctx = this._ctx({
46-
node: this.root,
47-
ctxs: this._ctxs,
48-
views: this.views
49-
});
50-
}
5144
this.update();
5245
names = {};
5346
for (i$ = 0, len$ = (ref$ = [(fn$.call(this))].concat([(fn1$.call(this))], [(fn2$.call(this))], [(fn3$.call(this))], [(fn4$.call(this))], (fn5$.call(this)).map(fn6$))).length; i$ < len$; ++i$) {
@@ -232,14 +225,21 @@
232225
}
233226
},
234227
procEach: function(name, data, key, initOnly){
235-
var list, getkey, hash, items, nodes, proxyIndex, ns, i$, i, n, j, node, idx, expectedIdx, _, ps, this$ = this;
228+
var c, list, getkey, hash, items, nodes, proxyIndex, ns, i$, i, n, j, node, idx, expectedIdx, _, ps, this$ = this;
236229
key == null && (key = null);
230+
c = typeof this._ctx === 'function'
231+
? this._ctx({
232+
node: this.root,
233+
ctxs: this._ctxs,
234+
views: this.views
235+
})
236+
: this._ctx;
237237
list = this.handler[name].list({
238238
name: data.name,
239239
node: data.node,
240240
views: this.views,
241-
context: this._ctx,
242-
ctx: this._ctx,
241+
context: c,
242+
ctx: c,
243243
ctxs: this._ctxs
244244
}) || [];
245245
getkey = this.handler[name].key;
@@ -345,9 +345,16 @@
345345
});
346346
},
347347
_render: function(n, d, i, b, e, initOnly){
348-
var init, handler, text, attr, style, action, ref$, k, v, f, results$ = [];
349-
d.ctx = this._ctx;
350-
d.context = this._ctx;
348+
var c, init, handler, text, attr, style, action, ref$, k, v, f, results$ = [];
349+
c = typeof this._ctx === 'function'
350+
? c = this._ctx({
351+
node: this.root,
352+
ctxs: this._ctxs,
353+
views: this.views
354+
})
355+
: this._ctx;
356+
d.ctx = c;
357+
d.context = c;
351358
d.ctxs = this._ctxs;
352359
d.views = this.views;
353360
if (b) {

dist/index.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)