EmbyCrackedClient/web/modules/morphdom/morphdom.js

1 line
10 KiB
JavaScript
Raw Permalink Normal View History

2025-06-25 11:46:04 +08:00
let DOCUMENT_FRAGMENT_NODE=11;function morphAttrs(fromNode,toNode){var attrValue,toNodeAttrs=toNode.attributes;let attr,attrName,attrNamespaceURI,fromValue;if(toNode.nodeType!==DOCUMENT_FRAGMENT_NODE&&fromNode.nodeType!==DOCUMENT_FRAGMENT_NODE){for(let i=toNodeAttrs.length-1;0<=i;i--)attr=toNodeAttrs[i],attrName=attr.name,attrNamespaceURI=attr.namespaceURI,attrValue=attr.value,attrNamespaceURI?(attrName=attr.localName||attrName,(fromValue=fromNode.getAttributeNS(attrNamespaceURI,attrName))!==attrValue&&("xmlns"===attr.prefix&&(attrName=attr.name),fromNode.setAttributeNS(attrNamespaceURI,attrName,attrValue))):(fromValue=fromNode.getAttribute(attrName))!==attrValue&&fromNode.setAttribute(attrName,attrValue);var fromNodeAttrs=fromNode.attributes;for(let d=fromNodeAttrs.length-1;0<=d;d--)attr=fromNodeAttrs[d],attrName=attr.name,(attrNamespaceURI=attr.namespaceURI)?(attrName=attr.localName||attrName,toNode.hasAttributeNS(attrNamespaceURI,attrName)||fromNode.removeAttributeNS(attrNamespaceURI,attrName)):toNode.hasAttribute(attrName)||fromNode.removeAttribute(attrName)}}let range,NS_XHTML="http://www.w3.org/1999/xhtml",doc="undefined"==typeof document?void 0:document,HAS_TEMPLATE_SUPPORT=!!doc&&"content"in doc.createElement("template"),HAS_RANGE_SUPPORT=!!doc&&doc.createRange&&"createContextualFragment"in doc.createRange();function createFragmentFromTemplate(str){var template=doc.createElement("template");return template.innerHTML=str,template.content.childNodes[0]}function createFragmentFromRange(str){return range||(range=doc.createRange()).selectNode(doc.body),range.createContextualFragment(str).childNodes[0]}function createFragmentFromWrap(str){var fragment=doc.createElement("body");return fragment.innerHTML=str,fragment.childNodes[0]}function toElement(str){return str=str.trim(),(HAS_TEMPLATE_SUPPORT?createFragmentFromTemplate:HAS_RANGE_SUPPORT?createFragmentFromRange:createFragmentFromWrap)(str)}function compareNodeNames(fromEl,toEl){var fromCodeStart,toCodeStart,fromEl=fromEl.nodeName,toEl=toEl.nodeName;return fromEl===toEl||(fromCodeStart=fromEl.charCodeAt(0),toCodeStart=toEl.charCodeAt(0),fromCodeStart<=90&&97<=toCodeStart?fromEl===toEl.toUpperCase():toCodeStart<=90&&97<=fromCodeStart&&toEl===fromEl.toUpperCase())}function createElementNS(name,namespaceURI){return namespaceURI&&namespaceURI!==NS_XHTML?doc.createElementNS(namespaceURI,name):doc.createElement(name)}function moveChildren(fromEl,toEl){let curChild=fromEl.firstChild;for(;curChild;){var nextChild=curChild.nextSibling;toEl.appendChild(curChild),curChild=nextChild}return toEl}function syncBooleanAttrProp(fromEl,toEl,name){fromEl[name]!==toEl[name]&&(fromEl[name]=toEl[name],fromEl[name]?fromEl.setAttribute(name,""):fromEl.removeAttribute(name))}let specialElHandlers={OPTION:function(fromEl,toEl){let parentNode=fromEl.parentNode;if(parentNode){let parentName=parentNode.nodeName.toUpperCase();"OPTGROUP"===parentName&&(parentNode=parentNode.parentNode,parentName=parentNode&&parentNode.nodeName.toUpperCase()),"SELECT"!==parentName||parentNode.hasAttribute("multiple")||(fromEl.hasAttribute("selected")&&!toEl.selected&&(fromEl.setAttribute("selected","selected"),fromEl.removeAttribute("selected")),parentNode.selectedIndex=-1)}syncBooleanAttrProp(fromEl,toEl,"selected")},INPUT:function(fromEl,toEl){syncBooleanAttrProp(fromEl,toEl,"checked"),syncBooleanAttrProp(fromEl,toEl,"disabled"),fromEl.value!==toEl.value&&(fromEl.value=toEl.value),toEl.hasAttribute("value")||fromEl.removeAttribute("value")},TEXTAREA:function(fromEl,toEl){var oldValue,toEl=toEl.value,firstChild=(fromEl.value!==toEl&&(fromEl.value=toEl),fromEl.firstChild);firstChild&&(oldValue=firstChild.nodeValue)!==toEl&&(toEl||oldValue!==fromEl.placeholder)&&(firstChild.nodeValue=toEl)},SELECT:function(fromEl,toEl){if(!toEl.hasAttribute("multiple")){let selectedIndex=-1,i=0,curChild=fromEl.firstChild,optgroup;for(var nodeName;curChild;)if("OPTGROUP"===(nodeName=curChild.nodeName&&curChild.nodeName.toUpperCase()))curChild=(optgroup=curChild).firstChild;else{if("OPTION"===nodeName){if(curChild.hasAttribute("select