Răsfoiți Sursa

fix: for循环遍历时,判空

wxl 5 ani în urmă
părinte
comite
ad2e7511af

+ 3 - 1
libs/doesburg.common.js

@@ -3934,6 +3934,8 @@ function util_getFirstSetValue() {
   return args[l - 1];
 }
 function forEach(arr, callBack) {
+  if (!arr || !arr.length) return;
+
   for (var i = 0, j = arr.length; i < j; i++) {
     callBack && callBack(arr[i], i);
   }
@@ -4622,7 +4624,7 @@ function () {
     value: function _moveUpAll() {
       var me = this;
       forEach(this.coors, function (row) {
-        forEach(row, function (cell) {
+        forEach(row || [], function (cell) {
           if (!cell || cell.y === 0) return;
           var canUpRows = me.getEmptyRowsBeforeLine(cell.x, cell.y, cell.w);
           cell.fill(null);

Fișier diff suprimat deoarece este prea mare
+ 0 - 0
libs/doesburg.common.js.map


+ 3 - 1
libs/doesburg.umd.js

@@ -3943,6 +3943,8 @@ function util_getFirstSetValue() {
   return args[l - 1];
 }
 function forEach(arr, callBack) {
+  if (!arr || !arr.length) return;
+
   for (var i = 0, j = arr.length; i < j; i++) {
     callBack && callBack(arr[i], i);
   }
@@ -4631,7 +4633,7 @@ function () {
     value: function _moveUpAll() {
       var me = this;
       forEach(this.coors, function (row) {
-        forEach(row, function (cell) {
+        forEach(row || [], function (cell) {
           if (!cell || cell.y === 0) return;
           var canUpRows = me.getEmptyRowsBeforeLine(cell.x, cell.y, cell.w);
           cell.fill(null);

Fișier diff suprimat deoarece este prea mare
+ 0 - 0
libs/doesburg.umd.js.map


Fișier diff suprimat deoarece este prea mare
+ 0 - 0
libs/doesburg.umd.min.js


Fișier diff suprimat deoarece este prea mare
+ 0 - 0
libs/doesburg.umd.min.js.map


+ 1 - 0
src/utils/util.js

@@ -61,6 +61,7 @@ export function getFirstSetValue(){
 }
 
 export function forEach(arr, callBack){
+    if(!arr || !arr.length) return;
 	for(let i = 0, j = arr.length; i < j; i++){
 		callBack && callBack(arr[i], i);
 	}

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff