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

Method resolve

tools/common/_hyperscript.iife.js:6349–6404  ·  view source on GitHub ↗
(context, { root, prop, value: valueToPut })

Source from the content-addressed store, hash-verified

6347 }
6348 }
6349 resolve(context, { root, prop, value: valueToPut }) {
6350 if (this.symbolWrite) {
6351 this.putInto(context, root, prop, valueToPut);
6352 } else {
6353 context.meta.runtime.nullCheck(root, this.rootExpr);
6354 if (this.operation === "into") {
6355 if (this.attributeWrite) {
6356 context.meta.runtime.implicitLoop(root, function(elt) {
6357 if (valueToPut == null) {
6358 elt.removeAttribute(prop);
6359 } else {
6360 elt.setAttribute(prop, valueToPut);
6361 }
6362 });
6363 } else if (this.styleWrite) {
6364 context.meta.runtime.implicitLoop(root, function(elt) {
6365 elt.style[prop] = valueToPut;
6366 });
6367 } else if (this.arrayIndex) {
6368 root[prop] = valueToPut;
6369 } else {
6370 var cmd = this;
6371 context.meta.runtime.implicitLoop(root, function(elt) {
6372 cmd.putInto(context, elt, prop, valueToPut);
6373 });
6374 }
6375 } else if (Array.isArray(root)) {
6376 if (this.operation === "start") {
6377 root.unshift(valueToPut);
6378 } else {
6379 root.push(valueToPut);
6380 }
6381 context.meta.runtime.notifyMutation(root);
6382 } else {
6383 var ops = {
6384 before: Element.prototype.before,
6385 after: Element.prototype.after,
6386 start: Element.prototype.prepend,
6387 end: Element.prototype.append
6388 };
6389 var op = ops[this.operation] || Element.prototype.append;
6390 context.meta.runtime.implicitLoop(root, function(elt) {
6391 op.call(
6392 elt,
6393 valueToPut instanceof Node ? valueToPut : context.meta.runtime.convertValue(valueToPut, "Fragment")
6394 );
6395 if (elt.parentElement) {
6396 context.meta.runtime.processNode(elt.parentElement);
6397 } else {
6398 context.meta.runtime.processNode(elt);
6399 }
6400 });
6401 }
6402 }
6403 return this.findNext(context);
6404 }
6405 };
6406

Callers

nothing calls this directly

Calls 7

putIntoMethod · 0.95
nullCheckMethod · 0.45
implicitLoopMethod · 0.45
notifyMutationMethod · 0.45
convertValueMethod · 0.45
processNodeMethod · 0.45
findNextMethod · 0.45

Tested by

no test coverage detected