MCPcopy Create free account
hub / github.com/WebReflection/hypersimple / anyContent

Function anyContent

index.js:1646–1730  ·  view source on GitHub ↗
(value)

Source from the content-addressed store, hash-verified

1644 var oldValue;
1645
1646 var anyContent = function anyContent(value) {
1647 switch (typeof(value)) {
1648 case 'string':
1649 case 'number':
1650 case 'boolean':
1651 if (fastPath) {
1652 if (oldValue !== value) {
1653 oldValue = value;
1654 childNodes[0].textContent = value;
1655 }
1656 } else {
1657 fastPath = true;
1658 oldValue = value;
1659 childNodes = domdiff(node.parentNode, childNodes, [text(node, value)], diffOptions);
1660 }
1661
1662 break;
1663
1664 case 'function':
1665 anyContent(value(node));
1666 break;
1667
1668 case 'object':
1669 case 'undefined':
1670 if (value == null) {
1671 fastPath = false;
1672 childNodes = domdiff(node.parentNode, childNodes, [], diffOptions);
1673 break;
1674 }
1675
1676 default:
1677 fastPath = false;
1678 oldValue = value;
1679
1680 if (isArray(value)) {
1681 if (value.length === 0) {
1682 if (childNodes.length) {
1683 childNodes = domdiff(node.parentNode, childNodes, [], diffOptions);
1684 }
1685 } else {
1686 switch (typeof(value[0])) {
1687 case 'string':
1688 case 'number':
1689 case 'boolean':
1690 anyContent({
1691 html: value
1692 });
1693 break;
1694
1695 case 'object':
1696 if (isArray(value[0])) {
1697 value = value.concat.apply([], value);
1698 }
1699
1700 if (isPromise_ish(value[0])) {
1701 Promise.all(value).then(anyContent);
1702 break;
1703 }

Callers

nothing calls this directly

Calls 5

domdiffFunction · 0.85
textFunction · 0.85
isPromise_ishFunction · 0.85
canDiffFunction · 0.85
invokeAtDistanceFunction · 0.85

Tested by

no test coverage detected