create-element-x
Version:
Extends document.createElement to conform to the target API of JSX
7 lines • 3.31 kB
JavaScript
/*!
* Copyright (c) 2020 Florian Klampfer <https://qwtel.com/>
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("createElementX",[],e):"object"==typeof exports?exports.createElementX=e():t.createElementX=e()}(window,(function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";function n(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var r=[],n=!0,o=!1,u=void 0;try{for(var i,a=t[Symbol.iterator]();!(n=(i=a.next()).done)&&(r.push(i.value),!e||r.length!==e);n=!0);}catch(t){o=!0,u=t}finally{try{n||null==a.return||a.return()}finally{if(o)throw u}}return r}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return o(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return o(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}r.r(e),r.d(e,"createElement",(function(){return f}));var u=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},i=function(t){return"[object HTMLCollection]"===Object.prototype.toString.call(t)},a=function(t){return"[object NodeList]"===Object.prototype.toString.call(t)},c=/on([A-Z][A-Za-z]+)/,l=function(t,e){function r(t){"string"==typeof t?this.appendChild(e(t)):null!=t&&this.appendChild(t)}return function(e,o){var l=t(e);for(var f in o){var p=void 0;if(p=c.exec(f)){var d=p,y=n(d,2),s=y[1];l.addEventListener(s.toLowerCase(),o[f])}else l.setAttribute(f,o[f])}for(var b=arguments.length,m=new Array(b>2?b-2:0),v=2;v<b;v++)m[v-2]=arguments[v];var j,g=m[0];return u(g)||(j=i(g))||(j=a(g))?(j&&(g=Array.prototype.slice.call(g,0)),Array.prototype.forEach.call(g,r,l)):Array.prototype.forEach.call(m,r,l),l}},f=l(document.createElement.bind(document),document.createTextNode.bind(document));e.default=f}])}));