@webalternatif/js-core 1.5.1 → 1.5.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/cjs/dom.js +43 -27
- package/dist/esm/dom.js +43 -27
- package/package.json +1 -1
- package/types/dom.d.ts +6 -6
- package/types/index.d.ts +3 -3
package/dist/cjs/dom.js
CHANGED
|
@@ -190,7 +190,7 @@ var dom = {
|
|
|
190
190
|
},
|
|
191
191
|
/**
|
|
192
192
|
* @param {Element|Document|string} refEl
|
|
193
|
-
* @param {string|Element|NodeList|Array<Element>} selector
|
|
193
|
+
* @param {string|Element|NodeList|Array<Element>} [selector]
|
|
194
194
|
* @returns {Element}
|
|
195
195
|
*/
|
|
196
196
|
findOne: function findOne(refEl, selector) {
|
|
@@ -199,7 +199,7 @@ var dom = {
|
|
|
199
199
|
},
|
|
200
200
|
/**
|
|
201
201
|
* @param {Element|Document|string} refEl
|
|
202
|
-
* @param {string|Element|NodeList|Array<Element>} selector
|
|
202
|
+
* @param {string|Element|NodeList|Array<Element>} [selector]
|
|
203
203
|
* @returns {Array<Element>}
|
|
204
204
|
*/
|
|
205
205
|
find: function find(refEl, selector) {
|
|
@@ -652,31 +652,44 @@ var dom = {
|
|
|
652
652
|
return;
|
|
653
653
|
}
|
|
654
654
|
var currentTarget = ev.target;
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
655
|
+
var _loop = function _loop() {
|
|
656
|
+
if (_this5.matches(currentTarget, selector)) {
|
|
657
|
+
var wrappedEv = {
|
|
658
|
+
_immediateStopped: false,
|
|
659
|
+
originalEvent: ev,
|
|
660
|
+
type: ev.type,
|
|
661
|
+
target: ev.target,
|
|
662
|
+
currentTarget: currentTarget,
|
|
663
|
+
relatedTarget: ev.relatedTarget,
|
|
664
|
+
button: ev.button,
|
|
665
|
+
pageX: ev.pageX,
|
|
666
|
+
pageY: ev.pageY,
|
|
667
|
+
preventDefault: function preventDefault() {
|
|
668
|
+
return ev.preventDefault.apply(ev, arguments);
|
|
669
|
+
},
|
|
670
|
+
stopPropagation: function stopPropagation() {
|
|
671
|
+
return ev.stopPropagation.apply(ev, arguments);
|
|
672
|
+
},
|
|
673
|
+
stopImmediatePropagation: function stopImmediatePropagation() {
|
|
674
|
+
wrappedEv._immediateStopped = true;
|
|
675
|
+
ev.stopImmediatePropagation.apply(ev, arguments);
|
|
676
|
+
}
|
|
677
|
+
};
|
|
678
|
+
handler.call(currentTarget, wrappedEv);
|
|
679
|
+
if (wrappedEv._immediateStopped) {
|
|
680
|
+
return {
|
|
681
|
+
v: void 0
|
|
682
|
+
};
|
|
674
683
|
}
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
}
|
|
679
|
-
|
|
684
|
+
return 0; // break
|
|
685
|
+
}
|
|
686
|
+
currentTarget = currentTarget.parentElement;
|
|
687
|
+
},
|
|
688
|
+
_ret;
|
|
689
|
+
while (currentTarget && currentTarget !== el) {
|
|
690
|
+
_ret = _loop();
|
|
691
|
+
if (_ret === 0) break;
|
|
692
|
+
if (_ret) return _ret.v;
|
|
680
693
|
}
|
|
681
694
|
};
|
|
682
695
|
var store = LISTENERS.get(el);
|
|
@@ -867,10 +880,13 @@ var dom = {
|
|
|
867
880
|
return el.parentElement.insertBefore(newEl, el);
|
|
868
881
|
},
|
|
869
882
|
/**
|
|
870
|
-
* @param {Element} el
|
|
883
|
+
* @param {Element|string} el
|
|
871
884
|
* @returns {Element}
|
|
872
885
|
*/
|
|
873
886
|
empty: function empty(el) {
|
|
887
|
+
if ((0, _is.isString)(el)) {
|
|
888
|
+
el = this.findOne(el);
|
|
889
|
+
}
|
|
874
890
|
while (el.firstChild) {
|
|
875
891
|
el.removeChild(el.firstChild);
|
|
876
892
|
}
|
package/dist/esm/dom.js
CHANGED
|
@@ -183,7 +183,7 @@ var dom = {
|
|
|
183
183
|
},
|
|
184
184
|
/**
|
|
185
185
|
* @param {Element|Document|string} refEl
|
|
186
|
-
* @param {string|Element|NodeList|Array<Element>} selector
|
|
186
|
+
* @param {string|Element|NodeList|Array<Element>} [selector]
|
|
187
187
|
* @returns {Element}
|
|
188
188
|
*/
|
|
189
189
|
findOne: function findOne(refEl, selector) {
|
|
@@ -192,7 +192,7 @@ var dom = {
|
|
|
192
192
|
},
|
|
193
193
|
/**
|
|
194
194
|
* @param {Element|Document|string} refEl
|
|
195
|
-
* @param {string|Element|NodeList|Array<Element>} selector
|
|
195
|
+
* @param {string|Element|NodeList|Array<Element>} [selector]
|
|
196
196
|
* @returns {Array<Element>}
|
|
197
197
|
*/
|
|
198
198
|
find: function find(refEl, selector) {
|
|
@@ -645,31 +645,44 @@ var dom = {
|
|
|
645
645
|
return;
|
|
646
646
|
}
|
|
647
647
|
var currentTarget = ev.target;
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
648
|
+
var _loop = function _loop() {
|
|
649
|
+
if (_this5.matches(currentTarget, selector)) {
|
|
650
|
+
var wrappedEv = {
|
|
651
|
+
_immediateStopped: false,
|
|
652
|
+
originalEvent: ev,
|
|
653
|
+
type: ev.type,
|
|
654
|
+
target: ev.target,
|
|
655
|
+
currentTarget: currentTarget,
|
|
656
|
+
relatedTarget: ev.relatedTarget,
|
|
657
|
+
button: ev.button,
|
|
658
|
+
pageX: ev.pageX,
|
|
659
|
+
pageY: ev.pageY,
|
|
660
|
+
preventDefault: function preventDefault() {
|
|
661
|
+
return ev.preventDefault.apply(ev, arguments);
|
|
662
|
+
},
|
|
663
|
+
stopPropagation: function stopPropagation() {
|
|
664
|
+
return ev.stopPropagation.apply(ev, arguments);
|
|
665
|
+
},
|
|
666
|
+
stopImmediatePropagation: function stopImmediatePropagation() {
|
|
667
|
+
wrappedEv._immediateStopped = true;
|
|
668
|
+
ev.stopImmediatePropagation.apply(ev, arguments);
|
|
669
|
+
}
|
|
670
|
+
};
|
|
671
|
+
handler.call(currentTarget, wrappedEv);
|
|
672
|
+
if (wrappedEv._immediateStopped) {
|
|
673
|
+
return {
|
|
674
|
+
v: void 0
|
|
675
|
+
};
|
|
667
676
|
}
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
}
|
|
672
|
-
|
|
677
|
+
return 0; // break
|
|
678
|
+
}
|
|
679
|
+
currentTarget = currentTarget.parentElement;
|
|
680
|
+
},
|
|
681
|
+
_ret;
|
|
682
|
+
while (currentTarget && currentTarget !== el) {
|
|
683
|
+
_ret = _loop();
|
|
684
|
+
if (_ret === 0) break;
|
|
685
|
+
if (_ret) return _ret.v;
|
|
673
686
|
}
|
|
674
687
|
};
|
|
675
688
|
var store = LISTENERS.get(el);
|
|
@@ -860,10 +873,13 @@ var dom = {
|
|
|
860
873
|
return el.parentElement.insertBefore(newEl, el);
|
|
861
874
|
},
|
|
862
875
|
/**
|
|
863
|
-
* @param {Element} el
|
|
876
|
+
* @param {Element|string} el
|
|
864
877
|
* @returns {Element}
|
|
865
878
|
*/
|
|
866
879
|
empty: function empty(el) {
|
|
880
|
+
if (isString(el)) {
|
|
881
|
+
el = this.findOne(el);
|
|
882
|
+
}
|
|
867
883
|
while (el.firstChild) {
|
|
868
884
|
el.removeChild(el.firstChild);
|
|
869
885
|
}
|
package/package.json
CHANGED
package/types/dom.d.ts
CHANGED
|
@@ -18,16 +18,16 @@ declare namespace dom {
|
|
|
18
18
|
function child(el: Element, selector?: string): Element | null;
|
|
19
19
|
/**
|
|
20
20
|
* @param {Element|Document|string} refEl
|
|
21
|
-
* @param {string|Element|NodeList|Array<Element>} selector
|
|
21
|
+
* @param {string|Element|NodeList|Array<Element>} [selector]
|
|
22
22
|
* @returns {Element}
|
|
23
23
|
*/
|
|
24
|
-
function findOne(refEl: Element | Document | string, selector
|
|
24
|
+
function findOne(refEl: Element | Document | string, selector?: string | Element | NodeList | Array<Element>): Element;
|
|
25
25
|
/**
|
|
26
26
|
* @param {Element|Document|string} refEl
|
|
27
|
-
* @param {string|Element|NodeList|Array<Element>} selector
|
|
27
|
+
* @param {string|Element|NodeList|Array<Element>} [selector]
|
|
28
28
|
* @returns {Array<Element>}
|
|
29
29
|
*/
|
|
30
|
-
function find(refEl: Element | Document | string, selector
|
|
30
|
+
function find(refEl: Element | Document | string, selector?: string | Element | NodeList | Array<Element>): Array<Element>;
|
|
31
31
|
/**
|
|
32
32
|
* @param {Element|string} el
|
|
33
33
|
* @param {string} data
|
|
@@ -263,10 +263,10 @@ declare namespace dom {
|
|
|
263
263
|
*/
|
|
264
264
|
function before(el: Element, newEl: Element | string): Element | null;
|
|
265
265
|
/**
|
|
266
|
-
* @param {Element} el
|
|
266
|
+
* @param {Element|string} el
|
|
267
267
|
* @returns {Element}
|
|
268
268
|
*/
|
|
269
|
-
function empty(el: Element): Element;
|
|
269
|
+
function empty(el: Element | string): Element;
|
|
270
270
|
/**
|
|
271
271
|
* @param {Element|NodeList|Array<Element>} el
|
|
272
272
|
* @param {string|Element} selector
|
package/types/index.d.ts
CHANGED
|
@@ -18,8 +18,8 @@ declare const webf: {
|
|
|
18
18
|
dom: {
|
|
19
19
|
children(el: Element, selector?: string): NodeList;
|
|
20
20
|
child(el: Element, selector?: string): Element | null;
|
|
21
|
-
findOne(refEl: Element | Document | string, selector
|
|
22
|
-
find(refEl: Element | Document | string, selector
|
|
21
|
+
findOne(refEl: Element | Document | string, selector?: string | Element | NodeList | Array<Element>): Element;
|
|
22
|
+
find(refEl: Element | Document | string, selector?: string | Element | NodeList | Array<Element>): Array<Element>;
|
|
23
23
|
findOneByData(el: Element | string, data: string, value?: string): Element | null;
|
|
24
24
|
findByData(el: Element | string, data: string, value?: string): Element[];
|
|
25
25
|
addClass(el: Element | NodeList | Array<Element>, className: string): Element | NodeList | Array<Element>;
|
|
@@ -61,7 +61,7 @@ declare const webf: {
|
|
|
61
61
|
eq(nodeList: NodeList | Array<Element>, index?: number): Element | null;
|
|
62
62
|
after(el: Element, newEl: Element | string): Element | null;
|
|
63
63
|
before(el: Element, newEl: Element | string): Element | null;
|
|
64
|
-
empty(el: Element): Element;
|
|
64
|
+
empty(el: Element | string): Element;
|
|
65
65
|
not(el: Element | NodeList | Array<Element>, selector: string | Element): Array<Element>;
|
|
66
66
|
collide(elem1: Element, elem2: Element): boolean;
|
|
67
67
|
matches(el: Element, selector: string | Element): boolean;
|