@whitesev/pops 4.2.0 → 4.2.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/dist/index.amd.js +169 -145
- package/dist/index.amd.js.map +1 -1
- package/dist/index.amd.min.js +1 -1
- package/dist/index.amd.min.js.map +1 -1
- package/dist/index.cjs.js +169 -145
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.cjs.min.js.map +1 -1
- package/dist/index.esm.js +169 -145
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/index.iife.js +169 -145
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +1 -1
- package/dist/index.iife.min.js.map +1 -1
- package/dist/index.system.js +169 -145
- package/dist/index.system.js.map +1 -1
- package/dist/index.system.min.js +1 -1
- package/dist/index.system.min.js.map +1 -1
- package/dist/index.umd.js +169 -145
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/types/src/Pops.d.ts +10 -10
- package/dist/types/src/types/PopsDOMUtilsEventType.d.ts +3 -3
- package/dist/types/src/utils/PopsDOMUtils.d.ts +11 -11
- package/package.json +1 -1
- package/src/types/PopsDOMUtilsEventType.d.ts +3 -3
- package/src/utils/PopsDOMUtils.ts +159 -138
package/dist/index.system.js
CHANGED
|
@@ -3,7 +3,7 @@ System.register('pops', [], (function (exports) {
|
|
|
3
3
|
return {
|
|
4
4
|
execute: (function () {
|
|
5
5
|
|
|
6
|
-
const version = "4.2.
|
|
6
|
+
const version = "4.2.2";
|
|
7
7
|
|
|
8
8
|
const GlobalConfig = {
|
|
9
9
|
config: {},
|
|
@@ -247,6 +247,24 @@ System.register('pops', [], (function (exports) {
|
|
|
247
247
|
},
|
|
248
248
|
};
|
|
249
249
|
|
|
250
|
+
/**
|
|
251
|
+
* 通用的CSS类名
|
|
252
|
+
*/
|
|
253
|
+
const PopsCommonCSSClassName = {
|
|
254
|
+
flexCenter: "pops-flex-items-center",
|
|
255
|
+
flexYCenter: "pops-flex-y-center",
|
|
256
|
+
flexXCenter: "pops-flex-x-center",
|
|
257
|
+
hide: "pops-hide",
|
|
258
|
+
hideImportant: "pops-hide-important",
|
|
259
|
+
noBorder: "pops-no-border",
|
|
260
|
+
noBorderImportant: "pops-no-border-important",
|
|
261
|
+
userSelectNone: "pops-user-select-none",
|
|
262
|
+
lineHeightCenter: "pops-line-height-center",
|
|
263
|
+
widthFill: "pops-width-fill",
|
|
264
|
+
textIsDisabled: "pops-text-is-disabled",
|
|
265
|
+
textIsDisabledImportant: "pops-text-is-disabled-important",
|
|
266
|
+
};
|
|
267
|
+
|
|
250
268
|
const OriginPrototype = {
|
|
251
269
|
Object: {
|
|
252
270
|
defineProperty: Object.defineProperty,
|
|
@@ -296,6 +314,30 @@ System.register('pops', [], (function (exports) {
|
|
|
296
314
|
},
|
|
297
315
|
};
|
|
298
316
|
|
|
317
|
+
const PopsSafeUtils = {
|
|
318
|
+
/**
|
|
319
|
+
* 获取安全的html
|
|
320
|
+
*/
|
|
321
|
+
getSafeHTML(text) {
|
|
322
|
+
if (window.trustedTypes) {
|
|
323
|
+
const policy = window.trustedTypes.createPolicy("safe-innerHTML", {
|
|
324
|
+
createHTML: (html) => html,
|
|
325
|
+
});
|
|
326
|
+
return policy.createHTML(text);
|
|
327
|
+
}
|
|
328
|
+
else {
|
|
329
|
+
return text;
|
|
330
|
+
}
|
|
331
|
+
},
|
|
332
|
+
/**
|
|
333
|
+
* 设置安全的html
|
|
334
|
+
*/
|
|
335
|
+
setSafeHTML($el, text) {
|
|
336
|
+
// 创建 TrustedHTML 策略(需 CSP 允许)
|
|
337
|
+
$el.innerHTML = this.getSafeHTML(text);
|
|
338
|
+
},
|
|
339
|
+
};
|
|
340
|
+
|
|
299
341
|
const n$1="clientX",e$2="clientY",t$1=16,c$3="start",o$1="move",s$1="cancel",u$3="end",a$2="left",i$3="right",r$4="up",d$1="down",m$2={4:"start",5:"move",1:"end",3:"cancel"};function v$1(n){return m$2[n]}function b(n,e,t){const c={1:{0:{move:4},4:{move:5,end:1,cancel:3},5:{move:5,end:1,cancel:3}},0:{4:{move:2,end:1,cancel:3},5:{start:2,move:2,end:1,cancel:3}}}[Number(n)][e];return void 0!==c&&c[t]||0}function g$1(n){[1,3,2].includes(n.state)&&(n.state=0);}function h$3(n){return [5,1,3].includes(n)}function j(n){if(n.disabled)return n.state=0,true}function O(n,e){return Object.assign(Object.assign(Object.assign({},n),e),{state:0,disabled:false})}function p$3(n){return Math.round(100*n)/100}
|
|
300
342
|
|
|
301
343
|
var x=r=>Math.sqrt(r.x*r.x+r.y*r.y),y=(r,a)=>r.x*a.x+r.y*a.y,e$1=(r,a)=>{var t=x(r)*x(a);if(0===t)return 0;var h=y(r,a)/t;return h>1&&(h=1),Math.acos(h)},n=(r,a)=>r.x*a.y-a.x*r.y,o=r=>r/Math.PI*180,s=(r,a)=>{var t=e$1(r,a);return n(r,a)>0&&(t*=-1),o(t)},u$2=(x,y)=>{if(0!==x||0!==y)return Math.abs(x)>=Math.abs(y)?0<x?i$3:a$2:0<y?d$1:r$4};
|
|
@@ -765,48 +807,6 @@ System.register('pops', [], (function (exports) {
|
|
|
765
807
|
}
|
|
766
808
|
const popsUtils = new PopsUtils();
|
|
767
809
|
|
|
768
|
-
const PopsSafeUtils = {
|
|
769
|
-
/**
|
|
770
|
-
* 获取安全的html
|
|
771
|
-
*/
|
|
772
|
-
getSafeHTML(text) {
|
|
773
|
-
if (window.trustedTypes) {
|
|
774
|
-
const policy = window.trustedTypes.createPolicy("safe-innerHTML", {
|
|
775
|
-
createHTML: (html) => html,
|
|
776
|
-
});
|
|
777
|
-
return policy.createHTML(text);
|
|
778
|
-
}
|
|
779
|
-
else {
|
|
780
|
-
return text;
|
|
781
|
-
}
|
|
782
|
-
},
|
|
783
|
-
/**
|
|
784
|
-
* 设置安全的html
|
|
785
|
-
*/
|
|
786
|
-
setSafeHTML($el, text) {
|
|
787
|
-
// 创建 TrustedHTML 策略(需 CSP 允许)
|
|
788
|
-
$el.innerHTML = this.getSafeHTML(text);
|
|
789
|
-
},
|
|
790
|
-
};
|
|
791
|
-
|
|
792
|
-
/**
|
|
793
|
-
* 通用的CSS类名
|
|
794
|
-
*/
|
|
795
|
-
const PopsCommonCSSClassName = {
|
|
796
|
-
flexCenter: "pops-flex-items-center",
|
|
797
|
-
flexYCenter: "pops-flex-y-center",
|
|
798
|
-
flexXCenter: "pops-flex-x-center",
|
|
799
|
-
hide: "pops-hide",
|
|
800
|
-
hideImportant: "pops-hide-important",
|
|
801
|
-
noBorder: "pops-no-border",
|
|
802
|
-
noBorderImportant: "pops-no-border-important",
|
|
803
|
-
userSelectNone: "pops-user-select-none",
|
|
804
|
-
lineHeightCenter: "pops-line-height-center",
|
|
805
|
-
widthFill: "pops-width-fill",
|
|
806
|
-
textIsDisabled: "pops-text-is-disabled",
|
|
807
|
-
textIsDisabledImportant: "pops-text-is-disabled-important",
|
|
808
|
-
};
|
|
809
|
-
|
|
810
810
|
/**
|
|
811
811
|
* 存储在元素属性上的事件名
|
|
812
812
|
*/
|
|
@@ -819,7 +819,7 @@ System.register('pops', [], (function (exports) {
|
|
|
819
819
|
* @param startIndex
|
|
820
820
|
* @param option
|
|
821
821
|
*/
|
|
822
|
-
function
|
|
822
|
+
const getOption = function (args, startIndex, option) {
|
|
823
823
|
const currentParam = args[startIndex];
|
|
824
824
|
if (typeof currentParam === "boolean") {
|
|
825
825
|
option.capture = currentParam;
|
|
@@ -841,7 +841,7 @@ System.register('pops', [], (function (exports) {
|
|
|
841
841
|
option.isComposedPath = currentParam.isComposedPath;
|
|
842
842
|
}
|
|
843
843
|
return option;
|
|
844
|
-
}
|
|
844
|
+
};
|
|
845
845
|
const that = this;
|
|
846
846
|
// eslint-disable-next-line prefer-rest-params
|
|
847
847
|
const args = arguments;
|
|
@@ -856,8 +856,7 @@ System.register('pops', [], (function (exports) {
|
|
|
856
856
|
}
|
|
857
857
|
let $elList = [];
|
|
858
858
|
if (element instanceof NodeList || Array.isArray(element)) {
|
|
859
|
-
|
|
860
|
-
$elList = [...element];
|
|
859
|
+
$elList = $elList.concat(Array.from(element));
|
|
861
860
|
}
|
|
862
861
|
else {
|
|
863
862
|
$elList.push(element);
|
|
@@ -865,15 +864,15 @@ System.register('pops', [], (function (exports) {
|
|
|
865
864
|
// 事件名
|
|
866
865
|
let eventTypeList = [];
|
|
867
866
|
if (Array.isArray(eventType)) {
|
|
868
|
-
eventTypeList = eventTypeList.concat(eventType.filter((
|
|
867
|
+
eventTypeList = eventTypeList.concat(eventType.filter((it) => typeof it === "string" && it.toString() !== ""));
|
|
869
868
|
}
|
|
870
869
|
else if (typeof eventType === "string") {
|
|
871
|
-
eventTypeList = eventTypeList.concat(eventType.split(" ").filter((
|
|
870
|
+
eventTypeList = eventTypeList.concat(eventType.split(" ").filter((it) => it !== ""));
|
|
872
871
|
}
|
|
873
872
|
// 子元素选择器
|
|
874
873
|
let selectorList = [];
|
|
875
874
|
if (Array.isArray(selector)) {
|
|
876
|
-
selectorList = selectorList.concat(selector.filter((
|
|
875
|
+
selectorList = selectorList.concat(selector.filter((it) => typeof it === "string" && it.toString() !== ""));
|
|
877
876
|
}
|
|
878
877
|
else if (typeof selector === "string") {
|
|
879
878
|
selectorList.push(selector);
|
|
@@ -897,83 +896,105 @@ System.register('pops', [], (function (exports) {
|
|
|
897
896
|
// 这是存在selector的情况
|
|
898
897
|
listenerOption = getOption(args, 4, listenerOption);
|
|
899
898
|
}
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
let
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
}
|
|
932
|
-
// 在上层与主元素之间寻找可以被selector所匹配到的
|
|
933
|
-
const $closestMatches = that.closest(eventTarget, selectorItem);
|
|
934
|
-
if ($closestMatches && totalParent?.contains($closestMatches)) {
|
|
935
|
-
eventTarget = $closestMatches;
|
|
936
|
-
return true;
|
|
937
|
-
}
|
|
938
|
-
return false;
|
|
939
|
-
});
|
|
940
|
-
if (findValue) {
|
|
941
|
-
// 这里尝试使用defineProperty修改event的target值
|
|
942
|
-
try {
|
|
943
|
-
OriginPrototype.Object.defineProperty(event, "target", {
|
|
944
|
-
get() {
|
|
945
|
-
return eventTarget;
|
|
946
|
-
},
|
|
947
|
-
});
|
|
899
|
+
$elList.forEach(($elItem) => {
|
|
900
|
+
// 遍历事件名设置元素事件
|
|
901
|
+
eventTypeList.forEach((eventName) => {
|
|
902
|
+
/**
|
|
903
|
+
* 如果是option.once,那么删除该监听和元素上的事件和监听
|
|
904
|
+
*/
|
|
905
|
+
const checkOptionOnceToRemoveEventListener = () => {
|
|
906
|
+
if (listenerOption.once) {
|
|
907
|
+
this.off($elItem, eventName, selector, callback, option);
|
|
908
|
+
}
|
|
909
|
+
};
|
|
910
|
+
/**
|
|
911
|
+
* 事件回调
|
|
912
|
+
* @param event
|
|
913
|
+
*/
|
|
914
|
+
const handlerCallBack = function (event) {
|
|
915
|
+
let call_this = void 0;
|
|
916
|
+
let call_event = void 0;
|
|
917
|
+
let call_$selector = void 0;
|
|
918
|
+
let execCallback = false;
|
|
919
|
+
if (selectorList.length) {
|
|
920
|
+
// 存在子元素选择器
|
|
921
|
+
// 这时候的this和target都是子元素选择器的元素
|
|
922
|
+
let $target;
|
|
923
|
+
if (listenerOption.isComposedPath) {
|
|
924
|
+
// 可能为空
|
|
925
|
+
const composedPath = event.composedPath();
|
|
926
|
+
if (!composedPath.length && event.target) {
|
|
927
|
+
composedPath.push(event.target);
|
|
928
|
+
}
|
|
929
|
+
$target = composedPath[0];
|
|
948
930
|
}
|
|
949
|
-
|
|
950
|
-
|
|
931
|
+
else {
|
|
932
|
+
$target = event.target;
|
|
933
|
+
}
|
|
934
|
+
let $parent = $elItem;
|
|
935
|
+
if (popsUtils.isWin($parent)) {
|
|
936
|
+
// window和document共用一个对象
|
|
937
|
+
// 这样就能处理子元素选择器无法匹配的问题
|
|
938
|
+
$parent = PopsCore.document.documentElement;
|
|
939
|
+
}
|
|
940
|
+
const findValue = selectorList.find((selectors) => {
|
|
941
|
+
// 判断目标元素是否匹配选择器
|
|
942
|
+
if (that.matches($target, selectors)) {
|
|
943
|
+
// 当前目标可以被selector所匹配到
|
|
944
|
+
return true;
|
|
945
|
+
}
|
|
946
|
+
// 在上层与主元素之间寻找可以被selector所匹配到的
|
|
947
|
+
const $closestMatches = that.closest($target, selectors);
|
|
948
|
+
if ($closestMatches && $parent?.contains?.($closestMatches)) {
|
|
949
|
+
$target = $closestMatches;
|
|
950
|
+
return true;
|
|
951
|
+
}
|
|
952
|
+
return false;
|
|
953
|
+
});
|
|
954
|
+
if (findValue) {
|
|
955
|
+
// 这里尝试使用defineProperty修改event的target值
|
|
956
|
+
try {
|
|
957
|
+
OriginPrototype.Object.defineProperty(event, "target", {
|
|
958
|
+
get() {
|
|
959
|
+
return $target;
|
|
960
|
+
},
|
|
961
|
+
});
|
|
962
|
+
// oxlint-disable-next-line no-empty
|
|
963
|
+
}
|
|
964
|
+
catch { }
|
|
965
|
+
execCallback = true;
|
|
966
|
+
call_this = $target;
|
|
967
|
+
call_event = event;
|
|
968
|
+
call_$selector = $target;
|
|
951
969
|
}
|
|
952
|
-
|
|
970
|
+
}
|
|
971
|
+
else {
|
|
972
|
+
execCallback = true;
|
|
973
|
+
call_this = $elItem;
|
|
974
|
+
call_event = event;
|
|
975
|
+
}
|
|
976
|
+
if (execCallback) {
|
|
977
|
+
const result = listenerCallBack.call(call_this, call_event, call_$selector);
|
|
953
978
|
checkOptionOnceToRemoveEventListener();
|
|
979
|
+
if (typeof result === "boolean" && !result) {
|
|
980
|
+
return false;
|
|
981
|
+
}
|
|
954
982
|
}
|
|
955
|
-
}
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
listenerCallBack.call(elementItem, event);
|
|
959
|
-
checkOptionOnceToRemoveEventListener();
|
|
960
|
-
}
|
|
961
|
-
}
|
|
962
|
-
// 遍历事件名设置元素事件
|
|
963
|
-
eventTypeList.forEach((eventName) => {
|
|
964
|
-
elementItem.addEventListener(eventName, domUtilsEventCallBack, listenerOption);
|
|
983
|
+
};
|
|
984
|
+
// add listener
|
|
985
|
+
$elItem.addEventListener(eventName, handlerCallBack, listenerOption);
|
|
965
986
|
// 获取对象上的事件
|
|
966
|
-
const elementEvents = Reflect.get(
|
|
987
|
+
const elementEvents = Reflect.get($elItem, SymbolEvents) || {};
|
|
967
988
|
// 初始化对象上的xx事件
|
|
968
989
|
elementEvents[eventName] = elementEvents[eventName] || [];
|
|
969
990
|
elementEvents[eventName].push({
|
|
970
991
|
selector: selectorList,
|
|
971
992
|
option: listenerOption,
|
|
972
|
-
|
|
973
|
-
|
|
993
|
+
handlerCallBack: handlerCallBack,
|
|
994
|
+
callback: listenerCallBack,
|
|
974
995
|
});
|
|
975
996
|
// 覆盖事件
|
|
976
|
-
Reflect.set(
|
|
997
|
+
Reflect.set($elItem, SymbolEvents, elementEvents);
|
|
977
998
|
});
|
|
978
999
|
});
|
|
979
1000
|
return {
|
|
@@ -986,11 +1007,11 @@ System.register('pops', [], (function (exports) {
|
|
|
986
1007
|
},
|
|
987
1008
|
/**
|
|
988
1009
|
* 主动触发事件
|
|
989
|
-
* @param
|
|
990
|
-
* @param
|
|
1010
|
+
* @param extraDetails 赋予触发的Event的额外属性,如果是Event类型,那么将自动代替默认new的Event对象
|
|
1011
|
+
* @param useDispatchToTriggerEvent 是否使用dispatchEvent来触发事件,默认true,如果为false,则直接调用callback,但是这种会让使用了`$selector`的没有值
|
|
991
1012
|
*/
|
|
992
|
-
emit: (
|
|
993
|
-
that.emit($elList, eventTypeList,
|
|
1013
|
+
emit: (extraDetails, useDispatchToTriggerEvent) => {
|
|
1014
|
+
that.emit($elList, eventTypeList, extraDetails, useDispatchToTriggerEvent);
|
|
994
1015
|
},
|
|
995
1016
|
};
|
|
996
1017
|
}
|
|
@@ -1001,7 +1022,7 @@ System.register('pops', [], (function (exports) {
|
|
|
1001
1022
|
* @param startIndex
|
|
1002
1023
|
* @param option
|
|
1003
1024
|
*/
|
|
1004
|
-
function
|
|
1025
|
+
const getOption = function (args1, startIndex, option) {
|
|
1005
1026
|
const currentParam = args1[startIndex];
|
|
1006
1027
|
if (typeof currentParam === "boolean") {
|
|
1007
1028
|
option.capture = currentParam;
|
|
@@ -1010,12 +1031,12 @@ System.register('pops', [], (function (exports) {
|
|
|
1010
1031
|
option.capture = currentParam.capture;
|
|
1011
1032
|
}
|
|
1012
1033
|
return option;
|
|
1013
|
-
}
|
|
1014
|
-
const
|
|
1034
|
+
};
|
|
1035
|
+
const that = this;
|
|
1015
1036
|
// eslint-disable-next-line prefer-rest-params
|
|
1016
1037
|
const args = arguments;
|
|
1017
1038
|
if (typeof element === "string") {
|
|
1018
|
-
element =
|
|
1039
|
+
element = that.selectorAll(element);
|
|
1019
1040
|
}
|
|
1020
1041
|
if (element == null) {
|
|
1021
1042
|
return;
|
|
@@ -1023,22 +1044,22 @@ System.register('pops', [], (function (exports) {
|
|
|
1023
1044
|
let $elList = [];
|
|
1024
1045
|
if (element instanceof NodeList || Array.isArray(element)) {
|
|
1025
1046
|
element = element;
|
|
1026
|
-
$elList = $elList.concat(element);
|
|
1047
|
+
$elList = $elList.concat(Array.from(element));
|
|
1027
1048
|
}
|
|
1028
1049
|
else {
|
|
1029
1050
|
$elList.push(element);
|
|
1030
1051
|
}
|
|
1031
1052
|
let eventTypeList = [];
|
|
1032
1053
|
if (Array.isArray(eventType)) {
|
|
1033
|
-
eventTypeList = eventTypeList.concat(eventType.filter((
|
|
1054
|
+
eventTypeList = eventTypeList.concat(eventType.filter((it) => typeof it === "string" && it.toString() !== ""));
|
|
1034
1055
|
}
|
|
1035
1056
|
else if (typeof eventType === "string") {
|
|
1036
|
-
eventTypeList = eventTypeList.concat(eventType.split(" ").filter((
|
|
1057
|
+
eventTypeList = eventTypeList.concat(eventType.split(" ").filter((it) => it !== ""));
|
|
1037
1058
|
}
|
|
1038
1059
|
// 子元素选择器
|
|
1039
1060
|
let selectorList = [];
|
|
1040
1061
|
if (Array.isArray(selector)) {
|
|
1041
|
-
selectorList = selectorList.concat(selector.filter((
|
|
1062
|
+
selectorList = selectorList.concat(selector.filter((it) => typeof it === "string" && it.toString() !== ""));
|
|
1042
1063
|
}
|
|
1043
1064
|
else if (typeof selector === "string") {
|
|
1044
1065
|
selectorList.push(selector);
|
|
@@ -1067,36 +1088,39 @@ System.register('pops', [], (function (exports) {
|
|
|
1067
1088
|
// 目标函数、事件名、回调函数、事件配置、过滤函数
|
|
1068
1089
|
filter = option;
|
|
1069
1090
|
}
|
|
1070
|
-
$elList.forEach((
|
|
1091
|
+
$elList.forEach(($elItem) => {
|
|
1071
1092
|
// 获取对象上的事件
|
|
1072
|
-
const elementEvents = Reflect.get(
|
|
1093
|
+
const elementEvents = Reflect.get($elItem, SymbolEvents) || {};
|
|
1073
1094
|
eventTypeList.forEach((eventName) => {
|
|
1074
1095
|
const handlers = elementEvents[eventName] || [];
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1096
|
+
// 过滤出需要删除的事件
|
|
1097
|
+
const handlersFiltered = typeof filter === "function" ? handlers.filter(filter) : handlers;
|
|
1098
|
+
for (let index = 0; index < handlersFiltered.length; index++) {
|
|
1099
|
+
const handler = handlersFiltered[index];
|
|
1100
|
+
// 过滤出的事件再根据下面的条件进行判断处理移除
|
|
1101
|
+
// 1. callback内存地址必须相同
|
|
1102
|
+
// 2. selector必须相同
|
|
1103
|
+
// 3. option.capture必须相同
|
|
1078
1104
|
let flag = true;
|
|
1079
|
-
if (flag && listenerCallBack && handler.
|
|
1080
|
-
// callback不同
|
|
1105
|
+
if (flag && listenerCallBack && handler.callback !== listenerCallBack) {
|
|
1081
1106
|
flag = false;
|
|
1082
1107
|
}
|
|
1083
1108
|
if (flag && selectorList.length && Array.isArray(handler.selector)) {
|
|
1084
1109
|
if (JSON.stringify(handler.selector) !== JSON.stringify(selectorList)) {
|
|
1085
|
-
// 子元素选择器不同
|
|
1086
1110
|
flag = false;
|
|
1087
1111
|
}
|
|
1088
1112
|
}
|
|
1089
1113
|
if (flag &&
|
|
1090
1114
|
typeof handler.option.capture === "boolean" &&
|
|
1091
1115
|
listenerOption.capture !== handler.option.capture) {
|
|
1092
|
-
// 事件的配置项不同
|
|
1093
1116
|
flag = false;
|
|
1094
1117
|
}
|
|
1095
1118
|
if (flag) {
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1119
|
+
$elItem.removeEventListener(eventName, handler.handlerCallBack, handler.option);
|
|
1120
|
+
for (let i = handlers.length - 1; i >= 0; i--) {
|
|
1121
|
+
if (handlers[i] === handler) {
|
|
1122
|
+
handlers.splice(i, 1);
|
|
1123
|
+
}
|
|
1100
1124
|
}
|
|
1101
1125
|
}
|
|
1102
1126
|
}
|
|
@@ -1105,7 +1129,7 @@ System.register('pops', [], (function (exports) {
|
|
|
1105
1129
|
popsUtils.delete(elementEvents, eventType);
|
|
1106
1130
|
}
|
|
1107
1131
|
});
|
|
1108
|
-
Reflect.set(
|
|
1132
|
+
Reflect.set($elItem, SymbolEvents, elementEvents);
|
|
1109
1133
|
});
|
|
1110
1134
|
}
|
|
1111
1135
|
/**
|
|
@@ -1489,11 +1513,11 @@ System.register('pops', [], (function (exports) {
|
|
|
1489
1513
|
* 阻止事件的默认行为发生,并阻止事件传播
|
|
1490
1514
|
*/
|
|
1491
1515
|
const stopEvent = (event, onlyStopPropagation) => {
|
|
1516
|
+
// 停止事件的传播,阻止它继续向更上层的元素冒泡,事件将不会再传播给其他的元素
|
|
1517
|
+
event?.stopPropagation();
|
|
1518
|
+
// 阻止事件传播,并且还能阻止元素上的其他事件处理程序被触发
|
|
1519
|
+
event?.stopImmediatePropagation();
|
|
1492
1520
|
if (typeof onlyStopPropagation === "boolean" && onlyStopPropagation) {
|
|
1493
|
-
// 停止事件的传播,阻止它继续向更上层的元素冒泡,事件将不会再传播给其他的元素
|
|
1494
|
-
event?.stopPropagation();
|
|
1495
|
-
// 阻止事件传播,并且还能阻止元素上的其他事件处理程序被触发
|
|
1496
|
-
event?.stopImmediatePropagation();
|
|
1497
1521
|
return;
|
|
1498
1522
|
}
|
|
1499
1523
|
// 阻止事件的默认行为发生。例如,当点击一个链接时,浏览器会默认打开链接的URL,或者在输入框内输入文字
|