@litejs/ui 23.3.2 → 23.3.3
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 +43 -34
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -234,6 +234,7 @@
|
|
|
234
234
|
/* global El, xhr */
|
|
235
235
|
!function(exports) {
|
|
236
236
|
var fn, lastView, lastStr, lastUrl, syncResume
|
|
237
|
+
, body = document.body
|
|
237
238
|
, isArray = Array.isArray
|
|
238
239
|
, capture = 1
|
|
239
240
|
, fnStr = ""
|
|
@@ -247,16 +248,17 @@
|
|
|
247
248
|
, defaults = {
|
|
248
249
|
base: "view/",
|
|
249
250
|
home: "home",
|
|
250
|
-
root:
|
|
251
|
+
root: body
|
|
251
252
|
}
|
|
252
253
|
|
|
253
254
|
exports.View = View
|
|
254
255
|
exports.LiteJS = LiteJS
|
|
255
256
|
|
|
256
257
|
|
|
257
|
-
function LiteJS(
|
|
258
|
+
function LiteJS(opts) {
|
|
259
|
+
opts = Object.assign({}, defaults, opts)
|
|
258
260
|
var key, name
|
|
259
|
-
,
|
|
261
|
+
, root = opts.root
|
|
260
262
|
for (key in opts) if (hasOwn.call(opts, key)) {
|
|
261
263
|
if (typeof View[key] === "function") {
|
|
262
264
|
for (name in opts[key]) if (hasOwn.call(opts[key], name)) {
|
|
@@ -266,7 +268,13 @@
|
|
|
266
268
|
View[key] = opts[key]
|
|
267
269
|
}
|
|
268
270
|
}
|
|
269
|
-
View("#
|
|
271
|
+
View("#", root)
|
|
272
|
+
View.$ = function(sel, start) {
|
|
273
|
+
return body.querySelector.call(start || root, sel)
|
|
274
|
+
}
|
|
275
|
+
View.$$ = function(sel, start) {
|
|
276
|
+
return Array.from(body.querySelectorAll.call(start || root, sel))
|
|
277
|
+
}
|
|
270
278
|
return View
|
|
271
279
|
}
|
|
272
280
|
|
|
@@ -331,7 +339,7 @@
|
|
|
331
339
|
} else {
|
|
332
340
|
if (tmp.route === "404") {
|
|
333
341
|
El.txt(tmp = El("h3"), "# Error 404")
|
|
334
|
-
View("404", tmp, "#
|
|
342
|
+
View("404", tmp, "#")
|
|
335
343
|
}
|
|
336
344
|
View("404").show({origin:params})
|
|
337
345
|
}
|
|
@@ -524,11 +532,6 @@
|
|
|
524
532
|
html: function(el, html) {
|
|
525
533
|
el.innerHTML = html
|
|
526
534
|
},
|
|
527
|
-
md: El.md = function(el, txt) {
|
|
528
|
-
txt = txt.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """)
|
|
529
|
-
txt = txt.replace(/\n/g, "<br>")
|
|
530
|
-
el.innerHTML = txt
|
|
531
|
-
},
|
|
532
535
|
ref: function(el, name) {
|
|
533
536
|
this[name] = el
|
|
534
537
|
},
|
|
@@ -1081,18 +1084,18 @@
|
|
|
1081
1084
|
return
|
|
1082
1085
|
}
|
|
1083
1086
|
|
|
1084
|
-
hydrate(node, BIND_ATTR, scope)
|
|
1085
|
-
for (bind = node.firstChild; bind; bind = fn) {
|
|
1086
|
-
fn = bind.nextSibling
|
|
1087
|
-
render(bind, scope)
|
|
1088
|
-
}
|
|
1089
|
-
hydrate(node, "data-out", scope)
|
|
1090
|
-
|
|
1091
1087
|
/*** ie8 ***/
|
|
1092
1088
|
if (ie678 && node.tagName === "SELECT") {
|
|
1093
1089
|
node.parentNode.insertBefore(node, node)
|
|
1094
1090
|
}
|
|
1095
1091
|
/**/
|
|
1092
|
+
|
|
1093
|
+
if (hydrate(node, BIND_ATTR, scope)) return
|
|
1094
|
+
for (bind = node.firstChild; bind; bind = fn) {
|
|
1095
|
+
fn = bind.nextSibling
|
|
1096
|
+
render(bind, scope)
|
|
1097
|
+
}
|
|
1098
|
+
hydrate(node, "data-out", scope)
|
|
1096
1099
|
}
|
|
1097
1100
|
|
|
1098
1101
|
function hydrate(node, attr, scope) {
|
|
@@ -1127,7 +1130,7 @@
|
|
|
1127
1130
|
(vars[0] ? "var " + vars.join("='',") + "='';" : "") +
|
|
1128
1131
|
"with(data||{})return " + fn
|
|
1129
1132
|
).call(node, node, scope, bindings, setAttr, attr)) {
|
|
1130
|
-
return
|
|
1133
|
+
return true
|
|
1131
1134
|
}
|
|
1132
1135
|
} catch (e) {
|
|
1133
1136
|
/*** debug ***/
|
|
@@ -1207,10 +1210,10 @@
|
|
|
1207
1210
|
if (parent._r) {
|
|
1208
1211
|
parent.txt += all + "\n"
|
|
1209
1212
|
} else if (plugin || mapStart && (name = "map")) {
|
|
1210
|
-
if (
|
|
1213
|
+
if (plugins[name]) {
|
|
1211
1214
|
parentStack.push(parent)
|
|
1212
1215
|
stack.unshift(q)
|
|
1213
|
-
parent = (new
|
|
1216
|
+
parent = (new plugins[name](parent, op + text, mapEnd ? "" : ";")).el
|
|
1214
1217
|
} else {
|
|
1215
1218
|
append(parent, all)
|
|
1216
1219
|
}
|
|
@@ -1256,7 +1259,9 @@
|
|
|
1256
1259
|
|
|
1257
1260
|
function plugin(parent, name) {
|
|
1258
1261
|
var t = this
|
|
1259
|
-
|
|
1262
|
+
, arr = name.split(splitRe)
|
|
1263
|
+
t.name = arr[0]
|
|
1264
|
+
t.attr = arr.slice(1)
|
|
1260
1265
|
t.parent = parent
|
|
1261
1266
|
t.el = El("div")
|
|
1262
1267
|
t.el.plugin = t
|
|
@@ -1278,12 +1283,6 @@
|
|
|
1278
1283
|
|
|
1279
1284
|
t.el.plugin = t.el = t.parent = null
|
|
1280
1285
|
return el
|
|
1281
|
-
},
|
|
1282
|
-
done: function() {
|
|
1283
|
-
var t = this
|
|
1284
|
-
, parent = t.parent
|
|
1285
|
-
elCache[t.name] = t._done()
|
|
1286
|
-
return parent
|
|
1287
1286
|
}
|
|
1288
1287
|
}
|
|
1289
1288
|
|
|
@@ -1299,7 +1298,7 @@
|
|
|
1299
1298
|
|
|
1300
1299
|
js[P].done = Function("Function(this.txt)()")
|
|
1301
1300
|
|
|
1302
|
-
El.plugins = {
|
|
1301
|
+
var plugins = El.plugins = {
|
|
1303
1302
|
binding: extend(js, {
|
|
1304
1303
|
done: function() {
|
|
1305
1304
|
Object.assign(bindings, Function("return({" + this.txt + "})")())
|
|
@@ -1334,6 +1333,16 @@
|
|
|
1334
1333
|
}),
|
|
1335
1334
|
el: extend(plugin, {
|
|
1336
1335
|
content: 1,
|
|
1336
|
+
done: function() {
|
|
1337
|
+
var t = this
|
|
1338
|
+
, parent = t.parent
|
|
1339
|
+
, arr = t.attr
|
|
1340
|
+
t = elCache[t.name] = t._done()
|
|
1341
|
+
if (arr[0]) {
|
|
1342
|
+
// TODO:2023-03-22:lauri:Add new scope
|
|
1343
|
+
}
|
|
1344
|
+
return parent
|
|
1345
|
+
}
|
|
1337
1346
|
}),
|
|
1338
1347
|
js: js,
|
|
1339
1348
|
map: extend(js, {
|
|
@@ -1352,9 +1361,9 @@
|
|
|
1352
1361
|
done: function() {
|
|
1353
1362
|
var fn
|
|
1354
1363
|
, t = this
|
|
1355
|
-
, arr = t.
|
|
1364
|
+
, arr = t.attr
|
|
1356
1365
|
, bind = getAttr(t.el, BIND_ATTR)
|
|
1357
|
-
, view = View(
|
|
1366
|
+
, view = View(t.name, t._done(), arr[0], arr[1])
|
|
1358
1367
|
if (bind) {
|
|
1359
1368
|
fn = bind.replace(renderRe, function(match, name, op, args) {
|
|
1360
1369
|
return "(this['" + name + "']" + (
|
|
@@ -1370,15 +1379,15 @@
|
|
|
1370
1379
|
"view-link": extend(plugin, {
|
|
1371
1380
|
done: function() {
|
|
1372
1381
|
var t = this
|
|
1373
|
-
, arr = t.
|
|
1374
|
-
View(
|
|
1382
|
+
, arr = t.attr
|
|
1383
|
+
View(t.name, null, arr[1])
|
|
1375
1384
|
.on("ping", function(opts) {
|
|
1376
|
-
View.show(arr[
|
|
1385
|
+
View.show(arr[0].format(opts))
|
|
1377
1386
|
})
|
|
1378
1387
|
}
|
|
1379
1388
|
})
|
|
1380
1389
|
}
|
|
1381
|
-
|
|
1390
|
+
plugins.child = plugins.slot
|
|
1382
1391
|
|
|
1383
1392
|
xhr.view = xhr.tpl = El.tpl = parseTemplate
|
|
1384
1393
|
xhr.css = function(str) {
|