ant-design-x-vue-next
Version:
Ant Design X for Vue — community continuation aligned with @ant-design/x
2 lines (1 loc) • 2.61 kB
JavaScript
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../chunks/module-chunk.js");let s=null;function m(){var a,r;if(s)return s;if(typeof window<"u"&&typeof Node<"u")try{const n=document.createElement("template");n.innerHTML="<test-detect></test-detect>";const t=n.content.firstChild;if(t){const e=(a=Object.getOwnPropertyDescriptor(Node.prototype,"nodeName"))==null?void 0:a.get,i=(r=Object.getOwnPropertyDescriptor(Node.prototype,"nodeValue"))==null?void 0:r.get,u=!!(e&&t.nodeName&&!e.call(t));if(u&&e){const c=e;Object.defineProperty(Node.prototype,"nodeName",{get:function(){const o=c.call(this);if(o)return o;if(this.nodeType===1&&"tagName"in this)return this.tagName;switch(this.nodeType){case 3:return"#text";case 4:return"#cdata-section";case 7:return"#processing-instruction";case 8:return"#comment";case 9:return"#document";case 11:return"#document-fragment"}return o},configurable:!0,enumerable:!0})}const d=!!i&&(()=>{var l;n.innerHTML="<div>test</div>";const c=(l=n.content.firstChild)==null?void 0:l.firstChild;if(!c||!i)return!1;const o=i.call(c);return c.nodeValue!=null&&o==null})();if(d&&i){const c=i;Object.defineProperty(Node.prototype,"nodeValue",{get:function(){const o=c.call(this);return o??((this.nodeType===3||this.nodeType===4||this.nodeType===8)&&"data"in this?this.data:o)},configurable:!0,enumerable:!0})}if(u||d)return s=f.purify(window),s}}catch{}return s=f.purify,s}const p=["target","rel","data-language","class","style","data-raw","data-state","data-lang","data-block"],y=["script","iframe","object","embed","base","form"];function g(a){if(typeof document>"u")return a.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"");const r=document.createElement("template");r.innerHTML=a,y.forEach(t=>{r.content.querySelectorAll(t).forEach(e=>e.remove())}),r.content.querySelectorAll("*").forEach(t=>{for(const e of Array.from(t.attributes))(e.name.startsWith("on")||e.name==="srcdoc")&&t.removeAttribute(e.name)});const n=document.createElement("div");return n.appendChild(r.content.cloneNode(!0)),n.innerHTML}function A(a,r={}){if(!a)return"";const n=g(a),t=m();if(typeof t.sanitize!="function")return n.replace(/<[^>]*>/g,"");const e=r.dompurifyConfig||{},i=Array.isArray(e.ADD_TAGS)?e.ADD_TAGS:[],u=Array.isArray(e.ADD_ATTR)?e.ADD_ATTR:[],d=r.componentTags||[];return String(t.sanitize(n,{...e,ADD_TAGS:Array.from(new Set(["xmd-tail",...d,...i])),ADD_ATTR:Array.from(new Set([...p,...u]))}))}exports.createPatchedDOMPurify=m;exports.sanitizeMarkdownHtml=A;