lahama 2.2.0 → 2.4.0
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/dist/lahama.js +27 -23
- package/package.json +1 -1
package/dist/lahama.js
CHANGED
|
@@ -70,7 +70,7 @@ class ArrayWithOriginalIndices {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
isAddition(item, fromIdx) {
|
|
73
|
-
return this.findIndexFrom(item, fromIdx === -1
|
|
73
|
+
return this.findIndexFrom(item, fromIdx) === -1
|
|
74
74
|
}
|
|
75
75
|
findIndexFrom(item, fromIndex) {
|
|
76
76
|
for (let i = fromIndex; i < this.length; i++) {
|
|
@@ -122,22 +122,27 @@ function arraysDiffSequence(
|
|
|
122
122
|
const sequence = [];
|
|
123
123
|
const array = new ArrayWithOriginalIndices(oldArray, equalsFn);
|
|
124
124
|
for (let index = 0; index < newArray.length; index++) {
|
|
125
|
+
//!REMOVE CASE
|
|
125
126
|
if (array.isRemoval(index, newArray)) {
|
|
126
127
|
sequence.push(array.removeItem(index));
|
|
127
128
|
index--;
|
|
128
129
|
continue
|
|
129
130
|
}
|
|
131
|
+
//!noop case
|
|
130
132
|
if (array.isNoop(index, newArray)) {
|
|
131
133
|
sequence.push(array.noopItem(index));
|
|
132
134
|
continue
|
|
133
135
|
}
|
|
136
|
+
//!addition case
|
|
134
137
|
const item = newArray[index];
|
|
135
138
|
if (array.isAddition(item , index)) {
|
|
136
139
|
sequence.push(array.addItem(item, index));
|
|
137
140
|
continue
|
|
138
141
|
}
|
|
142
|
+
//!move case
|
|
139
143
|
sequence.push(array.moveItem(item, index));
|
|
140
144
|
}
|
|
145
|
+
//!remove extra items
|
|
141
146
|
sequence.push(...array.removeItemsAfter(newArray.length));
|
|
142
147
|
return sequence
|
|
143
148
|
}
|
|
@@ -169,14 +174,24 @@ function hFragment(vNodes) {
|
|
|
169
174
|
}
|
|
170
175
|
}
|
|
171
176
|
|
|
172
|
-
function addEventListener
|
|
173
|
-
|
|
174
|
-
|
|
177
|
+
function addEventListener(
|
|
178
|
+
eventName,
|
|
179
|
+
handler,
|
|
180
|
+
el,
|
|
181
|
+
hostComponent = null
|
|
182
|
+
) {
|
|
183
|
+
function boundHandler() {
|
|
184
|
+
hostComponent
|
|
185
|
+
? handler.apply(hostComponent, arguments)
|
|
186
|
+
: handler(...arguments);
|
|
187
|
+
}
|
|
188
|
+
el.addEventListener(eventName, boundHandler);
|
|
189
|
+
return boundHandler
|
|
175
190
|
}
|
|
176
191
|
function addEventListeners(listeners = {}, el) {
|
|
177
192
|
const addedListeners = {};
|
|
178
193
|
Object.entries(listeners).forEach(([eventName, handler]) => {
|
|
179
|
-
addedListeners[eventName] =
|
|
194
|
+
addedListeners[eventName] = addEventListenerCustom(eventName, handler, el);
|
|
180
195
|
});
|
|
181
196
|
return addedListeners
|
|
182
197
|
}
|
|
@@ -404,11 +419,11 @@ function patchDOM(oldVdom, newVdom, parentEl) {
|
|
|
404
419
|
}
|
|
405
420
|
newVdom.el = oldVdom.el;
|
|
406
421
|
switch (newVdom.type) {
|
|
407
|
-
case DOM_TYPES.TEXT
|
|
422
|
+
case DOM_TYPES.TEXT: {
|
|
408
423
|
patchText(oldVdom, newVdom);
|
|
409
424
|
return newVdom
|
|
410
425
|
}
|
|
411
|
-
case DOM_TYPES.ELEMENT
|
|
426
|
+
case DOM_TYPES.ELEMENT: {
|
|
412
427
|
patchElement(oldVdom, newVdom);
|
|
413
428
|
break
|
|
414
429
|
}
|
|
@@ -436,16 +451,16 @@ function findIndexInParent(parentEl, el) {
|
|
|
436
451
|
const {
|
|
437
452
|
class : oldClass,
|
|
438
453
|
style : oldStyle,
|
|
439
|
-
on
|
|
454
|
+
on: oldEvents,
|
|
440
455
|
...oldAttrs
|
|
441
456
|
} = oldVdom.props;
|
|
442
457
|
const {
|
|
443
|
-
class
|
|
444
|
-
style
|
|
445
|
-
on
|
|
458
|
+
class: newClass,
|
|
459
|
+
style: newStyle,
|
|
460
|
+
on: newEvents,
|
|
446
461
|
...newAttrs
|
|
447
462
|
} = newVdom.props;
|
|
448
|
-
const { listeners
|
|
463
|
+
const { listeners: oldListeners } = oldVdom;
|
|
449
464
|
patchAttrs(el, oldAttrs, newAttrs);
|
|
450
465
|
patchClasses(el, oldClass, newClass);
|
|
451
466
|
patchStyles(el, oldStyle, newStyle);
|
|
@@ -487,17 +502,6 @@ function patchStyles(el, oldStyle = {}, newStyle = {}) {
|
|
|
487
502
|
setStyle(el, style, newStyle[style]);
|
|
488
503
|
}
|
|
489
504
|
}
|
|
490
|
-
function addEventListener(eventName, handler, el) {
|
|
491
|
-
function boundHandler(event) {
|
|
492
|
-
handler(event);
|
|
493
|
-
}
|
|
494
|
-
el.addEventListener(eventName, boundHandler);
|
|
495
|
-
//!el.addEventListener("click", boundHandler) {
|
|
496
|
-
//! Element: el
|
|
497
|
-
//! Event: "click"
|
|
498
|
-
//! Listener : boundHandler!}
|
|
499
|
-
return boundHandler
|
|
500
|
-
}
|
|
501
505
|
function patchEvents(
|
|
502
506
|
el,
|
|
503
507
|
oldListeners = {},
|