@litejs/ui 21.3.1 → 21.11.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/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * @version 21.3.1
2
+ * @version 21.11.0
3
3
  * @author Lauri Rooden <lauri@rooden.ee>
4
4
  * @license MIT License
5
5
  */
@@ -731,12 +731,13 @@
731
731
  /*** PUSH ***/
732
732
  }
733
733
  /**/
734
- checkUrl()
734
+ return checkUrl()
735
735
  }
736
736
 
737
737
  function checkUrl() {
738
- if (lastRoute != (lastRoute = getUrl()) && cb) {
739
- cb(lastRoute)
738
+ if (lastRoute != (lastRoute = getUrl())) {
739
+ if (cb) cb(lastRoute)
740
+ return true
740
741
  }
741
742
  }
742
743
 
@@ -805,13 +806,14 @@
805
806
 
806
807
 
807
808
  !function(exports) {
808
- var fn, lastView, lastParams, lastStr, lastUrl, syncResume
809
+ var fn, lastView, lastStr, lastUrl, syncResume
809
810
  , isArray = Array.isArray
810
811
  , capture = 1
811
812
  , fnStr = ""
812
813
  , reStr = ""
813
814
  , views = View.views = {}
814
815
  , paramCb = {}
816
+ , lastParams = paramCb
815
817
  , hasOwn = views.hasOwnProperty
816
818
  , escapeRe = /[.*+?^=!:${}()|\[\]\/\\]/g
817
819
  , parseRe = /\{([\w%.]+?)\}|.[^{\\]*?/g
@@ -899,6 +901,10 @@
899
901
  view.wait(tmp.file = null)
900
902
  )
901
903
  } else {
904
+ if (tmp.route == "404") {
905
+ El.txt(tmp = El("h3"), "# Error 404")
906
+ View("404", tmp, "#body")
907
+ }
902
908
  View("404").show({origin:params})
903
909
  }
904
910
  return
@@ -986,7 +992,7 @@
986
992
  "return function(i,o,d){var m=r.exec(i);return m!==null?(" + fnStr + "d):d}"
987
993
  )()
988
994
  }
989
- return View(fn(url || View.home, params || {}, "404"))
995
+ return View(url ? fn(url, params || {}, "404") : View.home)
990
996
  }
991
997
 
992
998
  View.ping = function(name, fn) {
@@ -1052,9 +1058,8 @@
1052
1058
  /* litejs.com/MIT-LICENSE.txt */
1053
1059
 
1054
1060
 
1055
-
1056
1061
  !function(window, document, Object, Event, protoStr) {
1057
- var styleNode
1062
+ var UNDEF, styleNode
1058
1063
  , BIND_ATTR = "data-bind"
1059
1064
  , isArray = Array.isArray
1060
1065
  , seq = 0
@@ -1065,13 +1070,13 @@
1065
1070
  , body = document.body
1066
1071
  , root = document.documentElement
1067
1072
  , txtAttr = El.T = "textContent" in body ? "textContent" : "innerText"
1068
- , templateRe = /^([ \t]*)(%?)((?:("|')(?:\\?.)*?\4|[-\w:.#[\]]=?)*)[ \t]*([>^;@|\\\/]|!?=|)(([\])}]?).*?([[({]?))$/gm
1073
+ , templateRe = /([ \t]*)(%?)((?:("|')(?:\\?.)*?\4|[-\w:.#[\]]=?)*)[ \t]*([>^;@|\\\/]|!?=|)(([\])}]?).*?([[({]?))(?=\x1f+|\n+|$)/g
1069
1074
  , renderRe = /[;\s]*(\w+)(?:\s*(:?):((?:(["'\/])(?:\\?.)*?\3|[^;])*))?/g
1070
1075
  , selectorRe = /([.#:[])([-\w]+)(?:\((.+?)\)|([~^$*|]?)=(("|')(?:\\?.)*?\6|[-\w]+))?]?/g
1071
1076
  , splitRe = /[,\s]+/
1072
1077
  , camelRe = /\-([a-z])/g
1073
1078
  , bindings = El.bindings = {
1074
- attr: setAttr,
1079
+ attr: El.attr = acceptMany(setAttr, getAttr),
1075
1080
  cls: El.cls = acceptMany(cls),
1076
1081
  css: El.css = acceptMany(function(el, key, val) {
1077
1082
  el.style[key.replace(camelRe, camelFn)] = "" + val || ""
@@ -1147,6 +1152,10 @@
1147
1152
  * <input id="12" class="nice class" type="checkbox" checked="checked" disabled="disabled" data-lang="en">
1148
1153
  */
1149
1154
 
1155
+ function isObject(obj) {
1156
+ return obj && obj.constructor === Object
1157
+ }
1158
+
1150
1159
  window.El = El
1151
1160
 
1152
1161
  function El(name) {
@@ -1204,10 +1213,6 @@
1204
1213
  return a.toUpperCase()
1205
1214
  }
1206
1215
 
1207
- El.attr = function(el, key, val) {
1208
- return arguments.length < 3 && key.constructor != Object ? getAttr(el, key) : setAttr(el, key, val)
1209
- }
1210
-
1211
1216
  function getAttr(el, key) {
1212
1217
  return el && el.getAttribute && el.getAttribute(key)
1213
1218
  }
@@ -1215,7 +1220,7 @@
1215
1220
  function setAttr(el, key, val) {
1216
1221
  var current
1217
1222
 
1218
- if (key && key.constructor == Object) {
1223
+ if (isObject(key)) {
1219
1224
  for (current in key) {
1220
1225
  setAttr(el, current, key[current])
1221
1226
  }
@@ -1286,7 +1291,7 @@
1286
1291
 
1287
1292
  for (; input = el.elements[i++]; ) if (!input.disabled && (key = input.name || input.id)) {
1288
1293
  value = valFn(input)
1289
- if (value !== void 0) {
1294
+ if (value !== UNDEF) {
1290
1295
  step = opts
1291
1296
  key.replace(/\[(.*?)\]/g, function(_, _key, offset) {
1292
1297
  if (step == opts) key = key.slice(0, offset)
@@ -1329,8 +1334,8 @@
1329
1334
  }
1330
1335
 
1331
1336
  return checkbox && !el.checked ?
1332
- (type === "radio" ? void 0 : null) :
1333
- el.valObject !== void 0 ? el.valObject : el.value
1337
+ (type === "radio" ? UNDEF : null) :
1338
+ el.valObject !== UNDEF ? el.valObject : el.value
1334
1339
  }
1335
1340
 
1336
1341
  function append(el, child, before) {
@@ -1387,10 +1392,16 @@
1387
1392
  function acceptMany(fn, getter) {
1388
1393
  return function f(el, name, val, delay) {
1389
1394
  if (el && name) {
1390
- if (delay > 0) return setTimeout(f, delay, el, name, val)
1391
- if (name.constructor === Object) {
1395
+ if (delay >= 0) {
1396
+ if (delay > 0) setTimeout(f, delay, el, name, val)
1397
+ else requestAnimationFrame(function() {
1398
+ f(el, name, val)
1399
+ })
1400
+ return
1401
+ }
1402
+ if (isObject(name)) {
1392
1403
  for (i in name) {
1393
- if (hasOwn.call(name, i)) f(el, i, name[i])
1404
+ if (hasOwn.call(name, i)) f(el, i, name[i], val)
1394
1405
  }
1395
1406
  return
1396
1407
  }
@@ -1477,7 +1488,7 @@
1477
1488
  var fn = fixFn[ev] && fixFn[ev](el, _fn, ev) || _fn
1478
1489
  , fix = prefix ? function() {
1479
1490
  var e = new Event(ev)
1480
- if (e.clientX !== void 0) {
1491
+ if (e.clientX !== UNDEF) {
1481
1492
  e.pageX = e.clientX + scrollLeft()
1482
1493
  e.pageY = e.clientY + scrollTop()
1483
1494
  }
@@ -1527,7 +1538,10 @@
1527
1538
  selector = null
1528
1539
  }
1529
1540
  }
1530
- if (delay > 0) return setTimeout(bindingOn, delay, el, events, selector, data, handler)
1541
+ if (delay > 0) {
1542
+ setTimeout(bindingOn, delay, el, events, selector, data, handler)
1543
+ return
1544
+ }
1531
1545
  var fn = (
1532
1546
  typeof handler == "string" ? function(e) {
1533
1547
  var target = selector ? El.closest(e.target, selector) : el
@@ -1565,15 +1579,19 @@
1565
1579
  }
1566
1580
 
1567
1581
  function empty(el) {
1568
- for (var node; node = el.firstChild; ) {
1569
- kill(node)
1570
- }
1582
+ for (var node; node = el.firstChild; kill(node));
1571
1583
  return el
1572
1584
  }
1573
1585
 
1574
- function kill(el) {
1586
+ function kill(el, tr, delay) {
1575
1587
  var id
1576
1588
  if (el) {
1589
+ if (delay > 0) return setTimeout(kill, delay, el, tr)
1590
+ if (tr) {
1591
+ cls(el, tr, tr = "transitionend")
1592
+ // transitionend fires for each property transitioned
1593
+ if ("on" + tr in el) return addEvent(el, tr, kill.bind(el, el, el = null))
1594
+ }
1577
1595
  if (el._e) {
1578
1596
  emitter.emit.call(el, "kill")
1579
1597
  for (id in el._e) rmEvent(el, id)
@@ -1585,11 +1603,11 @@
1585
1603
  return el.kill && el.kill()
1586
1604
  }
1587
1605
  empty(el)
1588
- if (id = el._scope) {
1589
- delete elScope[id]
1606
+ if (el._scope !== UNDEF) {
1607
+ delete elScope[el._scope]
1590
1608
  }
1591
- if (el.valObject) {
1592
- el.valObject = null
1609
+ if (el.valObject !== UNDEF) {
1610
+ el.valObject = UNDEF
1593
1611
  }
1594
1612
  }
1595
1613
  }
@@ -1628,14 +1646,14 @@
1628
1646
 
1629
1647
  fn = "data b s B r->data&&(" + bind.replace(renderRe, function(match, name, op, args) {
1630
1648
  scope._m[i] = match
1631
- var fn = bindings[name]
1649
+ match = bindings[name]
1632
1650
  return (
1633
- (op == ":" || fn && hasOwn.call(fn, "once")) ?
1651
+ (op == ":" || match && hasOwn.call(match, "once")) ?
1634
1652
  "s(this,B,data._t=data._t.replace(data._m[" + (i++)+ "],''))||" :
1635
1653
  ""
1636
1654
  ) + (
1637
- fn ?
1638
- "b['" + name + "'].call(data,this" + (fn.raw ? ",'" + args + "'" : args ? "," + args : "") :
1655
+ match ?
1656
+ "b['" + name + "'].call(data,this" + (match.raw ? ",'" + args + "'" : args ? "," + args : "") :
1639
1657
  "s(this,'" + name + "'," + args
1640
1658
  ) + ")||"
1641
1659
  }) + "r)"
@@ -1698,10 +1716,10 @@
1698
1716
  }
1699
1717
 
1700
1718
  wrapProto.cloneNode = function(deep) {
1701
- var clone = new ElWrap(this, deep)
1702
- clone._ca = this._ca
1703
- //clone._cb = this._cb
1704
- return clone
1719
+ deep = new ElWrap(this, deep)
1720
+ deep._ca = this._ca
1721
+ //deep._cb = this._cb
1722
+ return deep
1705
1723
  }
1706
1724
 
1707
1725
  El.append = append
@@ -1843,10 +1861,7 @@
1843
1861
 
1844
1862
  JSON.parse(this.params)
1845
1863
  .each(function(val) {
1846
- if (!val || val.constructor != Object) {
1847
- val = { item: val }
1848
- }
1849
- parseTemplate(txt.format(val))
1864
+ parseTemplate(txt.format(isObject(val) ? val : { item: val }))
1850
1865
  })
1851
1866
  }
1852
1867
  }),
@@ -1919,7 +1934,7 @@
1919
1934
  /*** kb ***/
1920
1935
  var kbMaps = []
1921
1936
  , kbMod = El.kbMod = iOS ? "metaKey" : "ctrlKey"
1922
- , kbKeys = {
1937
+ , kbMap = El.kbMap = {
1923
1938
  8: "backspace", 9: "tab",
1924
1939
  13: "enter", 16: "shift", 17: "ctrl", 18: "alt", 19: "pause",
1925
1940
  20: "caps", 27: "esc",
@@ -1952,7 +1967,7 @@
1952
1967
  var c = e.keyCode || e.which
1953
1968
  , numpad = c > 95 && c < 106
1954
1969
  , code = numpad ? c - 48 : c
1955
- , key = kbKeys[code] || String.fromCharCode(code).toLowerCase() || code
1970
+ , key = kbMap[code] || String.fromCharCode(code).toLowerCase() || code
1956
1971
 
1957
1972
  // Otherwise IE backspace navigates back
1958
1973
  if (code == 8 && kbMaps[0].backspace) {
@@ -1976,15 +1991,14 @@
1976
1991
  if (map) {
1977
1992
  kbMaps.unshift(map)
1978
1993
  if (killEl) {
1979
- // addEvent(killEl, "kill", rmKb.bind(map, map))
1980
1994
  emitter.on.call(killEl, "kill", rmKb.bind(map, map))
1981
1995
  }
1982
1996
  }
1983
1997
  }
1984
1998
  El.rmKb = rmKb
1985
1999
  function rmKb(map) {
1986
- var i = kbMaps.indexOf(map||kbMaps[0])
1987
- if (i > -1) kbMaps.splice(i, 1)
2000
+ map = kbMaps.indexOf(map || kbMaps[0])
2001
+ if (map > -1) kbMaps.splice(map, 1)
1988
2002
  }
1989
2003
 
1990
2004
  addEvent(document, "keydown", kbDown)
@@ -2035,277 +2049,4 @@
2035
2049
  addEvent(window, "orientationchange", setBreakpointsRated)
2036
2050
  addEvent(window, "load", setBreakpointsRated)
2037
2051
  /**/
2038
- }(window, document, Object, Event, "prototype")
2039
- /* litejs.com/MIT-LICENSE.txt */
2040
-
2041
-
2042
-
2043
- !function(bindings) {
2044
- var hasOwn = Object.prototype.hasOwnProperty
2045
- , slice = Array.prototype.slice
2046
-
2047
- fixReadonlyCheckbox.once =
2048
- bindingEvery.once =
2049
- emitForm.once =
2050
- bindingFn.once =
2051
- bindingsEach.raw = bindingsEach.once =
2052
- true
2053
-
2054
- bindings.every = bindingEvery
2055
- function bindingEvery(el, list, attrName) {
2056
- var len = 0
2057
- , data = this
2058
- , parent = el.parentNode
2059
- , comm = document.createComment("every " + (list.name || list.length))
2060
- , nodes = []
2061
-
2062
- parent.replaceChild(comm, el)
2063
-
2064
- if (list) {
2065
- if (typeof list === "string") {
2066
- data.model.on("change:" + list, render)
2067
- El.on(parent, "kill", function() {
2068
- data.model.off("change:" + list, render)
2069
- })
2070
- render()
2071
- } else if (list.eachLive) {
2072
- list.eachLive(add, remove, list)
2073
- El.on(parent, "kill", function() {
2074
- list.off("add", add, list).off("remove", remove, list)
2075
- })
2076
- } else {
2077
- comm.render = render
2078
- render()
2079
- }
2080
- }
2081
- return true
2082
-
2083
- function render() {
2084
- for (; len; len--) {
2085
- remove(len)
2086
- }
2087
- _list = typeof list === "string" ? data.model.get(list, []) : list
2088
- if (typeof _list === "string") _list.split(",")
2089
- Object.each(_list, add, (
2090
- _list.constructor === Object ? Object.keys(_list) : _list
2091
- ))
2092
- }
2093
-
2094
- function add(item, i) {
2095
- len++
2096
- var up
2097
- , clone = el.cloneNode(true)
2098
- , scope = El.scope(clone, data)
2099
- , before = nodes[i] || comm
2100
- if (!before.parentNode) return
2101
- nodes.splice(i, 0, clone)
2102
- scope.i = i
2103
- scope._scope = scope
2104
- scope.len = this.length
2105
- scope[attrName || "item"] = item
2106
- El.append(before.parentNode, clone, before)
2107
- El.render(clone, scope)
2108
- if (typeof item.on === "function") {
2109
- item.on("change", up = El.render.bind(clone, clone))
2110
- El.on(clone, "kill", function() {
2111
- item.off("change", up)
2112
- })
2113
- }
2114
- }
2115
-
2116
- function remove(item, i) {
2117
- El.kill(nodes.splice(i, 1)[0])
2118
- }
2119
- }
2120
-
2121
- bindings.fixReadonlyCheckbox = fixReadonlyCheckbox
2122
- function fixReadonlyCheckbox(el) {
2123
- El.on(el, "click pointerdown", function(e) {
2124
- if ((this.firstChild || this).readOnly) {
2125
- return Event.stop(e)
2126
- }
2127
- })
2128
- }
2129
-
2130
- bindings.fn = bindingFn
2131
- function bindingFn(el, fn) {
2132
- return fn.apply(el, slice.call(arguments, 3))
2133
- }
2134
-
2135
- bindings["if"] = bindingsIf
2136
- function bindingsIf(el, enabled) {
2137
- var parent = el.parentNode
2138
- , scope = this
2139
- if (enabled) {
2140
- parent || el._ifComm && el._ifComm.parentNode.replaceChild(el, el._ifComm)
2141
- } else {
2142
- if (parent) {
2143
- if (!el._ifComm) {
2144
- El.on(el, "kill", El.kill.bind(el, el._ifComm = document.createComment("if")))
2145
- el._ifComm.render = function() {
2146
- El.render(el, scope)
2147
- }
2148
- }
2149
- parent.replaceChild(el._ifComm, el)
2150
- }
2151
- return true
2152
- }
2153
- }
2154
-
2155
- bindings.is = function bindingIs(node, model, path, list, state) {
2156
- var match
2157
- , scope = this
2158
- if (typeof model === "string") {
2159
- state = list
2160
- list = path
2161
- path = model
2162
- model = scope.model
2163
- }
2164
- if (model && path) {
2165
- match = i18n.pick(state != null ? state : model.get(path), list)
2166
- El.cls(node, scope["_is-" + path], 0)
2167
- El.cls(node, scope["_is-" + path] = match && "is-" + match)
2168
- }
2169
- }
2170
-
2171
- bindings.emitForm = emitForm
2172
- function emitForm(el, ev, a1, a2, a3, a4) {
2173
- El.on(el, "submit", function(e) {
2174
- var data = El.val(el)
2175
- View.emit(ev, e, data, a1, a2, a3, a4)
2176
- return Event.stop(e)
2177
- })
2178
- }
2179
-
2180
- function getChilds(node) {
2181
- var child
2182
- , childs = node._childs
2183
- if (!childs) {
2184
- for (node._childs = childs = []; child = node.firstChild;) {
2185
- childs.push(child);
2186
- node.removeChild(child)
2187
- }
2188
- }
2189
- return childs
2190
- }
2191
-
2192
- bindings.each = bindingsEach
2193
-
2194
- function bindingsEach(el, expr) {
2195
- var node = el
2196
- , child = getChilds(node)[0]
2197
- , match = /^\s*(\w+) in (\w*)(.*)/.exec(expr)
2198
- , fn = "with(data){var out=[],loop={i:0,offset:0},_1,_2=" + match[2]
2199
- + match[3].replace(/ (limit|offset):\s*(\d+)/ig, ";loop.$1=$2")
2200
- + ";if(_2)for(_1 in _2)if(hasOwn.call(_2,_1)&&!(loop.offset&&loop.offset--)){"
2201
- + "loop.i++;"
2202
- + "if(loop.limit&&loop.i-loop.offset>loop.limit)break;"
2203
- + "var clone=el.cloneNode(true)"
2204
- + ",scope=El.scope(clone,data);"
2205
- + "scope.loopKey=loop.key=_1;"
2206
- + "scope.loop=loop;"
2207
- + "scope." + match[1] + "=_2[_1];"
2208
- + "out.push(clone);"
2209
- + "};return out}"
2210
-
2211
- var childs = Function("hasOwn,el,data", fn)(hasOwn, child, this)
2212
-
2213
- El.append(El.empty(node), childs)
2214
- El.render(node)
2215
- return node
2216
- }
2217
-
2218
- bindings.focus = function(el) {
2219
- el.focus()
2220
- }
2221
-
2222
- bindings.href = function(el, url) {
2223
- if (url) {
2224
- var chr = url.charAt(0)
2225
- El.attr(el, "href", chr === "+" || chr === "%" ? "#" + View.expand(url) : url)
2226
- }
2227
- }
2228
- }(El.bindings)
2229
- /* litejs.com/MIT-LICENSE.txt */
2230
-
2231
-
2232
-
2233
- El.bindings.list = function(node, list, extra, val) {
2234
- var child = node._child
2235
- , data = this
2236
- , extraLen = 0
2237
-
2238
- if (!child) {
2239
- child = node._child = node.removeChild(node.firstChild)
2240
- }
2241
-
2242
- if (!list || node._list == list) return
2243
-
2244
- if (node._list) clear()
2245
-
2246
- node._list = data.list = list
2247
-
2248
- El.on(node, "kill", clear)
2249
-
2250
- El.cls(node, "loading")
2251
-
2252
- if (extra) {
2253
- extra.each(clone)
2254
- extraLen = extra.length
2255
- }
2256
-
2257
- list
2258
- .each(clone)
2259
- .on("add", clone).on("remove", remove)
2260
- .on("startLoading", function(){
2261
- El.cls(node, "loading")
2262
- })
2263
- .on("endLoading", function(){
2264
- El.cls(node, "loading", 0)
2265
- })
2266
- .then(function() {
2267
- if (val !== void 0 && El.val(node) !== val) {
2268
- if (!this.get(val)) {
2269
- clone({id:val,name:val}, extraLen)
2270
- extraLen++
2271
- }
2272
- El.val(node, val)
2273
- }
2274
- El.cls(node, "loading", 0)
2275
- })
2276
-
2277
- // Do not render childs when list initialized
2278
- return true
2279
-
2280
- function clone(item, pos) {
2281
- var clone = child.cloneNode(true)
2282
- , scope = El.scope(clone, data)
2283
- scope.item = item.data || item || {id:item,name:item}
2284
- scope.model = item
2285
- scope.pos = pos
2286
- function up() {
2287
- El.render(clone, scope)
2288
- }
2289
- if (item.on) {
2290
- item.on("change", up)
2291
- El.on(clone, "kill", function(){
2292
- item.off("change", up)
2293
- })
2294
- }
2295
- El.append(node, clone, extraLen + pos)
2296
- return El.render(clone, scope)
2297
- }
2298
-
2299
- function remove(item, pos) {
2300
- El.kill(node.childNodes[extraLen + pos])
2301
- }
2302
-
2303
- function clear() {
2304
- var list = node._list
2305
- El.empty(node)
2306
- if (list) {
2307
- node._list = null
2308
- list.off("add", clone).off("remove", remove)
2309
- }
2310
- }
2311
- }
2052
+ }(window, document, Object, Event, "prototype")
package/load.js CHANGED
@@ -24,7 +24,7 @@
24
24
  // XDomainRequest is a CORS implementation in IE8/9 and was removed in IE10 in favor of using XMLHttpRequest with proper CORS
25
25
  // IE does not allow to add arbitrary properties to ActiveX objects.
26
26
  // IE does not allow to assign or read the readystatechange after the send().
27
- // Last version-independent ProgID with 3.0 is good enough (MSXML2 is supported from IE4.01).
27
+ // Last version-independent ProgID with 3.0 is good enough (MSXML2 namespace is supported from IE6).
28
28
  // MSXML 6.0 has improved XSD, deprecated several legacy features
29
29
  // What's New in MSXML 6.0: https://msdn.microsoft.com/en-us/library/ms753751.aspx
30
30
 
@@ -32,8 +32,12 @@
32
32
  xhr._s = new Date
33
33
  var loaded = {}
34
34
  , urlEscRe = /[+#\s]+/g
35
- , XMLHttpRequest = +"\v1" && window.XMLHttpRequest || Function("return new ActiveXObject('MSXML2.XMLHTTP')")
36
- , execScript = window.execScript ||
35
+ /*** activex ***/
36
+ , XMLHttpRequest = +"\v1" && window.XMLHttpRequest || Function("return new ActiveXObject('Microsoft.XMLHTTP')")
37
+ /**/
38
+ , execScript =
39
+ // IE5-10, Chrome1-12
40
+ window.execScript ||
37
41
  /*** inject ***/
38
42
  // THANKS: Juriy Zaytsev - Global eval [http://perfectionkills.com/global-eval-what-are-the-options/]
39
43
  Function("e,eval", "try{return e('eval')==e&&e}catch(e){}")(eval) ||
@@ -49,9 +53,7 @@
49
53
  /*** onerror ***/
50
54
  , lastError
51
55
  , unsentErrors = []
52
-
53
- window.onerror = onerror
54
- function onerror(message, file, line, col, error) {
56
+ , onerror = window.onerror = function(message, file, line, col, error) {
55
57
  // Do not send multiple copies of the same error.
56
58
  // file = document.currentScript.src || import.meta.url
57
59
  if (lastError !== (lastError =
@@ -71,12 +73,14 @@
71
73
  }
72
74
 
73
75
  function sendErrors() {
74
- if (xhr.logErrors) {
75
- xhr.logErrors(unsentErrors)
76
+ if (xhr.err) {
77
+ xhr.err(unsentErrors)
76
78
  } else {
77
79
  setTimeout(sendErrors, 1307)
78
80
  }
79
81
  }
82
+ /*/
83
+ , onerror = nop
80
84
  /**/
81
85
 
82
86
  // next === true is for sync call
@@ -211,6 +215,7 @@
211
215
  /**/
212
216
 
213
217
 
218
+ /*** load ***/
214
219
  xhr.load = load
215
220
  function load(files, next) {
216
221
  if (typeof files == "string") files = [files]
@@ -222,6 +227,7 @@
222
227
 
223
228
  for (; i < len; i++) if ((file = files[i]) && 2 !== loaded[file]) {
224
229
  if (loaded[file]) {
230
+ // Same file requested again
225
231
  ;(loaded[file].x || (loaded[file].x = [])).push(cb, file, i)
226
232
  } else {
227
233
  // FireFox 3 throws on `xhr.send()` without arguments
@@ -249,6 +255,10 @@
249
255
  }
250
256
  if (res[pos] === "" || !files[pos]) {
251
257
  if (++pos < len) exec()
258
+ /*** inject ***/
259
+ // inject can be async
260
+ else if (pos === len) setTimeout(exec, 1)
261
+ /**/
252
262
  else {
253
263
  if (next) next()
254
264
  if (res = cb.x) {
@@ -259,7 +269,10 @@
259
269
  }
260
270
  }
261
271
 
262
- load([/*!{loadFiles}*/])
272
+ load([
273
+ //!{loadFiles}
274
+ ])
275
+ /**/
263
276
 
264
277
  function nop() {}
265
278
  }(this, Function)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@litejs/ui",
3
- "version": "21.3.1",
3
+ "version": "21.11.0",
4
4
  "description": "UI engine for LiteJS full-stack framework",
5
5
  "license": "MIT",
6
6
  "author": "Lauri Rooden <lauri@rooden.ee>",
@@ -22,9 +22,7 @@
22
22
  "css"
23
23
  ],
24
24
  "litejs": {
25
- "build": [
26
- "-i test/dev.html -o test/index.html"
27
- ]
25
+ "build": "lj b --out=test/index.html test/dev.html"
28
26
  },
29
27
  "jshintConfig": {
30
28
  "asi": true,
@@ -32,7 +30,7 @@
32
30
  "maxdepth": 6,
33
31
  "quotmark": "double"
34
32
  },
35
- "nyc": {
33
+ "c8": {
36
34
  "check-coverage": true,
37
35
  "branches": 100,
38
36
  "lines": 100,