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

Method resolve

tools/common/_hyperscript.iife.js:7261–7343  ·  view source on GitHub ↗
(context, { to, classRefs, css, value })

Source from the content-addressed store, hash-verified

7259 }
7260 }
7261 resolve(context, { to, classRefs, css, value }) {
7262 var runtime2 = context.meta.runtime;
7263 var cmd = this;
7264 runtime2.nullCheck(to, this.toExpr);
7265 var result;
7266 if (this.variant === "collection") {
7267 if (Array.isArray(to)) {
7268 to.push(value);
7269 } else if (to instanceof Set) {
7270 to.add(value);
7271 } else if (to instanceof Map) {
7272 throw new Error("Use 'set myMap[key] to value' for Maps");
7273 } else {
7274 throw new Error("Cannot add to " + typeof to);
7275 }
7276 runtime2.notifyMutation(to);
7277 return runtime2.findNext(this, context);
7278 } else if (this.variant === "class") {
7279 runtime2.forEach(classRefs, function(classRef) {
7280 if (cmd.when) {
7281 result = runtime2.implicitLoopWhen(
7282 to,
7283 cmd.when,
7284 context,
7285 function(t) {
7286 if (t instanceof Element) t.classList.add(classRef.className);
7287 },
7288 function(t) {
7289 if (t instanceof Element) t.classList.remove(classRef.className);
7290 }
7291 );
7292 } else {
7293 runtime2.implicitLoop(to, function(t) {
7294 if (t instanceof Element) t.classList.add(classRef.className);
7295 });
7296 }
7297 });
7298 } else if (this.variant === "attribute") {
7299 var attributeRef = this.attributeRef;
7300 if (this.when) {
7301 result = runtime2.implicitLoopWhen(
7302 to,
7303 this.when,
7304 context,
7305 function(t) {
7306 t.setAttribute(attributeRef.name, attributeRef.value);
7307 },
7308 function(t) {
7309 t.removeAttribute(attributeRef.name);
7310 }
7311 );
7312 } else {
7313 runtime2.implicitLoop(to, function(t) {
7314 t.setAttribute(attributeRef.name, attributeRef.value);
7315 });
7316 }
7317 } else {
7318 if (this.when) {

Callers

nothing calls this directly

Calls 8

_cssPropertyNamesFunction · 0.70
_removeCssPropertiesFunction · 0.70
nullCheckMethod · 0.45
notifyMutationMethod · 0.45
findNextMethod · 0.45
forEachMethod · 0.45
implicitLoopWhenMethod · 0.45
implicitLoopMethod · 0.45

Tested by

no test coverage detected