wgge 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/Collection.js +7 -17
- package/package.json +1 -1
package/core/Collection.js
CHANGED
|
@@ -47,15 +47,11 @@ export default class Collection extends NodeWithEvents {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
removeInternal(index, element) {
|
|
50
|
-
if (index
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
this.triggerEvent('change');
|
|
56
|
-
return element;
|
|
57
|
-
}
|
|
58
|
-
return false;
|
|
50
|
+
if (index < 0 || !element) return false;
|
|
51
|
+
this.items.splice(index, 1);
|
|
52
|
+
this.triggerEvent('remove', element);
|
|
53
|
+
this.triggerEvent('change');
|
|
54
|
+
return element;
|
|
59
55
|
}
|
|
60
56
|
|
|
61
57
|
reset() {
|
|
@@ -85,18 +81,12 @@ export default class Collection extends NodeWithEvents {
|
|
|
85
81
|
|
|
86
82
|
swap(childA, childB) {
|
|
87
83
|
const indexA = this.items.indexOf(childA);
|
|
88
|
-
if (indexA < 0) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
this.removeInternal(indexA, childA);
|
|
92
|
-
|
|
93
84
|
const indexB = this.items.indexOf(childB);
|
|
94
|
-
if (indexB < 0) {
|
|
95
|
-
this.insert(childA, indexA);
|
|
85
|
+
if (indexA < 0 || indexB < 0) {
|
|
96
86
|
return;
|
|
97
87
|
}
|
|
88
|
+
this.removeInternal(indexA, childA);
|
|
98
89
|
this.removeInternal(indexB, childB);
|
|
99
|
-
|
|
100
90
|
this.insert(childA, indexB);
|
|
101
91
|
this.insert(childB, indexA);
|
|
102
92
|
}
|