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

Method resolve

www/js/_hyperscript.js:8494–8529  ·  view source on GitHub ↗
(ctx, { target })

Source from the content-addressed store, hash-verified

8492 return new _EmptyCommand(target);
8493 }
8494 resolve(ctx, { target }) {
8495 var elt = target || ctx.me;
8496 if (Array.isArray(elt)) {
8497 elt.splice(0);
8498 ctx.meta.runtime.notifyMutation(elt);
8499 } else if (elt instanceof Set || elt instanceof Map) {
8500 elt.clear();
8501 ctx.meta.runtime.notifyMutation(elt);
8502 } else {
8503 ctx.meta.runtime.implicitLoop(elt, function(e) {
8504 var tag = e.tagName;
8505 if (tag === "INPUT") {
8506 if (e.type === "checkbox" || e.type === "radio") e.checked = false;
8507 else e.value = "";
8508 } else if (tag === "TEXTAREA") {
8509 e.value = "";
8510 } else if (tag === "SELECT") {
8511 e.selectedIndex = -1;
8512 } else if (tag === "FORM") {
8513 e.querySelectorAll("input, textarea, select").forEach(function(inp) {
8514 if (inp.tagName === "INPUT") {
8515 if (inp.type === "checkbox" || inp.type === "radio") inp.checked = false;
8516 else inp.value = "";
8517 } else if (inp.tagName === "TEXTAREA") {
8518 inp.value = "";
8519 } else if (inp.tagName === "SELECT") {
8520 inp.selectedIndex = -1;
8521 }
8522 });
8523 } else {
8524 e.replaceChildren();
8525 }
8526 });
8527 }
8528 return this.findNext(ctx);
8529 }
8530 };
8531 var ResetCommand = class _ResetCommand extends Command {
8532 static keyword = "reset";

Callers

nothing calls this directly

Calls 4

notifyMutationMethod · 0.45
implicitLoopMethod · 0.45
forEachMethod · 0.45
findNextMethod · 0.45

Tested by

no test coverage detected