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

Function _createElementSide

tools/common/_hyperscript.iife.js:9503–9542  ·  view source on GitHub ↗
(element, runtime2)

Source from the content-addressed store, hash-verified

9501 "SELECT": "value"
9502 };
9503 function _createElementSide(element, runtime2) {
9504 var tag = element.tagName;
9505 var type = tag === "INPUT" ? element.getAttribute("type") || "text" : null;
9506 if (tag === "INPUT" && type === "radio") {
9507 var radioValue = element.value;
9508 return {
9509 element,
9510 read: function() {
9511 var checked = runtime2.resolveProperty(element, "checked");
9512 return checked ? radioValue : void 0;
9513 },
9514 write: function(value) {
9515 element.checked = value === radioValue;
9516 }
9517 };
9518 }
9519 var prop = _bindProperty[tag + ":" + type] || _bindProperty[tag];
9520 if (!prop && element.hasAttribute("contenteditable") && element.getAttribute("contenteditable") !== "false") {
9521 prop = "textContent";
9522 }
9523 if (!prop && tag.includes("-") && "value" in element) {
9524 prop = "value";
9525 }
9526 if (!prop) {
9527 throw new Error(
9528 "bind cannot auto-detect a property for <" + tag.toLowerCase() + ">. Use an explicit property (e.g. 'bind $var to #el's value')."
9529 );
9530 }
9531 var isNumeric = prop === "valueAsNumber";
9532 return {
9533 element,
9534 read: function() {
9535 var val = runtime2.resolveProperty(element, prop);
9536 return isNumeric && val !== val ? null : val;
9537 },
9538 write: function(value) {
9539 element[prop] = value;
9540 }
9541 };
9542 }
9543 function _createExpressionSide(expr, target, feature, runtime2) {
9544 if (expr.type === "classRef") {
9545 return {

Callers 1

_resolveSideFunction · 0.70

Calls 1

resolvePropertyMethod · 0.45

Tested by

no test coverage detected