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

Function _copyAttributes

www/js/_hyperscript.esm.js:3686–3701  ·  view source on GitHub ↗
(destination, source)

Source from the content-addressed store, hash-verified

3684 parentNode.insertBefore(element, after);
3685}
3686function _copyAttributes(destination, source) {
3687 for (var attr of source.attributes) {
3688 if (destination.getAttribute(attr.name) !== attr.value) {
3689 destination.setAttribute(attr.name, attr.value);
3690 if (attr.name === "value" && destination instanceof HTMLInputElement && destination.type !== "file") {
3691 destination.value = attr.value;
3692 }
3693 }
3694 }
3695 for (var i = destination.attributes.length - 1; i >= 0; i--) {
3696 var attr = destination.attributes[i];
3697 if (attr && !source.hasAttribute(attr.name)) {
3698 destination.removeAttribute(attr.name);
3699 }
3700 }
3701}
3702function _isSoftMatch(oldNode, newNode) {
3703 if (!(oldNode instanceof Element) || oldNode.tagName !== newNode.tagName) return false;
3704 if (oldNode.tagName === "SCRIPT" && !oldNode.isEqualNode(newNode)) return false;

Callers 2

morphMethod · 0.70
_morphNodeFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected