@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/html-imports.js
CHANGED
|
@@ -419,7 +419,7 @@ function containsNode(window2, a, b, crossRoots = false, testCache = null) {
|
|
|
419
419
|
const rootNodeB = b.getRootNode();
|
|
420
420
|
if (rootNodeA === rootNodeB)
|
|
421
421
|
return response(a.contains(b));
|
|
422
|
-
if (crossRoots && rootNodeB
|
|
422
|
+
if (crossRoots && isShadowRoot(rootNodeB))
|
|
423
423
|
return response(containsNode(window2, a, rootNodeB.host, crossRoots, testCache));
|
|
424
424
|
return response(false);
|
|
425
425
|
}
|
|
@@ -475,7 +475,7 @@ var Realtime = class {
|
|
|
475
475
|
} else {
|
|
476
476
|
args[0] = from_default(args[0], false);
|
|
477
477
|
}
|
|
478
|
-
if (args[0].filter((x) => typeof x !== "string" && !(x instanceof DOMSpec) && !(x
|
|
478
|
+
if (args[0].filter((x) => typeof x !== "string" && !(x instanceof DOMSpec) && !isNode(x)).length) {
|
|
479
479
|
throw new Error(`Argument #2 must be either a string or a Node object, or a list of those.`);
|
|
480
480
|
}
|
|
481
481
|
args[0] = args[0].map((s) => s instanceof DOMSpec ? s : new DOMSpec(s));
|
|
@@ -853,10 +853,12 @@ var DOMRealtime = class extends Realtime {
|
|
|
853
853
|
dispatch2.call(window2, registration, record, context);
|
|
854
854
|
}));
|
|
855
855
|
mo.observe(context, { childList: true, subtree: params.subtree && true });
|
|
856
|
-
const disconnectable = {
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
856
|
+
const disconnectable = {
|
|
857
|
+
disconnect() {
|
|
858
|
+
registry.delete(registration);
|
|
859
|
+
mo.disconnect();
|
|
860
|
+
}
|
|
861
|
+
};
|
|
860
862
|
const signalGenerator = params.signalGenerator || params.lifecycleSignals && this.createSignalGenerator();
|
|
861
863
|
const registration = { context, spec, callback, params, signalGenerator, disconnectable };
|
|
862
864
|
const registry = this.registry(interceptionTiming);
|
|
@@ -1059,7 +1061,7 @@ function domInterception(timing, callback) {
|
|
|
1059
1061
|
_apiOriginals[DOMClassName][apiName] = _apiOriginal;
|
|
1060
1062
|
});
|
|
1061
1063
|
function method(...args) {
|
|
1062
|
-
const DOMClassName = Object.keys(_apiOriginals).find((name) => this
|
|
1064
|
+
const DOMClassName = Object.keys(_apiOriginals).find((name) => isNodeInterface(this, name) && apiName in _apiOriginals[name]);
|
|
1063
1065
|
const $apiOriginals = _apiOriginals[DOMClassName];
|
|
1064
1066
|
let exec = () => $apiOriginals[apiName].value.call(this, ...args);
|
|
1065
1067
|
if (webqit.realdom.domInterceptionNoRecurse.get(this) === apiName)
|
|
@@ -1118,17 +1120,17 @@ function domInterception(timing, callback) {
|
|
|
1118
1120
|
});
|
|
1119
1121
|
}
|
|
1120
1122
|
function setter(value) {
|
|
1121
|
-
const DOMClassName = Object.keys(_apiOriginals).find((name) => this
|
|
1123
|
+
const DOMClassName = Object.keys(_apiOriginals).find((name) => isNodeInterface(this, name) && apiName in _apiOriginals[name]);
|
|
1122
1124
|
const $apiOriginals = _apiOriginals[DOMClassName];
|
|
1123
1125
|
let exec = () => $apiOriginals[apiName].set.call(this, value);
|
|
1124
|
-
if (this
|
|
1126
|
+
if (isNodeInterface(this, "HTMLScriptElement") || webqit.realdom.domInterceptionNoRecurse.get(this) === apiName)
|
|
1125
1127
|
return exec();
|
|
1126
1128
|
let exits = [], entrants = [], target = this;
|
|
1127
1129
|
if (["outerHTML", "outerText"].includes(apiName)) {
|
|
1128
1130
|
exits = [this];
|
|
1129
1131
|
target = this.parentNode;
|
|
1130
1132
|
} else {
|
|
1131
|
-
if (this
|
|
1133
|
+
if (isNodeInterface(this, "HTMLTemplateElement")) {
|
|
1132
1134
|
target = this.content;
|
|
1133
1135
|
exits = [...this.content.childNodes];
|
|
1134
1136
|
} else {
|
|
@@ -1144,18 +1146,18 @@ function domInterception(timing, callback) {
|
|
|
1144
1146
|
}
|
|
1145
1147
|
const temp = document.createElement(tempNodeName.includes("-") ? "div" : tempNodeName);
|
|
1146
1148
|
noRecurse(temp, apiName, () => temp[apiName] = value);
|
|
1147
|
-
entrants = this
|
|
1148
|
-
if (this
|
|
1149
|
+
entrants = isNodeInterface(this, "HTMLTemplateElement") ? [...temp.content.childNodes] : [...temp.childNodes];
|
|
1150
|
+
if (isNodeInterface(this, "HTMLTemplateElement") && this.hasAttribute("src") || isShadowRoot(this)) {
|
|
1149
1151
|
const getScripts = (nodes) => nodes.reduce((scripts, el) => {
|
|
1150
|
-
if (el
|
|
1152
|
+
if (isNodeInterface(el, "HTMLScriptElement"))
|
|
1151
1153
|
return scripts.concat(el);
|
|
1152
|
-
if (el
|
|
1154
|
+
if (isNodeInterface(el, "HTMLTemplateElement"))
|
|
1153
1155
|
return scripts.concat(getScripts([el.content]));
|
|
1154
1156
|
scripts = scripts.concat(getScripts([...el.querySelectorAll?.("template") || []].map((t) => t.content)));
|
|
1155
1157
|
return scripts.concat(...el.querySelectorAll?.("script") || []);
|
|
1156
1158
|
}, []);
|
|
1157
1159
|
for (const script of getScripts(entrants)) {
|
|
1158
|
-
if (this
|
|
1160
|
+
if (isShadowRoot(this)) {
|
|
1159
1161
|
script.setAttribute("data-handling", "manual");
|
|
1160
1162
|
continue;
|
|
1161
1163
|
}
|
|
@@ -1170,7 +1172,7 @@ function domInterception(timing, callback) {
|
|
|
1170
1172
|
noRecurse(value, "append", () => value.append(...entrants));
|
|
1171
1173
|
exec = () => noRecurse(this, "replaceWith", () => Element.prototype.replaceWith.call(this, value));
|
|
1172
1174
|
} else {
|
|
1173
|
-
if (this
|
|
1175
|
+
if (isNodeInterface(this, "HTMLTemplateElement")) {
|
|
1174
1176
|
exec = () => noRecurse(this.content, "replaceChildren", () => this.content.replaceChildren(...entrants));
|
|
1175
1177
|
} else {
|
|
1176
1178
|
exec = () => noRecurse(this, "replaceChildren", () => Element.prototype.replaceChildren.call(this, ...entrants));
|
|
@@ -1287,17 +1289,57 @@ function meta(name) {
|
|
|
1287
1289
|
if (_el = window2.document.querySelector(`meta[name="${name}"]`)) {
|
|
1288
1290
|
_content = (_el.content || "").split(";").filter((v) => v).reduce((_metaVars, directive) => {
|
|
1289
1291
|
const directiveSplit = directive.split("=").map((d) => d.trim());
|
|
1290
|
-
set_default(
|
|
1292
|
+
set_default(
|
|
1293
|
+
_metaVars,
|
|
1294
|
+
directiveSplit[0].split("."),
|
|
1295
|
+
directiveSplit[1] === "true" ? true : directiveSplit[1] === "false" ? false : isNumeric_default(directiveSplit[1]) ? parseInt(directiveSplit[1]) : directiveSplit[1]
|
|
1296
|
+
);
|
|
1291
1297
|
return _metaVars;
|
|
1292
1298
|
}, {});
|
|
1293
1299
|
}
|
|
1294
|
-
return {
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1300
|
+
return {
|
|
1301
|
+
get name() {
|
|
1302
|
+
return name;
|
|
1303
|
+
},
|
|
1304
|
+
get content() {
|
|
1305
|
+
return _el.content;
|
|
1306
|
+
},
|
|
1307
|
+
json() {
|
|
1308
|
+
return JSON.parse(JSON.stringify(_content));
|
|
1309
|
+
}
|
|
1310
|
+
};
|
|
1311
|
+
}
|
|
1312
|
+
function isNode(value) {
|
|
1313
|
+
return value !== null && typeof value === "object" && typeof value.nodeType === "number" && typeof value.nodeName === "string";
|
|
1314
|
+
}
|
|
1315
|
+
function isElement(value) {
|
|
1316
|
+
return value?.nodeType === 1;
|
|
1317
|
+
}
|
|
1318
|
+
function isShadowRoot(value) {
|
|
1319
|
+
return value?.nodeType === 11 && Object.prototype.toString.call(value) === "[object ShadowRoot]";
|
|
1320
|
+
}
|
|
1321
|
+
function isDocument(value) {
|
|
1322
|
+
return value?.nodeType === 9 && Object.prototype.toString.call(value) === "[object Document]";
|
|
1323
|
+
}
|
|
1324
|
+
function isCharacterData(value) {
|
|
1325
|
+
const toStringValue = Object.prototype.toString.call(value);
|
|
1326
|
+
return toStringValue === "[object Text]" || toStringValue === "[object Comment]" || toStringValue === "[object CDATASection]" || toStringValue === "[object ProcessingInstruction]";
|
|
1327
|
+
}
|
|
1328
|
+
function isNodeInterface(value, interfaceName) {
|
|
1329
|
+
if (!isNode(value))
|
|
1330
|
+
return false;
|
|
1331
|
+
if (interfaceName === "ShadowRoot") {
|
|
1332
|
+
return isShadowRoot(value);
|
|
1333
|
+
HTMLUnknownElement;
|
|
1334
|
+
}
|
|
1335
|
+
const toStringValue = Object.prototype.toString.call(value);
|
|
1336
|
+
if (toStringValue === `[object ${interfaceName}]`)
|
|
1337
|
+
return true;
|
|
1338
|
+
if (interfaceName === "DocumentFragment" && isShadowRoot(value))
|
|
1339
|
+
return true;
|
|
1340
|
+
if (interfaceName === "CharacterData" && isCharacterData(value))
|
|
1341
|
+
return true;
|
|
1342
|
+
return (interfaceName === "Node" || interfaceName === "Element" || interfaceName === "HTMLElement") && isElement(value) || interfaceName === "Node" && isNode(value);
|
|
1301
1343
|
}
|
|
1302
1344
|
|
|
1303
1345
|
// node_modules/@webqit/util/str/toTitle.js
|
|
@@ -1641,7 +1683,7 @@ var _DOMContext = class {
|
|
|
1641
1683
|
return configs;
|
|
1642
1684
|
}
|
|
1643
1685
|
get name() {
|
|
1644
|
-
return
|
|
1686
|
+
return isDocument(this.host) || isShadowRoot(this.host) ? Infinity : this.host.getAttribute(this.configs.CONTEXT_API.attr.contextname);
|
|
1645
1687
|
}
|
|
1646
1688
|
subscribed(event) {
|
|
1647
1689
|
}
|
|
@@ -1842,7 +1884,7 @@ function HTMLImportElement_default() {
|
|
|
1842
1884
|
};
|
|
1843
1885
|
class HTMLImportElement extends BaseElement {
|
|
1844
1886
|
static instance(node) {
|
|
1845
|
-
if (configs.HTML_IMPORTS.elements.import.includes("-") && node
|
|
1887
|
+
if (configs.HTML_IMPORTS.elements.import.includes("-") && node.nodeName === this.nodeName)
|
|
1846
1888
|
return node;
|
|
1847
1889
|
return _wq(node).get("import::instance") || new this(node);
|
|
1848
1890
|
}
|
|
@@ -1867,7 +1909,7 @@ function HTMLImportElement_default() {
|
|
|
1867
1909
|
const moduleRef = priv.moduleRef.includes("#") ? priv.moduleRef : `${priv.moduleRef}#`;
|
|
1868
1910
|
const request = { ...HTMLImportsContext.createRequest(moduleRef), live: signal && true, signal, diff: !moduleRef.endsWith("#") };
|
|
1869
1911
|
parentNode[configs.CONTEXT_API.api.contexts].request(request, (response) => {
|
|
1870
|
-
callback((response
|
|
1912
|
+
callback((isNodeInterface(response, "HTMLTemplateElement") ? [...response.content.children] : Array.isArray(response) ? response : response && [response]) || []);
|
|
1871
1913
|
});
|
|
1872
1914
|
}, { live: true, timing: "sync", lifecycleSignals: true });
|
|
1873
1915
|
priv.autoDestroyRealtime = realdom.realtime(window2.document).track(parentNode, () => {
|
|
@@ -1894,6 +1936,7 @@ function HTMLImportElement_default() {
|
|
|
1894
1936
|
priv.slottedElements.add(slottedElement);
|
|
1895
1937
|
});
|
|
1896
1938
|
priv.originalsRemapped = true;
|
|
1939
|
+
priv.autoRestore();
|
|
1897
1940
|
});
|
|
1898
1941
|
};
|
|
1899
1942
|
priv.autoRestore = (callback = null) => {
|