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

Method resolve

www/js/_hyperscript-max.js:7816–7907  ·  view source on GitHub ↗
(context, { element, classRefs, css, from })

Source from the content-addressed store, hash-verified

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

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