/
H.browser.js
814 lines (803 loc) · 22.1 KB
/
H.browser.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
'use strict';
/**
* H helper functions available only for Browsers. Chainable and is similar to jQuery's $ constructor.
* @typicalname H()
* @name HBrowser
* @param {String|Function} parameter DOM selector, HTML code that will be used to create new elements, Function to run when document is ready. Similar to $(function(){ }) or $(document).ready(function(){ })
* @returns {HObject}
*/
const H = (s) => {
if(!s)
s = [];
if(typeof s == 'string') {
s = s.trim();
if(s[0]=='<') {
if (/^<(\w+)\s*\/?>(?:<\/\1>|)$/.test(s))
s = [document.createElement(RegExp.$1)];
else {
var container = document.createElement('div');
container.innerHTML = s;
s = HObject.from(container.children);
}
} else
s = document.querySelectorAll(s);
} else if(typeof s == 'function') {
if (document.readyState === 'loading')
document.addEventListener('DOMContentLoaded', s);
else
s();
return;
}
if(s instanceof NodeList)
s = HObject.from(s);
if(!H.isArray(s))
s = new HObject(s);
if(!(s instanceof HObject)) // In case it is just a regular array
s = HObject.from(s);
return s.filter(e=>e instanceof Node);
};
require('./H.common.js')(H);
/**
* Collection of DOM Nodes, extends Array
* @typicalname H()
*/
class HObject extends Array {
/**
* Get the descendants of each element in the current set of matched elements, filtered by a selector.
* @param {String} selector DOM selector
* @returns {HObject}
*/
find(sel) {
return this.map(e=>HObject.from(e.querySelectorAll(sel))).flat();
}
/**
* For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.
* @param {String|Element} selector DOM selector or DOM element
* @returns {HObject}
*/
closest(sel) {
return this.map(e=>e.closest(sel)).filter(e=>e);
}
/**
* Checks if any of the elements in the set contains the selected element.
* @param {String|Element} selector DOM selector or DOM element
* @returns {HObject}
*/
contains(sel) {
if(typeof sel=='string') {
return this.find(sel).length>0;
} else
return this.findIndex(e=>e.contains(sel))!==-1;
}
/**
* Get the ancestors of each element in the current set of matched elements, optionally filtered by a selector.
* @param {String} selector DOM selector
* @returns {HObject}
*/
parents(sel) {
var parents = new HObject();
for(let el of this) {
while(el) {
el = el.parentElement;
if(el && (!sel || el.matches(sel)))
parents.push(el);
}
}
return parents;
}
/**
* Get the parent of each element in the current set of matched elements, optionally filtered by a selector.
* @param {String} selector DOM selector
* @returns {HObject}
*/
parent(sel) {
return this.map(ele=>ele.parentElement).filter(e=>!sel || e.is(sel));
}
/**
* Get the children of each element in the set of matched elements, optionally filtered by a selector.
* @param {String} selector DOM selector
* @returns {HObject}
*/
children(sel) {
return this.map(e=>Array.from(e.children).filter(e=>!sel || e.matches(sel))).flat();
}
/**
* Get the siblings of each element in the set of matched elements, optionally filtered by a selector.
* @param {String} selector DOM selector
* @returns {HObject}
*/
siblings(sel) {
return this.map(e=>{
return Array.from(e.parentNode.children).filter(ele=>ele!=e && (!sel || ele.matches(sel)));
}).flat();
}
/**
* Reduce the set of matched elements to the first in the set.
* @returns {HObject}
*/
first() {
return H(this[0]);
}
/**
* Reduce the set of matched elements to the last in the set.
* @returns {HObject}
*/
last() {
return H(this[this.length-1]);
}
/**
* Get the immediately preceding sibling of each element in the set of matched elements. If a selector is provided, it retrieves the previous sibling only if it matches that selector.
* @param {String} selector DOM selector
* @returns {HObject}
*/
prev(sel) {
return this.map(e=>e.previousElementSibling).filter(e=>e && (!sel || e.matches(sel)));
}
/**
* Get the immediately following sibling of each element in the set of matched elements. If a selector is provided, it retrieves the next sibling only if it matches that selector.
* @param {String} selector DOM selector
* @returns {HObject}
*/
next(sel) {
return this.map(e=>e.nextElementSibling).filter(e=>e && (!sel || e.matches(sel)));
}
/**
* Get all preceding siblings of each element in the set of matched elements, optionally filtered by a selector.
* @param {String} selector DOM selector
* @returns {HObject}
*/
prevAll(sel) {
var elements = new HObject();
for(let el of this) {
while(el) {
el = el.previousElementSibling;
if(el && (!sel || el.matches(sel)))
elements.push(el);
}
}
return elements;
}
/**
* Get all following siblings of each element in the set of matched elements, optionally filtered by a selector.
* @param {String} selector DOM selector
* @returns {HObject}
*/
nextAll(sel) {
var elements = new HObject();
for(let el of this) {
while(el) {
el = el.nextElementSibling;
if(el && (!sel || el.matches(sel)))
elements.push(el);
}
}
return elements;
}
/**
* Get the value of an attribute for the first element in the set of matched elements.
* @param {String} name Attribute name
* @returns {String}
*//**
* Set an attribute for the set of matched elements.
* @param {String} name Attribute name
* @param {String} value Attribute value
* @returns {HObject}
*/
attr(attr, val) {
if(typeof val!='undefined') {
this.forEach(e=>e.setAttribute(attr, val));
return this;
} else
return this[0] && this[0].getAttribute(attr);
}
/**
* Remove an attribute from each element in the set of matched elements.
* @param {String} name Attribute name
* @returns {HObject}
*/
removeAttr(attr) {
this.forEach(e=>e.removeAttribute(attr));
return this;
}
/**
* Display the matched elements.
* @returns {HObject}
*/
show() {
this.css('display', '');
if(this.css('display')=='none')
return this.css('display', 'block');
return this;
}
/**
* Hide the matched elements.
* @returns {HObject}
*/
hide() {
return this.css('display', 'none');
}
/**
* Get the value of a property for the first element in the set of matched elements.
* @param {String} key Property name
* @returns {String}
*//**
* Set a property for the set of matched elements.
* @param {String} key Property name
* @param {String} value Property value
* @returns {HObject}
*/
prop(key, val) {
if(typeof val!='undefined') {
this.forEach(e=>e[key]=val);
return this;
} else
return this[0] && this[0][key];
}
/**
* Get the computed style properties for the first element in the set of matched elements.
* @param {String} name Property name
* @returns {String}
*//**
* Set a CSS property for the set of matched elements.
* @param {String} name Property name
* @param {String} value Property value
* @returns {HObject}
*//**
* Set one or more CSS properties for the set of matched elements.
* @param {Object} properties Key-value pair of properties to set.
* @returns {HObject}
*/
css(key, value, important) {
var props = {};
if (typeof key == 'string') {
if (typeof value === 'undefined') {
let kHyphen = key.indexOf('--')==0?key:(key.replace(/([a-z])([A-Z])/g, function(matches, l1, l2) {// To hyphen-case
return l1+'-'+l2;
}).toLowerCase());
if(this.length==0)
return undefined;
return window.getComputedStyle(this[0]).getPropertyValue(kHyphen);
}
props = {
[key] : value
};
} else if (H.isObject(key))
props = key;
for(let k in props) {
let kHyphen = k.indexOf('--')==0?k:(k.replace(/([a-z])([A-Z])/g, function(matches, l1, l2) {// To hyphen-case
return l1+'-'+l2;
}).toLowerCase());
for(let ele of this) {
ele.style.setProperty(kHyphen, props[k], important?'important':undefined);
}
}
return this;
}
/**
* Insert content, specified by the parameter, to the end of each element in the set of matched elements.
* @param {Mixed} content Content to insert. (either a selector, HTML content or a DOM Node)
* @returns {HObject}
*/
append(sel) {
this.forEach(el=>{
var ch = H(sel);
for(let child of ch)
el.appendChild(child);
});
return this;
}
/**
* Insert every element in the set of matched elements to the end of the target(s).
* @param {Mixed} target Target of the content. (either a selector, HTML content or a DOM Node)
* @returns {HObject}
*/
appendTo(sel) {
H(sel).append(this);
return this;
}
/**
* Insert content, specified by the parameter, to the beginning of each element in the set of matched elements.
* @param {Mixed} content Content to insert. (either a selector, HTML content or a DOM Node)
* @returns {HObject}
*/
prepend(sel) {
this.forEach(el=>{
var ch = H(sel).reverse();
for(let child of ch)
el.insertBefore(child, el.firstChild);
});
return this;
}
/**
* Insert every element in the set of matched elements to the beginning of the target(s).
* @param {Mixed} target Target of the content. (either a selector, HTML content or a DOM Node)
* @returns {HObject}
*/
prependTo(sel) {
H(sel).prepend(this);
return this;
}
/**
* Insert every element in the set of matched elements before the target.
* @param {String} target DOM selector
* @returns {HObject}
*/
insertBefore(sel) {
H(sel).before(this);
return this;
}
/**
* Insert content, specified by the parameter, before each element in the set of matched elements
* @param {String} content HTML code or DOM selector
* @returns {HObject}
*/
before(content) {
this.forEach(e=>{
var $content = H(content);
$content.forEach(c=>{
e.parentNode.insertBefore(c, e);
});
});
return this;
}
/**
* Insert every element in the set of matched elements after the target.
* @param {String} target DOM selector
* @returns {HObject}
*/
insertAfter(sel) {
H(sel).after(this);
return this;
}
/**
* Insert content, specified by the parameter, after each element in the set of matched elements
* @param {String} content HTML code or DOM selector
* @returns {HObject}
*/
after(content) {
this.forEach(e=>{
var $content = H(content).reverse();
$content.forEach(c=>{
var bef = e.nextSibling;
if(bef)
bef.parentNode.insertBefore(c, bef);
else
e.parentNode.appendChild(c);
});
});
return this;
}
/**
* Wrap an HTML structure around each element in the set of matched elements.
* @param {String} element Wrapping element.
* @returns {HObject}
*/
wrap(element) {
this.each(function(){
H(element).eq(0).insertBefore(this).append(this);
});
return this;
}
/**
* Wrap an HTML structure around the content of each element in the set of matched elements.
* @param {String} element Wrapping element.
* @returns {HObject}
*/
wrapInner(element) {
this.forEach((t)=>{
var w = H(element).get(0);
Array.from(t.childNodes).forEach(e=>w.appendChild(e));
t.appendChild(w);
});
return this;
}
/**
* Remove all child nodes of the set of matched elements from the DOM.
* @returns {HObject}
*/
empty() {
this.forEach(el=>{
while(el.firstChild)
el.removeChild(el.firstChild);
});
return this;
}
/**
* Remove the set of matched elements from the DOM.
* @returns {void}
*/
remove(sel) {
this.forEach(el=>{
el.parentNode.removeChild(el);
});
return;
}
/**
* Reduce the set of matched elements to the one at the specified index.
* @param {Number} index Index of the element
* @returns {HObject}
*/
eq(index) {
return H(this[index]);
}
/**
* Search for a given element from among the matched elements.
* @returns {Number}
*/
index() {
if (!this[0])
return -1;
var cEle = this[0];
let index = 0;
while(cEle.previousElementSibling) {
index++;
cEle = cEle.previousElementSibling;
}
return index;
}
/**
* Get the HTML contents of the first element in the set of matched elements.
* @returns {String}
*//**
* Set the HTML contents of each element in the set of matched elements.
* @param {String} content HTML content
* @returns {HObject}
*/
html(val) {
if(typeof val!='undefined') {
this.forEach(e=>e.innerHTML=val);
return this;
} else
return this[0] && this[0].innerHTML;
}
/**
* Get the combined text contents of each element in the set of matched elements, including their descendants.
* @returns {String}
*//**
* Set the content of each element in the set of matched elements to the specified text.
* @param {String} content Text content
* @returns {HObject}
*/
text(val) {
if(typeof val!='undefined') {
this.forEach(e=>e.textContent=val);
return this;
} else
return this[0] && this[0].textContent;
}
/**
* Get the current value of the first element in the set of matched elements.
* @returns {String}
*//**
* Set the value of each element in the set of matched elements.
* @param {String} value Value
* @returns {HObject}
*/
val(val) {
if(typeof val!='undefined') {
this.forEach(e=>e.value=val);
return this;
} else
return this[0] && this[0].value;
}
/**
* Iterate over a jQuery object, executing a function for each matched element.
* @param {Function} function Function to execute
* @returns {HObject}
*/
each(cb) {
for(let i in this) {
if(cb.call(H(this[i]), this[i], i)===false)
break;
}
return this;
}
/**
* Retrieve the elements matched as a vanilla Array.
* @returns {Node}
*//**
* Retrieve one of the elements matched.
* @param {Number} index Index of the element to return
* @returns {Node}
*/
get(index) {
if(index!=undefined)
return this[index];
else
return Array.from(this);
}
/**
* Adds the specified class(es) to each element in the set of matched elements
* @param {String} className Class name
* @returns {HObject}
*/
addClass(c) {
c.trim().split(' ').forEach(c=>{
this.forEach(e=>e.classList.add(c));
});
return this;
}
/**
* Remove a single class, multiple classes, or all classes from each element in the set of matched elements.
* @param {String} className Class name
* @returns {HObject}
*/
removeClass(c) {
c.trim().split(' ').forEach(c=>{
this.forEach(e=>e.classList.remove(c));
});
return this;
}
/**
* Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the state argument.
* @param {String} className Class name
* @returns {HObject}
*/
toggleClass(c) {
c.trim().split(' ').forEach(c=>{
this.forEach(e=>e.classList.toggle(c));
});
return this;
}
/**
* Determine whether any of the matched elements are assigned the given class.
* @param {String} className Class name
* @returns {Boolean}
*/
hasClass(c) {
return this.some(e=>e.classList.contains(c));
}
/**
* Reduce the set of matched elements to those that match the selector.
* @param {String} selector DOM Selector
* @returns {HObject}
*//**
* Reduce the set of matched elements to those that match the function's test.
* @param {Function} fn Function used as a test for each elkement in the set.
* @returns {HObject}
*/
filter(cb) {
if(typeof cb == 'string')
return HObject.from(this.get().filter(e=>e.matches(cb)));
else
return HObject.from(this.get().filter((e, i)=>cb.call(new HObject(e), e, i)));
}
/**
* Check the current matched set of elements against a selector and return true if at least one of these elements matches the given arguments.
* @param {String} selector DOM Selector
* @returns {Boolean}
*/
is(sel) {
return this.some(e=>e.matches(sel));
}
/**
* Get the current coordinates of the first element in the set of matched elements, relative to the document.
* @returns {Object} \{top, left\}
*/
offset() {
if(!this[0])
return undefined;
var rect = this[0].getBoundingClientRect();
return {
top: rect.top + window.scrollY,
left: rect.left + window.scrollX
};
}
/**
* Attach an event handler function for one or more events to the selected elements.
* @param {String} events One or more space-separated event types and optional namespaces.
* @param {String} selector A selector string to filter the descendants of the selected elements that trigger the event.
* @param {Function} callback Event Handler
* @param {Object} options Additional options for .addEventListener
* @returns {HObject}
*/
on(events, sel, cb, opts) {
if(typeof sel!='string') {
opts = cb;
cb = sel;
sel = undefined;
}
if(typeof opts=='boolean') {
opts = {
once : opts,
};
}
opts = opts || {};
var this_ = this;
var handler = function(e) {
var $target = this;
if(sel) {
if(e.target.matches(sel)) {
$target = e.target;
} else {
$target = H(e.target).closest(sel);
if($target.length==0) // Skip if it doesn't have a parent matching sel
return;
}
}
return cb.call(H($target), e, ...(H.isArray(e.detail)?e.detail:[]));
};
events.trim().split(' ').forEach((event) => {
let parts = event.split('.');
let eventName = parts.shift() || null;
let namespace = parts.join('.') || null;
if(!eventName)
return;
this.forEach((ele) => {
ele.attachedEvents = ele.attachedEvents || [];
ele.attachedEvents.push({
eventName,
namespace,
handler,
capture : opts.capture || false
});
ele.addEventListener(eventName, handler, opts);
});
});
return this;
}
/**
* Attach a handler to an event for the elements. The handler is executed at most once per element per event type.
* @param {String} events One or more space-separated event types and optional namespaces.
* @param {String} selector A selector string to filter the descendants of the selected elements that trigger the event.
* @param {Function} callback Event Handler
* @param {Object} options Additional options for .addEventListener
* @returns {HObject}
*/
one(events, sel, cb, opts) {
if(typeof sel!='string') {
cb = cb || {};
cb.once = true;
} else {
opts = opts || {};
opts.once = true;
}
return this.on(events, sel, cb, opts);
}
/**
* Remove an event handler.
* @param {String} events One or more space-separated event types and optional namespaces.
* @param {Function} callback Event Handler
* @returns {HObject}
*/
off(events, cb) {
events.trim().split(' ').forEach((event) => {
let parts = event.split('.');
let eventName = parts.shift() || null;
let namespace = parts.join('.') || null;
if(!eventName && !namespace)
return;
this.forEach((ele) => {
let toRemove = [];
ele.attachedEvents = ele.attachedEvents || [];
ele.attachedEvents.forEach((ev, i) => {
if(
(!eventName || eventName==ev.eventName) &&
(!namespace || namespace==ev.namespace) &&
(!cb && cb==ev.cb)
) {
ele.removeEventListener(ev.eventName, ev.handler, ev.capture);
toRemove.push(i);
}
});
ele.attachedEvents = ele.attachedEvents.filter((e,i)=>!toRemove.includes(i))
});
});
return this;
}
/**
* Execute all handlers and behaviors attached to the matched elements for the given event type.
* @param {String} event Event types and optional namespaces.
* @param {Array<Mixed>} extraParams Additional parameters to pass along to the event handler.
* @param {Object} eventOptions Additional event options for CustomEvent (e.g. for controlling if event bubbles...)
* @returns {HObject}
*/
trigger(event, params, evtOpts={}) {
let parts = event.split('.');
let eventName = parts.shift() || null;
let namespace = parts.join('.') || null;
if(!eventName)
return this;
var event = new CustomEvent(eventName, {
detail : params,
bubbles: true,
cancelable: true,
...evtOpts,
});
for(let ele of this) {
if(namespace) {
ele.attachedEvents = ele.attachedEvents || [];
ele.attachedEvents.forEach(ev => {
if(eventName==ev.eventName && namespace==ev.namespace)
ev.handler.call(ele, event);
});
} else
ele.dispatchEvent(event);
}
return this;
}
/**
* Execute all handlers attached to an element for an event.
* @param {String} event Event types and optional namespaces.
* @param {Array<Mixed>} extraParams Additional parameters to pass along to the event handler.
* @param {Object} eventOptions Additional event options for CustomEvent (e.g. for controlling if event bubbles...)
* @returns {Mixed}
*/
triggerHandler(event, params, evtOpts={}) {
let parts = event.split('.');
let eventName = parts.shift() || null;
let namespace = parts.join('.') || null;
if(!eventName)
return undefined;
var event = new CustomEvent(eventName, {
detail : params,
...evtOpts,
});
var out;
this.forEach(ele => {
ele.attachedEvents = ele.attachedEvents || [];
ele.attachedEvents.forEach(ev => {
if(eventName==ev.eventName && (!namespace || namespace==ev.namespace))
out = ev.handler.call(ele, event);
});
});
return out;
}
};
H.HObject = HObject;
var loadedScripts = [];
/**
* Loads a JS script
* @async
* @param {String} url JS script url
* @param {Boolean} [reload=false] If set to true, the scrippt will be appended regardless if it was previously loaded or not
* @returns {Promise} Resolves when script is loaded
*/
H.loadScript = (url, forceReload=false) => {
return new Promise(function(resolve, reject) {
if(forceReload || !loadedScripts.includes(url)) {
var script= document.createElement('script');
script.type= 'text/javascript';
script.onerror = (e) => {
reject(e);
};
script.onload = () => {
resolve();
};
script.async = true;
script.src = url;
document.body.appendChild(script);
loadedScripts.push(url);
} else
resolve();
});
};
var loadedStylesheets = [];
/**
* Loads a CSS stylesheet
* @async
* @param {String} url CSS stylesheet url
* @param {Boolean} [reload=false] If set to true, the stylesheet will be reloaded regardless if it was previously loaded or not
* @returns {Promise} Resolves when stylesheet is loaded
*/
H.loadStylesheet = (url, forceReload=false) => {
return new Promise(function(resolve, reject) {
if(forceReload || !loadedStylesheets.includes(url)) {
var link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.onerror = (e) => {
reject(e);
};
link.onload = () => {
resolve();
};
link.href = url;
document.head.appendChild(link);
loadedStylesheets.push(url);
} else
resolve();
});
};
H._fetch = window.fetch.bind(window);
module.exports = H;