@litejs/ui 25.5.0 → 26.2.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/shim.js CHANGED
@@ -14,7 +14,6 @@
14
14
 
15
15
 
16
16
  /* global El, xhr, escape */
17
- /* c8 ignore start */
18
17
  !function(window, Date, Function, Infinity, P) {
19
18
 
20
19
  // Array#flat() - Chrome69, Firefox62, Safari12
@@ -24,8 +23,9 @@
24
23
  // queueMicrotask - Chrome71, Firefox69, Safari12.1
25
24
  // "".at(), [].at() - Chrome92, Firefox90, Safari15.4
26
25
 
27
- var UNDEF, isArray, oKeys
26
+ var UNDEF, canCapture, isArray, oKeys
28
27
  , O = window
28
+ , NULL = null
29
29
  , patched = (window.xhr || window)._p = []
30
30
  , jsonRe = /[\x00-\x1f\x22\x5c]/g
31
31
  , JSONmap = {"\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\"":"\\\"","\\":"\\\\"}
@@ -49,6 +49,7 @@
49
49
  , b = "setInterval"
50
50
  , setInterval = (window[b] = window[b])
51
51
  , c
52
+ /* node:coverage ignore next 19 */
52
53
  , ie678 = !+"\v1" && a < 9 // jshint ignore:line
53
54
  , ie6789 = ie678 || a == 9
54
55
  , ie67 = ie678 && a < 8
@@ -71,6 +72,7 @@
71
72
  wheel: wheelEv
72
73
  }
73
74
  , fixFn = Event.fixFn = {
75
+ /* node:coverage ignore next 17 */
74
76
  wheel: wheelEv !== "wheel" && function(el, fn) {
75
77
  // DOMMouseScroll Firefox 1 MouseScrollEvent.detail - number of lines to scroll (-32768/+32768 = page up/down)
76
78
  return function(e) {
@@ -111,15 +113,17 @@
111
113
  patch(b, a, ie6789, isFn)
112
114
 
113
115
  // 20 fps is good enough
114
- patch("request" + (a = "AnimationFrame"), "return setTimeout(a,50)")
116
+ a = "AnimationFrame"
117
+ patch("request" + a, "return setTimeout(a,50)")
115
118
  // window.mozRequestAnimationFrame || // Firefox 4-23
116
119
  // window.webkitRequestAnimationFrame || // Chrome 10-24
117
120
  // window.msRequestAnimationFrame || // IE 10 PP2+
118
121
  patch("cancel" + a, "clearTimeout(a)")
119
122
 
120
123
 
124
+ /* node:coverage ignore next 8 */
121
125
  if (!IS_NODE && !(onhashchange in window) || ie67) {
122
- patch(onhashchange, null)
126
+ patch(onhashchange, NULL)
123
127
  setInterval(function() {
124
128
  if (lastHash !== (lastHash = location.href.split("#")[1]) && isFn(window[onhashchange])) {
125
129
  window[onhashchange]()
@@ -130,6 +134,7 @@
130
134
  // Missing PointerEvents with Scribble enable on Safari 14
131
135
  // https://mikepk.com/2020/10/iOS-safari-scribble-bug/
132
136
  // https://bugs.webkit.org/show_bug.cgi?id=217430
137
+ /* node:coverage ignore next 50 */
133
138
  if (!window.PointerEvent) {
134
139
  // IE10
135
140
  if (window[MS + EV]) {
@@ -175,6 +180,7 @@
175
180
  }
176
181
  _fn.call(el, e)
177
182
  }
183
+ /* node:coverage ignore next 19 */
178
184
  function touchToPointer(e) {
179
185
  var touch
180
186
  , touches = e.changedTouches
@@ -233,7 +239,7 @@
233
239
  return (data[id] = "" + val)
234
240
  },
235
241
  getItem: function(id) {
236
- return data[id]
242
+ return data[id] || NULL
237
243
  },
238
244
  removeItem: function(id) {
239
245
  delete data[id]
@@ -246,7 +252,7 @@
246
252
  }
247
253
 
248
254
  createStorage("session") // Chrome5, FF2, IE8, Safari4
249
- createStorage("local") // Chrome5, FF3.5, IE8, Safari4
255
+ createStorage("local") // Chrome5, FF3.5, IE8, Safari4, IE8
250
256
 
251
257
  // IE8 has console, however, the console object does not exist if the console is not opened.
252
258
  patch("console", {log: nop, error: nop})
@@ -269,7 +275,7 @@
269
275
  // IE 8 serializes `undefined` as `"undefined"`
270
276
  return (
271
277
  isStr(o) ? "\"" + o.replace(jsonRe, jsonFn) + "\"" :
272
- o !== o || o == null || o === Infinity || o === -Infinity ? "null" :
278
+ o !== o || o == NULL || o === Infinity || o === -Infinity ? "null" :
273
279
  typeof o == "object" ? (
274
280
  isFn(o.toJSON) ? stringify(o.toJSON()) :
275
281
  isArray(o) ? "[" + o.map(stringify) + "]" :
@@ -286,15 +292,24 @@
286
292
  // https://bugzilla.mozilla.org/show_bug.cgi?id=666448
287
293
  patch("escape", "return X(a)", esc("a", 0) != "a", esc)
288
294
 
289
- // From Chrome23/Firefox21 parseInt parses leading-zero strings as decimal, not octal
295
+ // Since Chrome23/Firefox21 parseInt parses leading-zero strings as decimal, not octal
290
296
  b = patch("g:parseInt", "return X(a,(b>>>0)||(Y.test(''+a)?16:10))", _parseInt("08") !== 8, _parseInt, /^\s*[-+]?0[xX]/)
291
297
 
298
+ O = Math
299
+ patch("log10", "return X(a)/Y", 0, O.log, O.LN10)
300
+
301
+ a = O.pow
292
302
  O = Number
293
303
  patch("parseInt", b)
294
304
  patch("parseFloat", parseFloat)
295
305
  patch("isNaN", "return a!==a")
296
- patch("isInteger", "return X(a)&&Math.floor(a)===a", 0, patch("isFinite", "return typeof a==='number'&&isFinite(a)"))
297
- patch("isSafeInteger", "return a<=X", 0, patch("MAX_SAFE_INTEGER", 9007199254740991))
306
+ c = "_SAFE_INTEGER"
307
+ patch("EPSILON", a(2, -52))
308
+ patch(
309
+ "isSafeInteger", "return Y(a)&&a>=X&&a<=-X", 0,
310
+ patch("MIN" + c, -patch("MAX" + c, a(2, 53)-1)),
311
+ patch("isInteger", "return X(a)&&a%1===0", 0, patch("isFinite", "return typeof a==='number'&&isFinite(a)"))
312
+ )
298
313
 
299
314
  O = Date
300
315
  patch("now", "return+new Date")
@@ -303,6 +318,7 @@
303
318
  O = O[P]
304
319
  // IE8 toJSON does not return milliseconds
305
320
  // FF37 returns invalid extended ISO-8601, `29349-01-26T00:00:00.000Z` instead of `+029349-01-26T00:00:00.000Z`
321
+ /* node:coverage ignore next */
306
322
  b = O[a = "toISOString"] && new Date(8e14)[a]().length < 27 || ie678
307
323
  patch(a, patch("toJSON", [
308
324
  "a=t.getUTCFullYear();if(a!==a)throw RangeError('Invalid time');return(b=a<0?'-':a>9999?'+':'')+X(a<0?-a:a,'-',b?6:4", "Month()+1,'-'", "Date(),'T'",
@@ -345,7 +361,7 @@
345
361
 
346
362
  // TODO:2021-02-25:lauri:Accept iterable objects
347
363
  //patch("from", "a=S.call(a);return b?a.map(b,c):a")
348
- patch("from", "a=X(a)?a.split(''):b?a:S.call(a);return b?a.map(b,c):a", 0, isStr)
364
+ patch("from", "a=X(a)?a.split(''):S.call(a);return b?a.map(b,c):a", 0, isStr)
349
365
  patch("of", "return S.call(A)")
350
366
 
351
367
  O = O[P]
@@ -389,7 +405,7 @@
389
405
  patch("at", a + "[a]")
390
406
 
391
407
  O = String[P]
392
- patch("at", a + ".charAt(a)")
408
+ patch("s:at", a + ".charAt(a)")
393
409
  patch("endsWith", "return(a+='')===t.slice(-a.length)")
394
410
  patch("startsWith", "return t.lastIndexOf(a,0)===0")
395
411
  patch("trim", "return t.replace(/^\\s+|\\s+$/g,'')")
@@ -399,9 +415,13 @@
399
415
  patch("sendBeacon", function(url, data) {
400
416
  // The synchronous XMLHttpRequest blocks the process of unloading the document,
401
417
  // which in turn causes the next navigation appear to be slower.
402
- url = xhr("POST", url, xhr.unload)
403
- url.setRequestHeader("Content-Type", "text/plain;charset=UTF-8")
404
- url.send(data)
418
+ try {
419
+ url = xhr("POST", url, xhr.unload)
420
+ url.setRequestHeader("Content-Type", "text/plain;charset=UTF-8")
421
+ url.send(data)
422
+ return true
423
+ } catch(e){}
424
+ return false
405
425
  })
406
426
 
407
427
  // The HTML5 document.head DOM tree accessor
@@ -434,10 +454,23 @@
434
454
  , closest = patch("closest", walk.bind(window, "parentNode", 1))
435
455
  , matches = patch("matches", "return!!X(a)(t)", 0, selectorFn)
436
456
 
457
+ /* node:coverage ignore next 13 */
458
+ try {
459
+ O[a = "addEventListener"]("t", NULL, Object.defineProperties({}, {
460
+ capture: { get: function() { canCapture = 1 } }
461
+ }))
462
+ b = "removeEventListener"
463
+ c = "O.call(t,a,b,X(c)?!!c.capture:!!c)"
464
+ if (!canCapture) {
465
+ patch("c:" + a, c, 1, isObj)
466
+ patch("c:" + b, c, 1, isObj)
467
+ }
468
+ } catch(e){}
437
469
  // The addEventListener is supported in Internet Explorer from version 9.
438
470
  // https://developer.mozilla.org/en-US/docs/Web/Reference/Events/wheel
439
471
  // - IE8 always prevents the default of the mousewheel event.
440
- patch("addEventListener", "return(t.attachEvent('on'+a,b=X(t,a,b)),b)", 0, function(el, ev, fn) {
472
+ patch(a, "return(t.attachEvent('on'+a,b=X(t,a,b)),b)", 0, function(el, ev, fn) {
473
+ /* node:coverage ignore next 8 */
441
474
  return function() {
442
475
  var e = new Event(ev)
443
476
  if (e.clientX !== UNDEF) {
@@ -447,7 +480,8 @@
447
480
  fn.call(el, e)
448
481
  }
449
482
  })
450
- patch("removeEventListener", "t.detachEvent('on'+a,b)")
483
+ patch(b, "t.detachEvent('on'+a,b)")
484
+
451
485
 
452
486
  // Note: querySelector in IE8 supports only CSS 2.1 selectors
453
487
  patch((a = "querySelector"), (b = "return X(t,a,Y)"), ie678, find, 1)
@@ -455,8 +489,8 @@
455
489
 
456
490
 
457
491
  function selectorFn(str) {
458
- if (str != null && !isStr(str)) throw Error("Invalid selector")
459
- return selectorCache[str || ""] ||
492
+ if (!str || !isStr(str)) throw Error("Invalid selector")
493
+ return selectorCache[str] ||
460
494
  (selectorCache[str] = Function("m,c", "return function(_,v,a,b){return " +
461
495
  str.split(selectorSplitRe).map(function(sel) {
462
496
  var relation, from
@@ -491,7 +525,7 @@
491
525
  if (first) return el
492
526
  out.push(el)
493
527
  }
494
- return first ? null : out
528
+ return first ? NULL : out
495
529
  }
496
530
 
497
531
  function find(node, sel, first) {
@@ -504,6 +538,7 @@
504
538
 
505
539
  // ie6789
506
540
  // The documentMode is an IE only property, supported from IE8.
541
+ /* node:coverage ignore next 8 */
507
542
  if (ie678) {
508
543
  try {
509
544
  // Remove background image flickers on hover in IE6
@@ -516,6 +551,10 @@
516
551
  function isFn(value) {
517
552
  return typeof value === "function"
518
553
  }
554
+ /* node:coverage ignore next 3 */
555
+ function isObj(obj) {
556
+ return !!obj && obj.constructor === Object
557
+ }
519
558
  function isStr(value) {
520
559
  return typeof value === "string"
521
560
  }
@@ -530,7 +569,3 @@
530
569
  ))
531
570
  }
532
571
  }(this, Date, Function, Infinity, "prototype") // jshint ignore:line
533
- /* c8 ignore stop */
534
-
535
-
536
-