MCPcopy Create free account
hub / github.com/bigskysoftware/_hyperscript / setSymbol

Method setSymbol

src/core/runtime/runtime.js:315–356  ·  view source on GitHub ↗
(str, context, type, value, targetElement)

Source from the content-addressed store, hash-verified

313 }
314
315 setSymbol(str, context, type, value, targetElement) {
316 if (type === "global") {
317 this.#globalScope[str] = value;
318 this.reactivity.notifyGlobalSymbol(str);
319 return;
320 }
321 if (type === "element") {
322 this.#getElementScope(context)[str] = value;
323 this.reactivity.notifyElementSymbol(str, context.meta.owner);
324 return;
325 }
326 if (type === "inherited") {
327 var inherited = this.#resolveInherited(str, context, targetElement);
328 if (inherited.element) {
329 this.getInternalData(inherited.element).elementScope[str] = value;
330 this.reactivity.notifyElementSymbol(str, inherited.element);
331 } else {
332 var owner = targetElement || context.meta?.owner;
333 if (owner) {
334 var internalData = this.getInternalData(owner);
335 if (!internalData.elementScope) internalData.elementScope = {};
336 internalData.elementScope[str] = value;
337 this.reactivity.notifyElementSymbol(str, owner);
338 }
339 }
340 return;
341 }
342 // local scope resolution (tries locals → element → global chain)
343 if (this.#isHyperscriptContext(context) && !this.#isReservedWord(str) && typeof context.locals[str] !== "undefined") {
344 context.locals[str] = value;
345 return;
346 }
347 var elementScope = this.#getElementScope(context);
348 if (typeof elementScope[str] !== "undefined") {
349 elementScope[str] = value;
350 this.reactivity.notifyElementSymbol(str, context.meta.owner);
351 } else if (this.#isHyperscriptContext(context) && !this.#isReservedWord(str)) {
352 context.locals[str] = value;
353 } else {
354 context[str] = value;
355 }
356 }
357
358 getInternalData(elt) {
359 if (!elt._hyperscript) {

Callers 4

putIntoMethod · 0.45
setMethod · 0.45
resolveMethod · 0.45
setMethod · 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