MCPcopy Index your code
hub / github.com/bigskysoftware/_hyperscript / setSymbol

Method setSymbol

tools/common/_hyperscript.iife.js:2329–2373  ·  view source on GitHub ↗
(str, context, type, value, targetElement)

Source from the content-addressed store, hash-verified

2327 return val;
2328 }
2329 setSymbol(str, context, type, value, targetElement) {
2330 if (type === "global") {
2331 this.#globalScope[str] = value;
2332 this.reactivity.notifyGlobalSymbol(str);
2333 return;
2334 }
2335 if (type === "element") {
2336 this.#getElementScope(context)[str] = value;
2337 this.reactivity.notifyElementSymbol(str, context.meta.owner);
2338 return;
2339 }
2340 if (type === "inherited") {
2341 var inherited = this.#resolveInherited(str, context, targetElement);
2342 if (inherited.element) {
2343 this.getInternalData(inherited.element).elementScope[str] = value;
2344 this.reactivity.notifyElementSymbol(str, inherited.element);
2345 } else {
2346 var owner = targetElement || context.meta?.owner;
2347 if (owner) {
2348 var internalData = this.getInternalData(owner);
2349 if (!internalData.elementScope) internalData.elementScope = {};
2350 internalData.elementScope[str] = value;
2351 this.reactivity.notifyElementSymbol(str, owner);
2352 }
2353 }
2354 return;
2355 }
2356 if (type === "local") {
2357 context.locals[str] = value;
2358 return;
2359 }
2360 if (this.#isHyperscriptContext(context) && !this.#isReservedWord(str) && typeof context.locals[str] !== "undefined") {
2361 context.locals[str] = value;
2362 return;
2363 }
2364 var elementScope = this.#getElementScope(context);
2365 if (typeof elementScope[str] !== "undefined") {
2366 elementScope[str] = value;
2367 this.reactivity.notifyElementSymbol(str, context.meta.owner);
2368 } else if (this.#isHyperscriptContext(context) && !this.#isReservedWord(str)) {
2369 context.locals[str] = value;
2370 } else {
2371 context[str] = value;
2372 }
2373 }
2374 getInternalData(elt) {
2375 if (!elt._hyperscript) {
2376 elt._hyperscript = {};

Callers 4

setMethod · 0.45
setMethod · 0.45
resolveMethod · 0.45
putIntoMethod · 0.45

Calls 7

#getElementScopeMethod · 0.95
#resolveInheritedMethod · 0.95
getInternalDataMethod · 0.95
#isHyperscriptContextMethod · 0.95
#isReservedWordMethod · 0.95
notifyGlobalSymbolMethod · 0.45
notifyElementSymbolMethod · 0.45

Tested by

no test coverage detected