@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/scoped-js.js
CHANGED
|
@@ -1,41 +1,3 @@
|
|
|
1
|
-
// node_modules/@webqit/use-live/src/params.js
|
|
2
|
-
function resolveParams(...extensions) {
|
|
3
|
-
let extension, params = { runtimeParams, transformerParams, parserParams };
|
|
4
|
-
while (extension = extensions.shift()) {
|
|
5
|
-
const {
|
|
6
|
-
runtimeParams: _runtimeParams = {},
|
|
7
|
-
transformerParams: { globalsNoObserve: _globalsNoObserve = [], globalsOnlyPathsExcept: _globalsOnlyPathsExcept = [], ..._transformerParams } = {},
|
|
8
|
-
parserParams: _parserParams = {}
|
|
9
|
-
} = extension;
|
|
10
|
-
params = {
|
|
11
|
-
runtimeParams: { ...params.runtimeParams, ..._runtimeParams },
|
|
12
|
-
transformerParams: { ...params.transformerParams, globalsNoObserve: [...params.transformerParams.globalsNoObserve, ..._globalsNoObserve], globalsOnlyPathsExcept: [...params.transformerParams.globalsOnlyPathsExcept, ..._globalsOnlyPathsExcept], ..._transformerParams },
|
|
13
|
-
parserParams: { ...params.parserParams, ..._parserParams }
|
|
14
|
-
};
|
|
15
|
-
if (extensions.devMode) {
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return params;
|
|
19
|
-
}
|
|
20
|
-
var parserParams = {
|
|
21
|
-
ecmaVersion: "latest",
|
|
22
|
-
allowReturnOutsideFunction: true,
|
|
23
|
-
allowAwaitOutsideFunction: false,
|
|
24
|
-
allowSuperOutsideMethod: false,
|
|
25
|
-
preserveParens: false,
|
|
26
|
-
locations: true
|
|
27
|
-
};
|
|
28
|
-
var transformerParams = {
|
|
29
|
-
globalsNoObserve: ["arguments", "debugger"],
|
|
30
|
-
globalsOnlyPathsExcept: [],
|
|
31
|
-
originalSource: true,
|
|
32
|
-
locations: true,
|
|
33
|
-
compact: 2
|
|
34
|
-
};
|
|
35
|
-
var runtimeParams = {
|
|
36
|
-
apiVersion: 3
|
|
37
|
-
};
|
|
38
|
-
|
|
39
1
|
// node_modules/@webqit/util/js/isObject.js
|
|
40
2
|
function isObject_default(val) {
|
|
41
3
|
return !Array.isArray(val) && typeof val === "object" && val;
|
|
@@ -432,7 +394,7 @@ function containsNode(window2, a, b, crossRoots = false, testCache = null) {
|
|
|
432
394
|
const rootNodeB = b.getRootNode();
|
|
433
395
|
if (rootNodeA === rootNodeB)
|
|
434
396
|
return response(a.contains(b));
|
|
435
|
-
if (crossRoots && rootNodeB
|
|
397
|
+
if (crossRoots && isShadowRoot(rootNodeB))
|
|
436
398
|
return response(containsNode(window2, a, rootNodeB.host, crossRoots, testCache));
|
|
437
399
|
return response(false);
|
|
438
400
|
}
|
|
@@ -488,7 +450,7 @@ var Realtime = class {
|
|
|
488
450
|
} else {
|
|
489
451
|
args[0] = from_default(args[0], false);
|
|
490
452
|
}
|
|
491
|
-
if (args[0].filter((x) => typeof x !== "string" && !(x instanceof DOMSpec) && !(x
|
|
453
|
+
if (args[0].filter((x) => typeof x !== "string" && !(x instanceof DOMSpec) && !isNode(x)).length) {
|
|
492
454
|
throw new Error(`Argument #2 must be either a string or a Node object, or a list of those.`);
|
|
493
455
|
}
|
|
494
456
|
args[0] = args[0].map((s) => s instanceof DOMSpec ? s : new DOMSpec(s));
|
|
@@ -866,10 +828,12 @@ var DOMRealtime = class extends Realtime {
|
|
|
866
828
|
dispatch2.call(window2, registration, record, context);
|
|
867
829
|
}));
|
|
868
830
|
mo.observe(context, { childList: true, subtree: params.subtree && true });
|
|
869
|
-
const disconnectable = {
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
831
|
+
const disconnectable = {
|
|
832
|
+
disconnect() {
|
|
833
|
+
registry.delete(registration);
|
|
834
|
+
mo.disconnect();
|
|
835
|
+
}
|
|
836
|
+
};
|
|
873
837
|
const signalGenerator = params.signalGenerator || params.lifecycleSignals && this.createSignalGenerator();
|
|
874
838
|
const registration = { context, spec, callback, params, signalGenerator, disconnectable };
|
|
875
839
|
const registry = this.registry(interceptionTiming);
|
|
@@ -1072,7 +1036,7 @@ function domInterception(timing, callback) {
|
|
|
1072
1036
|
_apiOriginals[DOMClassName][apiName] = _apiOriginal;
|
|
1073
1037
|
});
|
|
1074
1038
|
function method(...args) {
|
|
1075
|
-
const DOMClassName = Object.keys(_apiOriginals).find((name) => this
|
|
1039
|
+
const DOMClassName = Object.keys(_apiOriginals).find((name) => isNodeInterface(this, name) && apiName in _apiOriginals[name]);
|
|
1076
1040
|
const $apiOriginals = _apiOriginals[DOMClassName];
|
|
1077
1041
|
let exec = () => $apiOriginals[apiName].value.call(this, ...args);
|
|
1078
1042
|
if (webqit.realdom.domInterceptionNoRecurse.get(this) === apiName)
|
|
@@ -1131,17 +1095,17 @@ function domInterception(timing, callback) {
|
|
|
1131
1095
|
});
|
|
1132
1096
|
}
|
|
1133
1097
|
function setter(value) {
|
|
1134
|
-
const DOMClassName = Object.keys(_apiOriginals).find((name) => this
|
|
1098
|
+
const DOMClassName = Object.keys(_apiOriginals).find((name) => isNodeInterface(this, name) && apiName in _apiOriginals[name]);
|
|
1135
1099
|
const $apiOriginals = _apiOriginals[DOMClassName];
|
|
1136
1100
|
let exec = () => $apiOriginals[apiName].set.call(this, value);
|
|
1137
|
-
if (this
|
|
1101
|
+
if (isNodeInterface(this, "HTMLScriptElement") || webqit.realdom.domInterceptionNoRecurse.get(this) === apiName)
|
|
1138
1102
|
return exec();
|
|
1139
1103
|
let exits = [], entrants = [], target = this;
|
|
1140
1104
|
if (["outerHTML", "outerText"].includes(apiName)) {
|
|
1141
1105
|
exits = [this];
|
|
1142
1106
|
target = this.parentNode;
|
|
1143
1107
|
} else {
|
|
1144
|
-
if (this
|
|
1108
|
+
if (isNodeInterface(this, "HTMLTemplateElement")) {
|
|
1145
1109
|
target = this.content;
|
|
1146
1110
|
exits = [...this.content.childNodes];
|
|
1147
1111
|
} else {
|
|
@@ -1157,18 +1121,18 @@ function domInterception(timing, callback) {
|
|
|
1157
1121
|
}
|
|
1158
1122
|
const temp = document.createElement(tempNodeName.includes("-") ? "div" : tempNodeName);
|
|
1159
1123
|
noRecurse(temp, apiName, () => temp[apiName] = value);
|
|
1160
|
-
entrants = this
|
|
1161
|
-
if (this
|
|
1124
|
+
entrants = isNodeInterface(this, "HTMLTemplateElement") ? [...temp.content.childNodes] : [...temp.childNodes];
|
|
1125
|
+
if (isNodeInterface(this, "HTMLTemplateElement") && this.hasAttribute("src") || isShadowRoot(this)) {
|
|
1162
1126
|
const getScripts = (nodes) => nodes.reduce((scripts, el) => {
|
|
1163
|
-
if (el
|
|
1127
|
+
if (isNodeInterface(el, "HTMLScriptElement"))
|
|
1164
1128
|
return scripts.concat(el);
|
|
1165
|
-
if (el
|
|
1129
|
+
if (isNodeInterface(el, "HTMLTemplateElement"))
|
|
1166
1130
|
return scripts.concat(getScripts([el.content]));
|
|
1167
1131
|
scripts = scripts.concat(getScripts([...el.querySelectorAll?.("template") || []].map((t) => t.content)));
|
|
1168
1132
|
return scripts.concat(...el.querySelectorAll?.("script") || []);
|
|
1169
1133
|
}, []);
|
|
1170
1134
|
for (const script of getScripts(entrants)) {
|
|
1171
|
-
if (this
|
|
1135
|
+
if (isShadowRoot(this)) {
|
|
1172
1136
|
script.setAttribute("data-handling", "manual");
|
|
1173
1137
|
continue;
|
|
1174
1138
|
}
|
|
@@ -1183,7 +1147,7 @@ function domInterception(timing, callback) {
|
|
|
1183
1147
|
noRecurse(value, "append", () => value.append(...entrants));
|
|
1184
1148
|
exec = () => noRecurse(this, "replaceWith", () => Element.prototype.replaceWith.call(this, value));
|
|
1185
1149
|
} else {
|
|
1186
|
-
if (this
|
|
1150
|
+
if (isNodeInterface(this, "HTMLTemplateElement")) {
|
|
1187
1151
|
exec = () => noRecurse(this.content, "replaceChildren", () => this.content.replaceChildren(...entrants));
|
|
1188
1152
|
} else {
|
|
1189
1153
|
exec = () => noRecurse(this, "replaceChildren", () => Element.prototype.replaceChildren.call(this, ...entrants));
|
|
@@ -1300,18 +1264,93 @@ function meta(name) {
|
|
|
1300
1264
|
if (_el = window2.document.querySelector(`meta[name="${name}"]`)) {
|
|
1301
1265
|
_content = (_el.content || "").split(";").filter((v) => v).reduce((_metaVars, directive) => {
|
|
1302
1266
|
const directiveSplit = directive.split("=").map((d) => d.trim());
|
|
1303
|
-
set_default(
|
|
1267
|
+
set_default(
|
|
1268
|
+
_metaVars,
|
|
1269
|
+
directiveSplit[0].split("."),
|
|
1270
|
+
directiveSplit[1] === "true" ? true : directiveSplit[1] === "false" ? false : isNumeric_default(directiveSplit[1]) ? parseInt(directiveSplit[1]) : directiveSplit[1]
|
|
1271
|
+
);
|
|
1304
1272
|
return _metaVars;
|
|
1305
1273
|
}, {});
|
|
1306
1274
|
}
|
|
1307
|
-
return {
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1275
|
+
return {
|
|
1276
|
+
get name() {
|
|
1277
|
+
return name;
|
|
1278
|
+
},
|
|
1279
|
+
get content() {
|
|
1280
|
+
return _el.content;
|
|
1281
|
+
},
|
|
1282
|
+
json() {
|
|
1283
|
+
return JSON.parse(JSON.stringify(_content));
|
|
1284
|
+
}
|
|
1285
|
+
};
|
|
1286
|
+
}
|
|
1287
|
+
function isNode(value) {
|
|
1288
|
+
return value !== null && typeof value === "object" && typeof value.nodeType === "number" && typeof value.nodeName === "string";
|
|
1314
1289
|
}
|
|
1290
|
+
function isElement(value) {
|
|
1291
|
+
return value?.nodeType === 1;
|
|
1292
|
+
}
|
|
1293
|
+
function isShadowRoot(value) {
|
|
1294
|
+
return value?.nodeType === 11 && Object.prototype.toString.call(value) === "[object ShadowRoot]";
|
|
1295
|
+
}
|
|
1296
|
+
function isCharacterData(value) {
|
|
1297
|
+
const toStringValue = Object.prototype.toString.call(value);
|
|
1298
|
+
return toStringValue === "[object Text]" || toStringValue === "[object Comment]" || toStringValue === "[object CDATASection]" || toStringValue === "[object ProcessingInstruction]";
|
|
1299
|
+
}
|
|
1300
|
+
function isNodeInterface(value, interfaceName) {
|
|
1301
|
+
if (!isNode(value))
|
|
1302
|
+
return false;
|
|
1303
|
+
if (interfaceName === "ShadowRoot") {
|
|
1304
|
+
return isShadowRoot(value);
|
|
1305
|
+
HTMLUnknownElement;
|
|
1306
|
+
}
|
|
1307
|
+
const toStringValue = Object.prototype.toString.call(value);
|
|
1308
|
+
if (toStringValue === `[object ${interfaceName}]`)
|
|
1309
|
+
return true;
|
|
1310
|
+
if (interfaceName === "DocumentFragment" && isShadowRoot(value))
|
|
1311
|
+
return true;
|
|
1312
|
+
if (interfaceName === "CharacterData" && isCharacterData(value))
|
|
1313
|
+
return true;
|
|
1314
|
+
return (interfaceName === "Node" || interfaceName === "Element" || interfaceName === "HTMLElement") && isElement(value) || interfaceName === "Node" && isNode(value);
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
// node_modules/@webqit/use-live/src/params.js
|
|
1318
|
+
function resolveParams(...extensions) {
|
|
1319
|
+
let extension, params = { runtimeParams, transformerParams, parserParams };
|
|
1320
|
+
while (extension = extensions.shift()) {
|
|
1321
|
+
const {
|
|
1322
|
+
runtimeParams: _runtimeParams = {},
|
|
1323
|
+
transformerParams: { globalsNoObserve: _globalsNoObserve = [], globalsOnlyPathsExcept: _globalsOnlyPathsExcept = [], ..._transformerParams } = {},
|
|
1324
|
+
parserParams: _parserParams = {}
|
|
1325
|
+
} = extension;
|
|
1326
|
+
params = {
|
|
1327
|
+
runtimeParams: { ...params.runtimeParams, ..._runtimeParams },
|
|
1328
|
+
transformerParams: { ...params.transformerParams, globalsNoObserve: [...params.transformerParams.globalsNoObserve, ..._globalsNoObserve], globalsOnlyPathsExcept: [...params.transformerParams.globalsOnlyPathsExcept, ..._globalsOnlyPathsExcept], ..._transformerParams },
|
|
1329
|
+
parserParams: { ...params.parserParams, ..._parserParams }
|
|
1330
|
+
};
|
|
1331
|
+
if (extensions.devMode) {
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
return params;
|
|
1335
|
+
}
|
|
1336
|
+
var parserParams = {
|
|
1337
|
+
ecmaVersion: "latest",
|
|
1338
|
+
allowReturnOutsideFunction: true,
|
|
1339
|
+
allowAwaitOutsideFunction: false,
|
|
1340
|
+
allowSuperOutsideMethod: false,
|
|
1341
|
+
preserveParens: false,
|
|
1342
|
+
locations: true
|
|
1343
|
+
};
|
|
1344
|
+
var transformerParams = {
|
|
1345
|
+
globalsNoObserve: ["arguments", "debugger"],
|
|
1346
|
+
globalsOnlyPathsExcept: [],
|
|
1347
|
+
originalSource: true,
|
|
1348
|
+
locations: true,
|
|
1349
|
+
compact: 2
|
|
1350
|
+
};
|
|
1351
|
+
var runtimeParams = {
|
|
1352
|
+
apiVersion: 3
|
|
1353
|
+
};
|
|
1315
1354
|
|
|
1316
1355
|
// node_modules/@webqit/util/str/toTitle.js
|
|
1317
1356
|
function toTitle_default(str, strict) {
|
|
@@ -1396,12 +1435,14 @@ function exposeAPIs(config) {
|
|
|
1396
1435
|
throw new Error(`The "Element" class already has a "${config.api.scripts}" property!`);
|
|
1397
1436
|
}
|
|
1398
1437
|
[window2.ShadowRoot.prototype, window2.Element.prototype].forEach((proto) => {
|
|
1399
|
-
Object.defineProperty(proto, config.api.scripts, {
|
|
1400
|
-
|
|
1401
|
-
scriptsMap.
|
|
1438
|
+
Object.defineProperty(proto, config.api.scripts, {
|
|
1439
|
+
get: function() {
|
|
1440
|
+
if (!scriptsMap.has(this)) {
|
|
1441
|
+
scriptsMap.set(this, []);
|
|
1442
|
+
}
|
|
1443
|
+
return scriptsMap.get(this);
|
|
1402
1444
|
}
|
|
1403
|
-
|
|
1404
|
-
} });
|
|
1445
|
+
});
|
|
1405
1446
|
});
|
|
1406
1447
|
Object.defineProperties(window2.HTMLScriptElement.prototype, {
|
|
1407
1448
|
scoped: {
|
|
@@ -1451,7 +1492,7 @@ async function execute(config, execHash) {
|
|
|
1451
1492
|
if (script.live) {
|
|
1452
1493
|
liveProgramHandle.abort();
|
|
1453
1494
|
}
|
|
1454
|
-
if (thisContext
|
|
1495
|
+
if (isElement(thisContext)) {
|
|
1455
1496
|
thisContext[config.api.scripts]?.splice(thisContext[config.api.scripts].indexOf(script, 1));
|
|
1456
1497
|
}
|
|
1457
1498
|
}, { id: "scoped-js:script-exits", subtree: "cross-roots", timing: "sync", generation: "exits" });
|