Skip to content

Commit b86a0a1

Browse files
committed
latest modelview 5.0.0
1 parent 9ab9bf1 commit b86a0a1

File tree

4 files changed

+44
-36
lines changed

4 files changed

+44
-36
lines changed

frameworks/keyed/modelview/src/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', {});

frameworks/keyed/modelviews/src/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', {});

frameworks/non-keyed/modelview/src/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', {});

frameworks/non-keyed/modelviews/src/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', {});

0 commit comments

Comments
 (0)