Skip to content

Commit 2da7b41

Browse files
committed
v.5.0.0 contd
* simple mode collection add method, correct space allocation * model isDirty counts wildcard key as well * minor changes
1 parent 4a76d63 commit 2da7b41

7 files changed

Lines changed: 25 additions & 21 deletions

File tree

build/modelview.bundle.js

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

build/modelview.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
*
33
* ModelView.js
44
* @version: 5.0.0
5-
* @built on 2022-03-23 12:05:22
5+
* @built on 2022-03-23 18:38:28
66
*
77
* A simple, light-weight, versatile and fast isomorphic MVVM JavaScript framework (Browser and Server)
88
* https://github.com/foo123/modelview.js
@@ -11,7 +11,7 @@
1111
*
1212
* ModelView.js
1313
* @version: 5.0.0
14-
* @built on 2022-03-23 12:05:22
14+
* @built on 2022-03-23 18:38:28
1515
*
1616
* A simple, light-weight, versatile and fast isomorphic MVVM JavaScript framework (Browser and Server)
1717
* https://github.com/foo123/modelview.js
@@ -450,7 +450,7 @@ function $closest(selector, el)
450450
var found = el.closest(selector);
451451
return found ? [found] : [];
452452
}
453-
else if (el[MATCHES])
453+
else if (MATCHES)
454454
{
455455
while (el)
456456
{
@@ -2692,7 +2692,7 @@ function tpl2codesimplef(tpl)
26922692
{
26932693
end = [p1, p2+3];
26942694
code += tpl2codesimplek(tpl.slice(0, start[0]));
2695-
code += "\n_$$_ += (function(MODEL){var _$$_='',ITEM=function(MODEL){var _$$_='';"+tpl2codesimplef(tpl.slice(start[1], end[0]))+"return _$$_;};if(MODEL){for(var I=0,N=MODEL.get('"+start[2]+".length');I<N;++I){_$$_ += ITEM(MODEL.getProxy('"+start[2]+".'+I, '.'));}}else{_$$_='<!--foreach {"+start[2]+"}-->'+ITEM()+'<!--/foreach-->';}return _$$_;})(MODEL);"
2695+
code += "\n_$$_ += (function(MODEL){var _$$_='',ITEM=function(MODEL){var _$$_='';"+tpl2codesimplef(tpl.slice(start[1], end[0]))+"\nreturn _$$_;};if(MODEL){for(var I=0,N=MODEL.get('"+start[2]+".length');I<N;++I){_$$_ += ITEM(MODEL.getProxy('"+start[2]+".'+I, '.'));}}else{_$$_='<!--foreach {"+start[2]+"}-->'+ITEM()+'<!--/foreach-->';}return _$$_;})(MODEL);"
26962696
tpl = tpl.slice(end[1]);
26972697
offset = 0;
26982698
}
@@ -3154,6 +3154,8 @@ function morphCollectionSimple(view, list, key, collection, isDirty, model, only
31543154
delNodes(null, parentNode, startIndex+1+m*d.from, m*(d.to-d.from+1));
31553155
break;
31563156
case 'add':
3157+
x = new Array(2+d.to-d.from+1); x[0] = d.from; x[1] = 0;
3158+
list.map.splice.apply(list.map, x);
31573159
frag = Fragment();
31583160
iterate(function(index) {
31593161
var node = clone(list);
@@ -4785,8 +4787,8 @@ model.data( [Object data] );
47854787
if (!is_array(ks)) ks = Str(ks).split('.');
47864788
for (c=0,i=0,l=ks.length; i<l; ++i)
47874789
{
4788-
if (!u || !u.k || !HAS.call(u.k, ks[i])) break;
4789-
u = u.k[ks[i]]; //c++;
4790+
if (!u || !u.k || (!HAS.call(u.k, ks[i]) && !HAS.call(u.k, WILDCARD))) break;
4791+
u = (u.k[ks[i]] || u.k[WILDCARD]); //c++;
47904792
if (u.f) return true;
47914793
}
47924794
return false;//(0 < l) && (c === l);
@@ -8111,8 +8113,8 @@ view.render( [Boolean immediate=false] );
81118113
//if ('function' !== typeof morphSimple) throw err('Simple Mode is not included in this build');
81128114
callback = function() {
81138115
view.$reset = {}; view.$cache = null;
8114-
morphSimple(view, view.$map, view.$model, !model || ('sync' === immediate) ? null : true/*model.getDirty()*/);
8115-
nextTick(function(){
8116+
morphSimple(view, view.$map, view.$model, !model || ('sync' === immediate) ? false : true);
8117+
nextTick(function() {
81168118
clearInvalid(view);
81178119
// notify any 3rd-party also if needed
81188120
view.publish('render', {});
@@ -8150,7 +8152,7 @@ view.render( [Boolean immediate=false] );
81508152
view.$cnt = {}; view.$reset = {}; view.$cache['#'] = null;
81518153
morph(view, view.$renderdom, view.$out.call(view, htmlNode));
81528154
view.$cache['#'] = null;
8153-
nextTick(function(){
8155+
nextTick(function() {
81548156
clearInvalid(view);
81558157
// notify any 3rd-party also if needed
81568158
view.publish('render', {});

build/modelview.min.js

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

src/model.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -789,8 +789,8 @@ model.data( [Object data] );
789789
if (!is_array(ks)) ks = Str(ks).split('.');
790790
for (c=0,i=0,l=ks.length; i<l; ++i)
791791
{
792-
if (!u || !u.k || !HAS.call(u.k, ks[i])) break;
793-
u = u.k[ks[i]]; //c++;
792+
if (!u || !u.k || (!HAS.call(u.k, ks[i]) && !HAS.call(u.k, WILDCARD))) break;
793+
u = (u.k[ks[i]] || u.k[WILDCARD]); //c++;
794794
if (u.f) return true;
795795
}
796796
return false;//(0 < l) && (c === l);

src/utils-simple.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function tpl2codesimplef(tpl)
5757
{
5858
end = [p1, p2+3];
5959
code += tpl2codesimplek(tpl.slice(0, start[0]));
60-
code += "\n_$$_ += (function(MODEL){var _$$_='',ITEM=function(MODEL){var _$$_='';"+tpl2codesimplef(tpl.slice(start[1], end[0]))+"return _$$_;};if(MODEL){for(var I=0,N=MODEL.get('"+start[2]+".length');I<N;++I){_$$_ += ITEM(MODEL.getProxy('"+start[2]+".'+I, '.'));}}else{_$$_='<!--foreach {"+start[2]+"}-->'+ITEM()+'<!--/foreach-->';}return _$$_;})(MODEL);"
60+
code += "\n_$$_ += (function(MODEL){var _$$_='',ITEM=function(MODEL){var _$$_='';"+tpl2codesimplef(tpl.slice(start[1], end[0]))+"\nreturn _$$_;};if(MODEL){for(var I=0,N=MODEL.get('"+start[2]+".length');I<N;++I){_$$_ += ITEM(MODEL.getProxy('"+start[2]+".'+I, '.'));}}else{_$$_='<!--foreach {"+start[2]+"}-->'+ITEM()+'<!--/foreach-->';}return _$$_;})(MODEL);"
6161
tpl = tpl.slice(end[1]);
6262
offset = 0;
6363
}
@@ -519,6 +519,8 @@ function morphCollectionSimple(view, list, key, collection, isDirty, model, only
519519
delNodes(null, parentNode, startIndex+1+m*d.from, m*(d.to-d.from+1));
520520
break;
521521
case 'add':
522+
x = new Array(2+d.to-d.from+1); x[0] = d.from; x[1] = 0;
523+
list.map.splice.apply(list.map, x);
522524
frag = Fragment();
523525
iterate(function(index) {
524526
var node = clone(list);

src/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ function $closest(selector, el)
402402
var found = el.closest(selector);
403403
return found ? [found] : [];
404404
}
405-
else if (el[MATCHES])
405+
else if (MATCHES)
406406
{
407407
while (el)
408408
{

src/view.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,8 +1363,8 @@ view.render( [Boolean immediate=false] );
13631363
//if ('function' !== typeof morphSimple) throw err('Simple Mode is not included in this build');
13641364
callback = function() {
13651365
view.$reset = {}; view.$cache = null;
1366-
morphSimple(view, view.$map, view.$model, !model || ('sync' === immediate) ? null : true/*model.getDirty()*/);
1367-
nextTick(function(){
1366+
morphSimple(view, view.$map, view.$model, !model || ('sync' === immediate) ? false : true);
1367+
nextTick(function() {
13681368
clearInvalid(view);
13691369
// notify any 3rd-party also if needed
13701370
view.publish('render', {});
@@ -1402,7 +1402,7 @@ view.render( [Boolean immediate=false] );
14021402
view.$cnt = {}; view.$reset = {}; view.$cache['#'] = null;
14031403
morph(view, view.$renderdom, view.$out.call(view, htmlNode));
14041404
view.$cache['#'] = null;
1405-
nextTick(function(){
1405+
nextTick(function() {
14061406
clearInvalid(view);
14071407
// notify any 3rd-party also if needed
14081408
view.publish('render', {});

0 commit comments

Comments
 (0)