diff --git a/package-lock.json b/package-lock.json index db34633e8..32bd26997 100644 --- a/package-lock.json +++ b/package-lock.json @@ -47,6 +47,7 @@ "lodash": "^4.17.21", "mime-types": "^2.1.35", "moment": "^2.30.1", + "morphdom": "^2.7.4", "multer": "^1.4.5-lts.1", "node-fetch": "^3.3.2", "node-persist": "^4.0.1", @@ -5784,6 +5785,12 @@ "node": "*" } }, + "node_modules/morphdom": { + "version": "2.7.4", + "resolved": "https://registry.npmjs.org/morphdom/-/morphdom-2.7.4.tgz", + "integrity": "sha512-ATTbWMgGa+FaMU3FhnFYB6WgulCqwf6opOll4CBzmVDTLvPMmUPrEv8CudmLPK0MESa64+6B89fWOxP3+YIlxQ==", + "license": "MIT" + }, "node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", diff --git a/package.json b/package.json index 7c4afac75..43ae658bc 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "lodash": "^4.17.21", "mime-types": "^2.1.35", "moment": "^2.30.1", + "morphdom": "^2.7.4", "multer": "^1.4.5-lts.1", "node-fetch": "^3.3.2", "node-persist": "^4.0.1", diff --git a/public/lib.js b/public/lib.js index 73d81b109..7c6f6e11d 100644 --- a/public/lib.js +++ b/public/lib.js @@ -20,6 +20,7 @@ import moment from 'moment'; import seedrandom from 'seedrandom'; import * as Popper from '@popperjs/core'; import droll from 'droll'; +import morphdom from 'morphdom'; /** * Expose the libraries to the 'window' object. @@ -96,6 +97,7 @@ export default { seedrandom, Popper, droll, + morphdom, }; export { @@ -118,4 +120,5 @@ export { seedrandom, Popper, droll, + morphdom, }; diff --git a/public/scripts/extensions/quick-reply/lib/morphdom-esm.js b/public/scripts/extensions/quick-reply/lib/morphdom-esm.js deleted file mode 100644 index 7a13a27fc..000000000 --- a/public/scripts/extensions/quick-reply/lib/morphdom-esm.js +++ /dev/null @@ -1,769 +0,0 @@ -var DOCUMENT_FRAGMENT_NODE = 11; - -function morphAttrs(fromNode, toNode) { - var toNodeAttrs = toNode.attributes; - var attr; - var attrName; - var attrNamespaceURI; - var attrValue; - var fromValue; - - // document-fragments dont have attributes so lets not do anything - if (toNode.nodeType === DOCUMENT_FRAGMENT_NODE || fromNode.nodeType === DOCUMENT_FRAGMENT_NODE) { - return; - } - - // update attributes on original DOM element - for (var i = toNodeAttrs.length - 1; i >= 0; i--) { - attr = toNodeAttrs[i]; - attrName = attr.name; - attrNamespaceURI = attr.namespaceURI; - attrValue = attr.value; - - if (attrNamespaceURI) { - attrName = attr.localName || attrName; - fromValue = fromNode.getAttributeNS(attrNamespaceURI, attrName); - - if (fromValue !== attrValue) { - if (attr.prefix === 'xmlns'){ - attrName = attr.name; // It's not allowed to set an attribute with the XMLNS namespace without specifying the `xmlns` prefix - } - fromNode.setAttributeNS(attrNamespaceURI, attrName, attrValue); - } - } else { - fromValue = fromNode.getAttribute(attrName); - - if (fromValue !== attrValue) { - fromNode.setAttribute(attrName, attrValue); - } - } - } - - // Remove any extra attributes found on the original DOM element that - // weren't found on the target element. - var fromNodeAttrs = fromNode.attributes; - - for (var d = fromNodeAttrs.length - 1; d >= 0; d--) { - attr = fromNodeAttrs[d]; - attrName = attr.name; - attrNamespaceURI = attr.namespaceURI; - - if (attrNamespaceURI) { - attrName = attr.localName || attrName; - - if (!toNode.hasAttributeNS(attrNamespaceURI, attrName)) { - fromNode.removeAttributeNS(attrNamespaceURI, attrName); - } - } else { - if (!toNode.hasAttribute(attrName)) { - fromNode.removeAttribute(attrName); - } - } - } -} - -var range; // Create a range object for efficently rendering strings to elements. -var NS_XHTML = 'http://www.w3.org/1999/xhtml'; - -var doc = typeof document === 'undefined' ? undefined : document; -var HAS_TEMPLATE_SUPPORT = !!doc && 'content' in doc.createElement('template'); -var HAS_RANGE_SUPPORT = !!doc && doc.createRange && 'createContextualFragment' in doc.createRange(); - -function createFragmentFromTemplate(str) { - var template = doc.createElement('template'); - template.innerHTML = str; - return template.content.childNodes[0]; -} - -function createFragmentFromRange(str) { - if (!range) { - range = doc.createRange(); - range.selectNode(doc.body); - } - - var fragment = range.createContextualFragment(str); - return fragment.childNodes[0]; -} - -function createFragmentFromWrap(str) { - var fragment = doc.createElement('body'); - fragment.innerHTML = str; - return fragment.childNodes[0]; -} - -/** - * This is about the same - * var html = new DOMParser().parseFromString(str, 'text/html'); - * return html.body.firstChild; - * - * @method toElement - * @param {String} str - */ -function toElement(str) { - str = str.trim(); - if (HAS_TEMPLATE_SUPPORT) { - // avoid restrictions on content for things like `Hi` which - // createContextualFragment doesn't support - //