Skip to content

Commit da74c43

Browse files
committed
add xui.deepEqauls
1 parent 1ae10f4 commit da74c43

File tree

6 files changed

+325
-263
lines changed

6 files changed

+325
-263
lines changed

API/App/js/xui-raw.js

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

runtime/xui/js/xui-all.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.

runtime/xui/js/xui-debug.js

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,32 @@ new function(){
628628
}else return hash;
629629
}else return hash;
630630
},
631+
deepEquals:function(x, y, deep, ignore, _curLayer){
632+
if(!xui.isSet(deep)) deep=100;
633+
if(!xui.isSet(_curLayer))_curLayer = 1;
634+
635+
if (x === y) return true;
636+
if (!(x instanceof Object) || !(y instanceof Object)) return false;
637+
if (x.constructor !== y.constructor) return false;
638+
for (let p in x) {
639+
if (ignore && ignore(p)) continue;
640+
if (!x.hasOwnProperty(p)) continue;
641+
if (!y.hasOwnProperty(p)) return false;
642+
if (x[p] === y[p]) continue;
643+
if (typeof x[p] !== "object") return false;
644+
if (xui.isHash(x[p]) && xui.isHash(y[p]) && xui.isEmpty(x[p])&& xui.isEmpty(y[p])) continue;
645+
if (xui.isArr(x[p]) && xui.isArr(y[p]) && x[p].length === 0 && y[p].length === 0) continue;
646+
if (_curLayer >= deep) {
647+
if (x[p] !== y[p]) return false;
648+
continue;
649+
} else if (!xui.deepEquals(x[p], y[p], deep, ignore, _curLayer + 1))
650+
return false;
651+
}
652+
for (let p in y) {
653+
if (y.hasOwnProperty(p) && !x.hasOwnProperty(p)) return false;
654+
}
655+
return true;
656+
},
631657
/*filter hash/array
632658
filter: filter function(will delete "return false")
633659
*/
@@ -54343,7 +54369,10 @@ xui.Class("xui.UI.TreeGrid",["xui.UI","xui.absValue"],{
5434354369
});
5434454370
if(profile.beforePopShow)
5434554371
editor.beforePopShow(function(editorprf, popCtl, items){
54346-
return profile.boxing().beforePopShow(profile, editorprf.$cell, editorprf, popCtl, items, editorprf.$cell._row, editorprf.$cell._col);
54372+
var rst;
54373+
if(editorEvents && editorEvents.beforePopShow)rst = editorEvents.beforePopShow(editorprf, popCtl, items);
54374+
rst = profile.boxing().beforePopShow(profile, editorprf.$cell, editorprf, popCtl, items, editorprf.$cell._row, editorprf.$cell._col);
54375+
return rst;
5434754376
});
5434854377
if(profile.afterPopShow)
5434954378
editor.afterPopShow(function(editorprf, popCtl){
@@ -54706,12 +54735,13 @@ xui.Class("xui.UI.TreeGrid",["xui.UI","xui.absValue"],{
5470654735
},dfun=function(){
5470754736
// if(editor) xui.tryF(editor.undo,[],editor);
5470854737
};
54709-
editor.onFocus(bfun).beforePopShow(function(editorPrf, popCtl,items){
54738+
editor.onFocus(bfun).beforePopShow(function(editorprf, popCtl,items){
5471054739
bfun();
5471154740
editor.onBlur(null);
54712-
// for compitable
54713-
if(profile.beforePopShow)
54714-
return profile.boxing().beforePopShow(profile, editorPrf.$cell, editorPrf, popCtl, items, editorPrf.$cell._row, editorPrf.$cell_col);
54741+
var rst;
54742+
if(editorEvents && editorEvents.beforePopShow)rst = editorEvents.beforePopShow(editorprf, popCtl, items);
54743+
if(profile.beforePopShow)rst = profile.boxing().beforePopShow(profile, editorprf.$cell, editorprf, popCtl, items, editorprf.$cell._row, editorprf.$cell_col);
54744+
return rst;
5471554745
}).afterPopHide(function(){
5471654746
cfun();
5471754747
editor.onBlur(dfun);

runtime/xui/js/xui.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.

xui/js/UI/TreeGrid.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6889,7 +6889,10 @@ xui.Class("xui.UI.TreeGrid",["xui.UI","xui.absValue"],{
68896889
});
68906890
if(profile.beforePopShow)
68916891
editor.beforePopShow(function(editorprf, popCtl, items){
6892-
return profile.boxing().beforePopShow(profile, editorprf.$cell, editorprf, popCtl, items, editorprf.$cell._row, editorprf.$cell._col);
6892+
var rst;
6893+
if(editorEvents && editorEvents.beforePopShow)rst = editorEvents.beforePopShow(editorprf, popCtl, items);
6894+
rst = profile.boxing().beforePopShow(profile, editorprf.$cell, editorprf, popCtl, items, editorprf.$cell._row, editorprf.$cell._col);
6895+
return rst;
68936896
});
68946897
if(profile.afterPopShow)
68956898
editor.afterPopShow(function(editorprf, popCtl){
@@ -7252,12 +7255,13 @@ xui.Class("xui.UI.TreeGrid",["xui.UI","xui.absValue"],{
72527255
},dfun=function(){
72537256
// if(editor) xui.tryF(editor.undo,[],editor);
72547257
};
7255-
editor.onFocus(bfun).beforePopShow(function(editorPrf, popCtl,items){
7258+
editor.onFocus(bfun).beforePopShow(function(editorprf, popCtl,items){
72567259
bfun();
72577260
editor.onBlur(null);
7258-
// for compitable
7259-
if(profile.beforePopShow)
7260-
return profile.boxing().beforePopShow(profile, editorPrf.$cell, editorPrf, popCtl, items, editorPrf.$cell._row, editorPrf.$cell_col);
7261+
var rst;
7262+
if(editorEvents && editorEvents.beforePopShow)rst = editorEvents.beforePopShow(editorprf, popCtl, items);
7263+
if(profile.beforePopShow)rst = profile.boxing().beforePopShow(profile, editorprf.$cell, editorprf, popCtl, items, editorprf.$cell._row, editorprf.$cell_col);
7264+
return rst;
72617265
}).afterPopHide(function(){
72627266
cfun();
72637267
editor.onBlur(dfun);

xui/js/xui.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,32 @@ new function(){
620620
}else return hash;
621621
}else return hash;
622622
},
623+
deepEquals:function(x, y, deep, ignore, _curLayer){
624+
if(!xui.isSet(deep)) deep=100;
625+
if(!xui.isSet(_curLayer))_curLayer = 1;
626+
627+
if (x === y) return true;
628+
if (!(x instanceof Object) || !(y instanceof Object)) return false;
629+
if (x.constructor !== y.constructor) return false;
630+
for (let p in x) {
631+
if (ignore && ignore(p)) continue;
632+
if (!x.hasOwnProperty(p)) continue;
633+
if (!y.hasOwnProperty(p)) return false;
634+
if (x[p] === y[p]) continue;
635+
if (typeof x[p] !== "object") return false;
636+
if (xui.isHash(x[p]) && xui.isHash(y[p]) && xui.isEmpty(x[p])&& xui.isEmpty(y[p])) continue;
637+
if (xui.isArr(x[p]) && xui.isArr(y[p]) && x[p].length === 0 && y[p].length === 0) continue;
638+
if (_curLayer >= deep) {
639+
if (x[p] !== y[p]) return false;
640+
continue;
641+
} else if (!xui.deepEquals(x[p], y[p], deep, ignore, _curLayer + 1))
642+
return false;
643+
}
644+
for (let p in y) {
645+
if (y.hasOwnProperty(p) && !x.hasOwnProperty(p)) return false;
646+
}
647+
return true;
648+
},
623649
/*filter hash/array
624650
filter: filter function(will delete "return false")
625651
*/

0 commit comments

Comments
 (0)