-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhtml2js.js
1 lines (1 loc) · 2.34 KB
/
html2js.js
1
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t,n){"use strict";e.exports={document:{createElement:function(e){return'document.createElement("'+e+'")'},createTextNode:function(e){return'document.createTextNode("'+e+'")'},createDocumentFragment:function(){return"document.createDocumentFragment()"},createComment:function(e){return'document.createComment("'+e+'")'}},elem:{appendChild:function(e,t){return e+".appendChild("+t+")"},setAttribute:function(e,t,n){return e+'.setAttribute("'+t+'", "'+n+'")'}}}},function(e,t,n){"use strict";var r=n(0),o=function(e){return e.replace(/\r?\n\s*/gm,"\\n").replace(/"/g,'\\"')};window.html2js={},window.html2js.parse=function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).functionName,n=void 0===t?"createNode":t,c=document.createElement("div");c.innerHTML=e,c.normalize();var u="function "+n+"() {\n",a=0;return c.childNodes.length>1?(u+="var container = "+r.document.createDocumentFragment()+";\n",u+=i(c,"container"),u+="return container;\n"):c.childNodes.length>0&&(u+=i(c.childNodes[0],null)),u+="}";function i(e,t){var n="";switch(e.nodeType){case Node.ELEMENT_NODE:break;case Node.TEXT_NODE:if(""===e.textContent.trim())return"";var c=r.document.createTextNode(o(e.textContent));return n+=t?r.elem.appendChild(t,c)+";\n":"return "+c+";\n";case Node.COMMENT_NODE:var u=r.document.createComment(e.textContent);return n+=t?r.elem.appendChild(t,u)+";\n":"return "+u+";\n";default:throw"element with node type "+e.nodeType+" should not be in loaded with this loader"}var d="e_"+a++;n+="var ",n+=d,n+=" = "+r.document.createElement(e.tagName.toLowerCase())+";\n";for(var l=Array.prototype.slice.apply(e.attributes),m=0;m<l.length;m++)n+=r.elem.setAttribute(d,l[m].name,l[m].value)+";\n";for(var p=Array.prototype.slice.apply(e.childNodes),s=0;s<p.length;s++)n+=i(p[s],d);return n+=t?r.elem.appendChild(t,d)+";\n":"return "+d+";\n"}}}]);