ソースを参照

Table: change argument selection to cloned array in selection-change event (#9551)

FuryBean 7 年 前
コミット
b27f340561
1 ファイル変更5 行追加5 行削除
  1. 5 5
      packages/table/src/table-store.js

+ 5 - 5
packages/table/src/table-store.js

@@ -289,7 +289,7 @@ TableStore.prototype.mutations = {
 
     if (changed) {
       const table = this.table;
-      table.$emit('selection-change', selection);
+      table.$emit('selection-change', selection ? selection.slice() : []);
       table.$emit('select', selection, row);
     }
 
@@ -317,7 +317,7 @@ TableStore.prototype.mutations = {
 
     const table = this.table;
     if (selectionChanged) {
-      table.$emit('selection-change', selection);
+      table.$emit('selection-change', selection ? selection.slice() : []);
     }
     table.$emit('select-all', selection);
     states.isAllSelected = value;
@@ -372,7 +372,7 @@ TableStore.prototype.clearSelection = function() {
   const oldSelection = states.selection;
   states.selection = [];
   if (oldSelection.length > 0) {
-    this.table.$emit('selection-change', states.selection);
+    this.table.$emit('selection-change', states.selection ? states.selection.slice() : []);
   }
 };
 
@@ -395,7 +395,7 @@ TableStore.prototype.setExpandRowKeys = function(rowKeys) {
 TableStore.prototype.toggleRowSelection = function(row, selected) {
   const changed = toggleRowSelection(this.states, row, selected);
   if (changed) {
-    this.table.$emit('selection-change', this.states.selection);
+    this.table.$emit('selection-change', this.states.selection ? this.states.selection.slice() : []);
   }
 };
 
@@ -440,7 +440,7 @@ TableStore.prototype.cleanSelection = function() {
   });
 
   if (deleted.length) {
-    this.table.$emit('selection-change', selection);
+    this.table.$emit('selection-change', selection ? selection.slice() : []);
   }
 };