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

Method resolve

www/js/_hyperscript.js:7817–7908  ·  view source on GitHub ↗
(context, { element, classRefs, css, from })

Source from the content-addressed store, hash-verified

7815 }
7816 }
7817 resolve(context, { element, classRefs, css, from }) {
7818 var runtime2 = context.meta.runtime;
7819 var cmd = this;
7820 var result;
7821 if (this.variant === "element") {
7822 if (from == null && typeof this.elementExpr.delete === "function") {
7823 var isDomTarget = this.isDOMTarget(element);
7824 if (!isDomTarget) {
7825 var lhsExprs = this.elementExpr.lhs;
7826 var lhs = {};
7827 for (var key in lhsExprs) {
7828 var sub = lhsExprs[key];
7829 lhs[key] = sub && sub.evaluate ? sub.evaluate(context) : sub;
7830 }
7831 this.elementExpr.delete(context, lhs);
7832 return this.findNext(context);
7833 }
7834 }
7835 runtime2.nullCheck(element, this.elementExpr);
7836 if (from != null && Array.isArray(from)) {
7837 var idx = from.indexOf(element);
7838 if (idx > -1) from.splice(idx, 1);
7839 runtime2.notifyMutation(from);
7840 } else if (from instanceof Set) {
7841 from.delete(element);
7842 runtime2.notifyMutation(from);
7843 } else if (from instanceof Map) {
7844 from.delete(element);
7845 runtime2.notifyMutation(from);
7846 } else {
7847 runtime2.implicitLoop(element, function(target) {
7848 if (target.parentElement && (from == null || from.contains(target))) {
7849 target.parentElement.removeChild(target);
7850 }
7851 });
7852 }
7853 } else if (this.variant === "css") {
7854 runtime2.nullCheck(from, this.fromExpr);
7855 var propNames = _cssPropertyNames(css);
7856 runtime2.implicitLoop(from, function(target) {
7857 _removeCssProperties(target, propNames);
7858 });
7859 } else {
7860 runtime2.nullCheck(from, this.fromExpr);
7861 if (classRefs) {
7862 runtime2.forEach(classRefs, function(classRef) {
7863 if (cmd.when) {
7864 result = runtime2.implicitLoopWhen(
7865 from,
7866 cmd.when,
7867 context,
7868 function(t) {
7869 t.classList.remove(classRef.className);
7870 },
7871 function(t) {
7872 t.classList.add(classRef.className);
7873 }
7874 );

Callers

nothing calls this directly

Calls 12

isDOMTargetMethod · 0.95
_cssPropertyNamesFunction · 0.70
_removeCssPropertiesFunction · 0.70
evaluateMethod · 0.45
deleteMethod · 0.45
findNextMethod · 0.45
nullCheckMethod · 0.45
notifyMutationMethod · 0.45
implicitLoopMethod · 0.45
containsMethod · 0.45
forEachMethod · 0.45
implicitLoopWhenMethod · 0.45

Tested by

no test coverage detected