Skip to content

Commit 1e5449a

Browse files
committed
- support functional ctx parameter for returning customized context especially useful for nested views.
1 parent 9f3acae commit 1e5449a

File tree

8 files changed

+25
-5
lines changed

8 files changed

+25
-5
lines changed

CHANGELOG.md

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

9+
## v1.3.0
10+
11+
- support functional `ctx` parameter for returning customized context especially useful for nested views.
12+
13+
914
## v1.2.1
1015

1116
- fix bug: `ctx()` should test argument's existence with `arguments.length`

dist/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@
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+
}
4451
this.update();
4552
names = {};
4653
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$) {

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.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"browser": "dist/index.min.js",
66
"main": "dist/index.min.js",
77
"description": "view template micro framework",
8-
"version": "1.2.1",
8+
"version": "1.3.0",
99
"files": [
1010
"dist/**/*"
1111
],

src/ldview.ls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ ldview = (opt = {}) ->
2929
if (@template = opt.template) =>
3030
@root.textContent = ''
3131
@root.appendChild @template.cloneNode(true)
32+
if typeof(@_ctx) == \function => @_ctx = @_ctx {node: @root, ctxs: @_ctxs, views: @views}
3233

3334
@update!
3435

web/static/assets/lib/ldview/dev/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@
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+
}
4451
this.update();
4552
names = {};
4653
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$) {

web/static/assets/lib/ldview/dev/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)