-
Notifications
You must be signed in to change notification settings - Fork 13
/
vue-append.min.js
1 lines (1 loc) · 1.9 KB
/
vue-append.min.js
1
!function(){function e(n,t){t(n);for(var o in n.childNodes)e(n.childNodes[o],t)}var n={},t=!0,o=function(e,n){var t=document.createEvent("HTMLEvents");return t.initEvent(n,!0,!0),!e.dispatchEvent(t)},i=[].slice,r=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,c=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,a=document.createElement("table"),d=/^\s*<(\w+|!)[^>]*>/,u=document.createElement("tr"),l={tr:document.createElement("tbody"),tbody:a,thead:a,tfoot:a,td:u,th:u,"*":document.createElement("div")},f=function(e,n,t){var o,a;return r.test(e)&&(o=document.createElement(RegExp.$1)),o||(e.replace&&(e=e.replace(c,"<$1></$2>")),void 0===n&&(n=d.test(e)&&RegExp.$1),n in l||(n="*"),a=l[n],a.innerHTML=""+e,o=i.call(a.childNodes).map(function(e){return a.removeChild(e)})),o},m=function(n,o,i){var r=0,c=0;n.forEach(function(n){var a=n.cloneNode(!0);document.documentElement!==o&&document.documentElement.contains(o)&&e(o.insertBefore(a,null),function(e){if(null!=e.nodeName&&"SCRIPT"===e.nodeName.toUpperCase()&&(!e.type||"text/javascript"===e.type))if(r++,e.src){var n=new XMLHttpRequest;n.open("GET",e.src,t),n.onreadystatechange=function(){if(4===n.readyState&&200===n.status){e.innerHTML=n.responseText;var t=e.ownerDocument?e.ownerDocument.defaultView:window;t.eval.call(t,e.innerHTML),c++,c===r&&i()}},n.send(null)}else{var o=e.ownerDocument?e.ownerDocument.defaultView:window;o.eval.call(o,e.innerHTML),c++,c===r&&i()}})})},s=function(e,n){if(n)try{e.innerHTML="",m(f(n),e,function(){o(e,"appended")})}catch(n){o(e,"appenderr"),console.error(n)}};n.config={},n.install=function(e){e.directive("append",{bind:function(e,n){n.modifiers&&n.modifiers.sync&&(t=!1)},inserted:function(e,n){s(e,n.value)},componentUpdated:function(e,n){n.value!==n.oldValue&&s(e,n.value)}})},"object"==typeof exports?module.exports=n:"function"==typeof define&&define.amd?define([],function(){return n}):window.Vue&&(window.VueAppend=n,Vue.use(n))}();