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

Method resolve

www/js/_hyperscript.js:6708–6763  ·  view source on GitHub ↗
(context, { root, prop, value: valueToPut })

Source from the content-addressed store, hash-verified

6706 }
6707 }
6708 resolve(context, { root, prop, value: valueToPut }) {
6709 if (this.symbolWrite) {
6710 this.putInto(context, root, prop, valueToPut);
6711 } else {
6712 context.meta.runtime.nullCheck(root, this.rootExpr);
6713 if (this.operation === "into") {
6714 if (this.attributeWrite) {
6715 context.meta.runtime.implicitLoop(root, function(elt) {
6716 if (valueToPut == null) {
6717 elt.removeAttribute(prop);
6718 } else {
6719 elt.setAttribute(prop, valueToPut);
6720 }
6721 });
6722 } else if (this.styleWrite) {
6723 context.meta.runtime.implicitLoop(root, function(elt) {
6724 elt.style[prop] = valueToPut;
6725 });
6726 } else if (this.arrayIndex) {
6727 root[prop] = valueToPut;
6728 } else {
6729 var cmd = this;
6730 context.meta.runtime.implicitLoop(root, function(elt) {
6731 cmd.putInto(context, elt, prop, valueToPut);
6732 });
6733 }
6734 } else if (Array.isArray(root)) {
6735 if (this.operation === "start") {
6736 root.unshift(valueToPut);
6737 } else {
6738 root.push(valueToPut);
6739 }
6740 context.meta.runtime.notifyMutation(root);
6741 } else {
6742 var ops = {
6743 before: Element.prototype.before,
6744 after: Element.prototype.after,
6745 start: Element.prototype.prepend,
6746 end: Element.prototype.append
6747 };
6748 var op = ops[this.operation] || Element.prototype.append;
6749 context.meta.runtime.implicitLoop(root, function(elt) {
6750 op.call(
6751 elt,
6752 valueToPut instanceof Node ? valueToPut : context.meta.runtime.convertValue(valueToPut, "Fragment")
6753 );
6754 if (elt.parentElement) {
6755 context.meta.runtime.processNode(elt.parentElement);
6756 } else {
6757 context.meta.runtime.processNode(elt);
6758 }
6759 });
6760 }
6761 }
6762 return this.findNext(context);
6763 }
6764 };
6765

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