MCPcopy Create free account
hub / github.com/bigskysoftware/_hyperscript / #resolveSpecifiers

Method #resolveSpecifiers

www/js/_hyperscript.js:3831–3871  ·  view source on GitHub ↗
(attrValue, scopeElt)

Source from the content-addressed store, hash-verified

3829 }
3830 }
3831 static #resolveSpecifiers(attrValue, scopeElt) {
3832 var result = {};
3833 var raw = attrValue.trim();
3834 if (raw === "*") {
3835 var scope = this.#readScope(scopeElt);
3836 for (var k in scope) {
3837 if (Object.prototype.hasOwnProperty.call(scope, k)) {
3838 result[k[0] === ":" ? k.slice(1) : k] = this.#serialize(scope[k]);
3839 }
3840 }
3841 return result;
3842 }
3843 var self2 = this;
3844 raw.split(",").forEach(function(part) {
3845 part = part.trim();
3846 if (!part) return;
3847 if (part[0] === ":") {
3848 var name = part.slice(1);
3849 var scope2 = self2.#readScope(scopeElt);
3850 var scopeKey = ":" + name;
3851 if (scopeKey in scope2) result[name] = self2.#serialize(scope2[scopeKey]);
3852 } else if (part[0] === "^") {
3853 var name = part.slice(1);
3854 var val = self2.#resolveInherited(":" + name, scopeElt);
3855 if (val !== void 0) result[name] = self2.#serialize(val);
3856 } else if (part[0] === "#") {
3857 var colonIdx = part.lastIndexOf(":");
3858 if (colonIdx > 0) {
3859 var selector = part.slice(0, colonIdx);
3860 var name = part.slice(colonIdx + 1);
3861 var targetElt = document.querySelector(selector);
3862 if (targetElt) {
3863 var scope2 = self2.#readScope(targetElt);
3864 var scopeKey = ":" + name;
3865 if (scopeKey in scope2) result[name] = self2.#serialize(scope2[scopeKey]);
3866 }
3867 }
3868 }
3869 });
3870 return result;
3871 }
3872 };
3873
3874 // src/parsetree/expressions/expressions.js

Callers 1

initMethod · 0.45

Calls 4

#readScopeMethod · 0.95
#serializeMethod · 0.95
forEachMethod · 0.45
#resolveInheritedMethod · 0.45

Tested by

no test coverage detected