@lvce-editor/virtual-dom 1.12.0 → 1.14.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/index.js
CHANGED
|
@@ -220,7 +220,12 @@ var getElementTag = (type) => {
|
|
|
220
220
|
};
|
|
221
221
|
|
|
222
222
|
// src/parts/GetEventListenerOptions/GetEventListenerOptions.ts
|
|
223
|
-
var getEventListenerOptions = (eventName) => {
|
|
223
|
+
var getEventListenerOptions = (eventName, value) => {
|
|
224
|
+
if (value.passive) {
|
|
225
|
+
return {
|
|
226
|
+
passive: true
|
|
227
|
+
};
|
|
228
|
+
}
|
|
224
229
|
switch (eventName) {
|
|
225
230
|
case "wheel":
|
|
226
231
|
return {
|
|
@@ -313,9 +318,19 @@ var getWrappedListener = (listener, returnValue) => {
|
|
|
313
318
|
};
|
|
314
319
|
|
|
315
320
|
// src/parts/AttachEvent/AttachEvent.ts
|
|
321
|
+
var getOptions = (fn) => {
|
|
322
|
+
if (fn.passive) {
|
|
323
|
+
return {
|
|
324
|
+
passive: true
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
return void 0;
|
|
328
|
+
};
|
|
316
329
|
var attachEvent = ($Node, eventMap, key, value, newEventMap) => {
|
|
317
330
|
if (newEventMap && newEventMap[value]) {
|
|
318
|
-
|
|
331
|
+
const fn = newEventMap[value];
|
|
332
|
+
const options2 = getOptions(fn);
|
|
333
|
+
$Node.addEventListener(key, newEventMap[value], options2);
|
|
319
334
|
return;
|
|
320
335
|
}
|
|
321
336
|
const listener = eventMap[value];
|
|
@@ -323,7 +338,7 @@ var attachEvent = ($Node, eventMap, key, value, newEventMap) => {
|
|
|
323
338
|
console.warn("listener not found", value);
|
|
324
339
|
return;
|
|
325
340
|
}
|
|
326
|
-
const options = getEventListenerOptions(key);
|
|
341
|
+
const options = getEventListenerOptions(key, value);
|
|
327
342
|
const wrapped = getWrappedListener(
|
|
328
343
|
listener,
|
|
329
344
|
eventMap.returnValue
|
|
@@ -583,6 +598,9 @@ var createFn = (info) => {
|
|
|
583
598
|
ipc.send("Viewlet.executeViewletCommand", uid, ...args);
|
|
584
599
|
};
|
|
585
600
|
nameAnonymousFunction(fn, info.name);
|
|
601
|
+
if (info.passive) {
|
|
602
|
+
fn.passive = true;
|
|
603
|
+
}
|
|
586
604
|
return fn;
|
|
587
605
|
};
|
|
588
606
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import * as GetEventListenerOptions from '../GetEventListenerOptions/GetEventListenerOptions.ts'
|
|
2
2
|
import * as GetWrappedListener from '../GetWrappedListener/GetWrappedListener.ts'
|
|
3
3
|
|
|
4
|
+
const getOptions = (fn: any) => {
|
|
5
|
+
if (fn.passive) {
|
|
6
|
+
return {
|
|
7
|
+
passive: true,
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
return undefined
|
|
11
|
+
}
|
|
12
|
+
|
|
4
13
|
export const attachEvent = (
|
|
5
14
|
$Node: HTMLElement,
|
|
6
15
|
eventMap: any,
|
|
@@ -9,8 +18,10 @@ export const attachEvent = (
|
|
|
9
18
|
newEventMap?: any,
|
|
10
19
|
) => {
|
|
11
20
|
if (newEventMap && newEventMap[value]) {
|
|
21
|
+
const fn = newEventMap[value]
|
|
22
|
+
const options: any = getOptions(fn)
|
|
12
23
|
// TODO support event listener options
|
|
13
|
-
$Node.addEventListener(key, newEventMap[value])
|
|
24
|
+
$Node.addEventListener(key, newEventMap[value], options)
|
|
14
25
|
return
|
|
15
26
|
}
|
|
16
27
|
const listener = eventMap[value]
|
|
@@ -18,7 +29,7 @@ export const attachEvent = (
|
|
|
18
29
|
console.warn('listener not found', value)
|
|
19
30
|
return
|
|
20
31
|
}
|
|
21
|
-
const options = GetEventListenerOptions.getEventListenerOptions(key)
|
|
32
|
+
const options = GetEventListenerOptions.getEventListenerOptions(key, value)
|
|
22
33
|
const wrapped = GetWrappedListener.getWrappedListener(
|
|
23
34
|
listener,
|
|
24
35
|
eventMap.returnValue,
|
|
@@ -17,5 +17,9 @@ export const createFn = (info) => {
|
|
|
17
17
|
ipc.send('Viewlet.executeViewletCommand', uid, ...args)
|
|
18
18
|
}
|
|
19
19
|
NameAnonymousFunction.nameAnonymousFunction(fn, info.name)
|
|
20
|
+
if (info.passive) {
|
|
21
|
+
// TODO avoid mutating function property, maybe return an object with function and options
|
|
22
|
+
fn.passive = true
|
|
23
|
+
}
|
|
20
24
|
return fn
|
|
21
25
|
}
|