@webqit/oohtml 5.0.7 → 5.0.8
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/bindings-api.js +78 -32
- package/dist/bindings-api.js.map +3 -3
- package/dist/context-api.js +67 -25
- package/dist/context-api.js.map +3 -3
- package/dist/data-binding.js +120 -81
- package/dist/data-binding.js.map +4 -4
- package/dist/html-imports.js +70 -27
- package/dist/html-imports.js.map +3 -3
- package/dist/main.js +937 -282
- package/dist/main.js.map +3 -3
- package/dist/main.lite.js +115 -49
- package/dist/main.lite.js.map +3 -3
- package/dist/namespaced-html.js +69 -27
- package/dist/namespaced-html.js.map +3 -3
- package/dist/scoped-css.js +70 -28
- package/dist/scoped-css.js.map +3 -3
- package/dist/scoped-js.js +109 -68
- package/dist/scoped-js.js.map +4 -4
- package/package.json +3 -3
- package/src/bindings-api/index.js +80 -75
- package/src/context-api/DOMContext.js +2 -1
- package/src/data-binding/index.js +1 -1
- package/src/html-imports/_HTMLImportElement.js +4 -2
- package/src/namespaced-html/index.js +3 -2
- package/src/scoped-css/index.js +2 -1
- package/src/scoped-js/index.js +71 -68
- package/test/bindings-api.test.js +3 -1
- package/test/imports.test.js +8 -0
- package/test/modules.test.js +6 -4
package/dist/data-binding.js
CHANGED
|
@@ -36,63 +36,6 @@ var runtimeParams = {
|
|
|
36
36
|
apiVersion: 3
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
// node_modules/@webqit/realdom/src/realtime/Util.js
|
|
40
|
-
function isXpath(expr) {
|
|
41
|
-
return (expr = expr.trim()) && expr.startsWith("(") && expr.endsWith(")");
|
|
42
|
-
}
|
|
43
|
-
function xpathQuery(window2, context, expr, subtree = true) {
|
|
44
|
-
expr = (Array.isArray(expr) ? expr : [expr]).map((x) => (x + "").replace("(", subtree ? "(.//" : "(./")).join("|");
|
|
45
|
-
let nodes = [], node;
|
|
46
|
-
try {
|
|
47
|
-
const result = window2.document.evaluate(expr, context, null, window2.XPathResult.ANY_TYPE);
|
|
48
|
-
while (node = result.iterateNext())
|
|
49
|
-
nodes.push(node);
|
|
50
|
-
} catch (e) {
|
|
51
|
-
}
|
|
52
|
-
return nodes;
|
|
53
|
-
}
|
|
54
|
-
function xpathMatch(window2, node, expr) {
|
|
55
|
-
expr = (Array.isArray(expr) ? expr : [expr]).map((x) => (x + "").replace("(", "(self::")).join("|");
|
|
56
|
-
try {
|
|
57
|
-
return window2.document.evaluate(`${expr}`, node, null, window2.XPathResult.BOOLEAN_TYPE).booleanValue;
|
|
58
|
-
} catch (e) {
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
function containsNode(window2, a, b, crossRoots = false, testCache = null) {
|
|
62
|
-
const prevTest = testCache?.get(a)?.get(b);
|
|
63
|
-
if (typeof prevTest !== "undefined")
|
|
64
|
-
return prevTest;
|
|
65
|
-
const response = (val) => {
|
|
66
|
-
if (!testCache?.has(a))
|
|
67
|
-
testCache?.set(a, /* @__PURE__ */ new WeakMap());
|
|
68
|
-
testCache?.get(a)?.set(b, val);
|
|
69
|
-
return val;
|
|
70
|
-
};
|
|
71
|
-
const rootNodeA = a.getRootNode();
|
|
72
|
-
const rootNodeB = b.getRootNode();
|
|
73
|
-
if (rootNodeA === rootNodeB)
|
|
74
|
-
return response(a.contains(b));
|
|
75
|
-
if (crossRoots && rootNodeB instanceof window2.ShadowRoot)
|
|
76
|
-
return response(containsNode(window2, a, rootNodeB.host, crossRoots, testCache));
|
|
77
|
-
return response(false);
|
|
78
|
-
}
|
|
79
|
-
function splitOuter(str, delim = "|") {
|
|
80
|
-
return [...str].reduce(([quote, depth, splits, skip], x) => {
|
|
81
|
-
if (!quote && depth === 0 && (Array.isArray(delim) ? delim : [delim]).includes(x)) {
|
|
82
|
-
return [quote, depth, [""].concat(splits)];
|
|
83
|
-
}
|
|
84
|
-
if (!quote && ["(", "[", "{"].includes(x) && !splits[0].endsWith("\\"))
|
|
85
|
-
depth++;
|
|
86
|
-
if (!quote && [")", "]", "}"].includes(x) && !splits[0].endsWith("\\"))
|
|
87
|
-
depth--;
|
|
88
|
-
if (['"', "'", "`"].includes(x) && !splits[0].endsWith("\\")) {
|
|
89
|
-
quote = quote === x ? null : quote || x;
|
|
90
|
-
}
|
|
91
|
-
splits[0] += x;
|
|
92
|
-
return [quote, depth, splits];
|
|
93
|
-
}, [null, 0, [""]])[2].reverse();
|
|
94
|
-
}
|
|
95
|
-
|
|
96
39
|
// node_modules/@webqit/util/js/isObject.js
|
|
97
40
|
function isObject_default(val) {
|
|
98
41
|
return !Array.isArray(val) && typeof val === "object" && val;
|
|
@@ -488,7 +431,7 @@ var Realtime = class {
|
|
|
488
431
|
} else {
|
|
489
432
|
args[0] = from_default(args[0], false);
|
|
490
433
|
}
|
|
491
|
-
if (args[0].filter((x) => typeof x !== "string" && !(x instanceof DOMSpec) && !(x
|
|
434
|
+
if (args[0].filter((x) => typeof x !== "string" && !(x instanceof DOMSpec) && !isNode(x)).length) {
|
|
492
435
|
throw new Error(`Argument #2 must be either a string or a Node object, or a list of those.`);
|
|
493
436
|
}
|
|
494
437
|
args[0] = args[0].map((s) => s instanceof DOMSpec ? s : new DOMSpec(s));
|
|
@@ -866,10 +809,12 @@ var DOMRealtime = class extends Realtime {
|
|
|
866
809
|
dispatch2.call(window2, registration, record, context);
|
|
867
810
|
}));
|
|
868
811
|
mo.observe(context, { childList: true, subtree: params.subtree && true });
|
|
869
|
-
const disconnectable = {
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
812
|
+
const disconnectable = {
|
|
813
|
+
disconnect() {
|
|
814
|
+
registry.delete(registration);
|
|
815
|
+
mo.disconnect();
|
|
816
|
+
}
|
|
817
|
+
};
|
|
873
818
|
const signalGenerator = params.signalGenerator || params.lifecycleSignals && this.createSignalGenerator();
|
|
874
819
|
const registration = { context, spec, callback, params, signalGenerator, disconnectable };
|
|
875
820
|
const registry = this.registry(interceptionTiming);
|
|
@@ -1072,7 +1017,7 @@ function domInterception(timing, callback) {
|
|
|
1072
1017
|
_apiOriginals[DOMClassName][apiName] = _apiOriginal;
|
|
1073
1018
|
});
|
|
1074
1019
|
function method(...args) {
|
|
1075
|
-
const DOMClassName = Object.keys(_apiOriginals).find((name) => this
|
|
1020
|
+
const DOMClassName = Object.keys(_apiOriginals).find((name) => isNodeInterface(this, name) && apiName in _apiOriginals[name]);
|
|
1076
1021
|
const $apiOriginals = _apiOriginals[DOMClassName];
|
|
1077
1022
|
let exec = () => $apiOriginals[apiName].value.call(this, ...args);
|
|
1078
1023
|
if (webqit.realdom.domInterceptionNoRecurse.get(this) === apiName)
|
|
@@ -1131,17 +1076,17 @@ function domInterception(timing, callback) {
|
|
|
1131
1076
|
});
|
|
1132
1077
|
}
|
|
1133
1078
|
function setter(value) {
|
|
1134
|
-
const DOMClassName = Object.keys(_apiOriginals).find((name) => this
|
|
1079
|
+
const DOMClassName = Object.keys(_apiOriginals).find((name) => isNodeInterface(this, name) && apiName in _apiOriginals[name]);
|
|
1135
1080
|
const $apiOriginals = _apiOriginals[DOMClassName];
|
|
1136
1081
|
let exec = () => $apiOriginals[apiName].set.call(this, value);
|
|
1137
|
-
if (this
|
|
1082
|
+
if (isNodeInterface(this, "HTMLScriptElement") || webqit.realdom.domInterceptionNoRecurse.get(this) === apiName)
|
|
1138
1083
|
return exec();
|
|
1139
1084
|
let exits = [], entrants = [], target = this;
|
|
1140
1085
|
if (["outerHTML", "outerText"].includes(apiName)) {
|
|
1141
1086
|
exits = [this];
|
|
1142
1087
|
target = this.parentNode;
|
|
1143
1088
|
} else {
|
|
1144
|
-
if (this
|
|
1089
|
+
if (isNodeInterface(this, "HTMLTemplateElement")) {
|
|
1145
1090
|
target = this.content;
|
|
1146
1091
|
exits = [...this.content.childNodes];
|
|
1147
1092
|
} else {
|
|
@@ -1157,18 +1102,18 @@ function domInterception(timing, callback) {
|
|
|
1157
1102
|
}
|
|
1158
1103
|
const temp = document.createElement(tempNodeName.includes("-") ? "div" : tempNodeName);
|
|
1159
1104
|
noRecurse(temp, apiName, () => temp[apiName] = value);
|
|
1160
|
-
entrants = this
|
|
1161
|
-
if (this
|
|
1105
|
+
entrants = isNodeInterface(this, "HTMLTemplateElement") ? [...temp.content.childNodes] : [...temp.childNodes];
|
|
1106
|
+
if (isNodeInterface(this, "HTMLTemplateElement") && this.hasAttribute("src") || isShadowRoot(this)) {
|
|
1162
1107
|
const getScripts = (nodes) => nodes.reduce((scripts, el) => {
|
|
1163
|
-
if (el
|
|
1108
|
+
if (isNodeInterface(el, "HTMLScriptElement"))
|
|
1164
1109
|
return scripts.concat(el);
|
|
1165
|
-
if (el
|
|
1110
|
+
if (isNodeInterface(el, "HTMLTemplateElement"))
|
|
1166
1111
|
return scripts.concat(getScripts([el.content]));
|
|
1167
1112
|
scripts = scripts.concat(getScripts([...el.querySelectorAll?.("template") || []].map((t) => t.content)));
|
|
1168
1113
|
return scripts.concat(...el.querySelectorAll?.("script") || []);
|
|
1169
1114
|
}, []);
|
|
1170
1115
|
for (const script of getScripts(entrants)) {
|
|
1171
|
-
if (this
|
|
1116
|
+
if (isShadowRoot(this)) {
|
|
1172
1117
|
script.setAttribute("data-handling", "manual");
|
|
1173
1118
|
continue;
|
|
1174
1119
|
}
|
|
@@ -1183,7 +1128,7 @@ function domInterception(timing, callback) {
|
|
|
1183
1128
|
noRecurse(value, "append", () => value.append(...entrants));
|
|
1184
1129
|
exec = () => noRecurse(this, "replaceWith", () => Element.prototype.replaceWith.call(this, value));
|
|
1185
1130
|
} else {
|
|
1186
|
-
if (this
|
|
1131
|
+
if (isNodeInterface(this, "HTMLTemplateElement")) {
|
|
1187
1132
|
exec = () => noRecurse(this.content, "replaceChildren", () => this.content.replaceChildren(...entrants));
|
|
1188
1133
|
} else {
|
|
1189
1134
|
exec = () => noRecurse(this, "replaceChildren", () => Element.prototype.replaceChildren.call(this, ...entrants));
|
|
@@ -1300,17 +1245,111 @@ function meta(name) {
|
|
|
1300
1245
|
if (_el = window2.document.querySelector(`meta[name="${name}"]`)) {
|
|
1301
1246
|
_content = (_el.content || "").split(";").filter((v) => v).reduce((_metaVars, directive) => {
|
|
1302
1247
|
const directiveSplit = directive.split("=").map((d) => d.trim());
|
|
1303
|
-
set_default(
|
|
1248
|
+
set_default(
|
|
1249
|
+
_metaVars,
|
|
1250
|
+
directiveSplit[0].split("."),
|
|
1251
|
+
directiveSplit[1] === "true" ? true : directiveSplit[1] === "false" ? false : isNumeric_default(directiveSplit[1]) ? parseInt(directiveSplit[1]) : directiveSplit[1]
|
|
1252
|
+
);
|
|
1304
1253
|
return _metaVars;
|
|
1305
1254
|
}, {});
|
|
1306
1255
|
}
|
|
1307
|
-
return {
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1256
|
+
return {
|
|
1257
|
+
get name() {
|
|
1258
|
+
return name;
|
|
1259
|
+
},
|
|
1260
|
+
get content() {
|
|
1261
|
+
return _el.content;
|
|
1262
|
+
},
|
|
1263
|
+
json() {
|
|
1264
|
+
return JSON.parse(JSON.stringify(_content));
|
|
1265
|
+
}
|
|
1266
|
+
};
|
|
1267
|
+
}
|
|
1268
|
+
function isNode(value) {
|
|
1269
|
+
return value !== null && typeof value === "object" && typeof value.nodeType === "number" && typeof value.nodeName === "string";
|
|
1270
|
+
}
|
|
1271
|
+
function isElement(value) {
|
|
1272
|
+
return value?.nodeType === 1;
|
|
1273
|
+
}
|
|
1274
|
+
function isShadowRoot(value) {
|
|
1275
|
+
return value?.nodeType === 11 && Object.prototype.toString.call(value) === "[object ShadowRoot]";
|
|
1276
|
+
}
|
|
1277
|
+
function isCharacterData(value) {
|
|
1278
|
+
const toStringValue = Object.prototype.toString.call(value);
|
|
1279
|
+
return toStringValue === "[object Text]" || toStringValue === "[object Comment]" || toStringValue === "[object CDATASection]" || toStringValue === "[object ProcessingInstruction]";
|
|
1280
|
+
}
|
|
1281
|
+
function isNodeInterface(value, interfaceName) {
|
|
1282
|
+
if (!isNode(value))
|
|
1283
|
+
return false;
|
|
1284
|
+
if (interfaceName === "ShadowRoot") {
|
|
1285
|
+
return isShadowRoot(value);
|
|
1286
|
+
HTMLUnknownElement;
|
|
1287
|
+
}
|
|
1288
|
+
const toStringValue = Object.prototype.toString.call(value);
|
|
1289
|
+
if (toStringValue === `[object ${interfaceName}]`)
|
|
1290
|
+
return true;
|
|
1291
|
+
if (interfaceName === "DocumentFragment" && isShadowRoot(value))
|
|
1292
|
+
return true;
|
|
1293
|
+
if (interfaceName === "CharacterData" && isCharacterData(value))
|
|
1294
|
+
return true;
|
|
1295
|
+
return (interfaceName === "Node" || interfaceName === "Element" || interfaceName === "HTMLElement") && isElement(value) || interfaceName === "Node" && isNode(value);
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
// node_modules/@webqit/realdom/src/realtime/Util.js
|
|
1299
|
+
function isXpath(expr) {
|
|
1300
|
+
return (expr = expr.trim()) && expr.startsWith("(") && expr.endsWith(")");
|
|
1301
|
+
}
|
|
1302
|
+
function xpathQuery(window2, context, expr, subtree = true) {
|
|
1303
|
+
expr = (Array.isArray(expr) ? expr : [expr]).map((x) => (x + "").replace("(", subtree ? "(.//" : "(./")).join("|");
|
|
1304
|
+
let nodes = [], node;
|
|
1305
|
+
try {
|
|
1306
|
+
const result = window2.document.evaluate(expr, context, null, window2.XPathResult.ANY_TYPE);
|
|
1307
|
+
while (node = result.iterateNext())
|
|
1308
|
+
nodes.push(node);
|
|
1309
|
+
} catch (e) {
|
|
1310
|
+
}
|
|
1311
|
+
return nodes;
|
|
1312
|
+
}
|
|
1313
|
+
function xpathMatch(window2, node, expr) {
|
|
1314
|
+
expr = (Array.isArray(expr) ? expr : [expr]).map((x) => (x + "").replace("(", "(self::")).join("|");
|
|
1315
|
+
try {
|
|
1316
|
+
return window2.document.evaluate(`${expr}`, node, null, window2.XPathResult.BOOLEAN_TYPE).booleanValue;
|
|
1317
|
+
} catch (e) {
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
function containsNode(window2, a, b, crossRoots = false, testCache = null) {
|
|
1321
|
+
const prevTest = testCache?.get(a)?.get(b);
|
|
1322
|
+
if (typeof prevTest !== "undefined")
|
|
1323
|
+
return prevTest;
|
|
1324
|
+
const response = (val) => {
|
|
1325
|
+
if (!testCache?.has(a))
|
|
1326
|
+
testCache?.set(a, /* @__PURE__ */ new WeakMap());
|
|
1327
|
+
testCache?.get(a)?.set(b, val);
|
|
1328
|
+
return val;
|
|
1329
|
+
};
|
|
1330
|
+
const rootNodeA = a.getRootNode();
|
|
1331
|
+
const rootNodeB = b.getRootNode();
|
|
1332
|
+
if (rootNodeA === rootNodeB)
|
|
1333
|
+
return response(a.contains(b));
|
|
1334
|
+
if (crossRoots && isShadowRoot(rootNodeB))
|
|
1335
|
+
return response(containsNode(window2, a, rootNodeB.host, crossRoots, testCache));
|
|
1336
|
+
return response(false);
|
|
1337
|
+
}
|
|
1338
|
+
function splitOuter(str, delim = "|") {
|
|
1339
|
+
return [...str].reduce(([quote, depth, splits, skip], x) => {
|
|
1340
|
+
if (!quote && depth === 0 && (Array.isArray(delim) ? delim : [delim]).includes(x)) {
|
|
1341
|
+
return [quote, depth, [""].concat(splits)];
|
|
1342
|
+
}
|
|
1343
|
+
if (!quote && ["(", "[", "{"].includes(x) && !splits[0].endsWith("\\"))
|
|
1344
|
+
depth++;
|
|
1345
|
+
if (!quote && [")", "]", "}"].includes(x) && !splits[0].endsWith("\\"))
|
|
1346
|
+
depth--;
|
|
1347
|
+
if (['"', "'", "`"].includes(x) && !splits[0].endsWith("\\")) {
|
|
1348
|
+
quote = quote === x ? null : quote || x;
|
|
1349
|
+
}
|
|
1350
|
+
splits[0] += x;
|
|
1351
|
+
return [quote, depth, splits];
|
|
1352
|
+
}, [null, 0, [""]])[2].reverse();
|
|
1314
1353
|
}
|
|
1315
1354
|
|
|
1316
1355
|
// node_modules/@webqit/util/str/toTitle.js
|
|
@@ -1608,7 +1647,7 @@ function compileInlineBindings(config, str) {
|
|
|
1608
1647
|
$existing__.delete( $key___ );
|
|
1609
1648
|
$exec__($itemNode__, '${config.BINDINGS_API.api.bind}', $itemBinding__ );
|
|
1610
1649
|
} else {
|
|
1611
|
-
$itemNode__ = ( Array.isArray( $import__.value ) ? $import__.value[ 0 ] : ( $import__.value
|
|
1650
|
+
$itemNode__ = ( Array.isArray( $import__.value ) ? $import__.value[ 0 ] : ( $import__.value?.nodeName === 'TEMPLATE' ? $import__.value.content.firstElementChild : $import__.value ) ).cloneNode( true );
|
|
1612
1651
|
$itemNode__.setAttribute( "${config.attr.itemIndex}", $key___ );
|
|
1613
1652
|
$exec__($itemNode__, '${config.BINDINGS_API.api.bind}', $itemBinding__ );
|
|
1614
1653
|
$exec__(this, 'appendChild', $itemNode__ );
|