13 lines
18 KiB
JavaScript
13 lines
18 KiB
JavaScript
|
/**
|
||
|
* Dom7 4.0.1
|
||
|
* Minimalistic JavaScript library for DOM manipulation, with a jQuery-compatible API
|
||
|
* https://framework7.io/docs/dom7.html
|
||
|
*
|
||
|
* Copyright 2021, Vladimir Kharlampidi
|
||
|
*
|
||
|
* Licensed under MIT
|
||
|
*
|
||
|
* Released on: October 27, 2021
|
||
|
*/
|
||
|
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Dom7=e()}(this,(function(){"use strict";function t(t){return null!==t&&"object"==typeof t&&"constructor"in t&&t.constructor===Object}function e(n={},i={}){Object.keys(i).forEach((o=>{void 0===n[o]?n[o]=i[o]:t(i[o])&&t(n[o])&&Object.keys(i[o]).length>0&&e(n[o],i[o])}))}const n={body:{},addEventListener(){},removeEventListener(){},activeElement:{blur(){},nodeName:""},querySelector:()=>null,querySelectorAll:()=>[],getElementById:()=>null,createEvent:()=>({initEvent(){}}),createElement:()=>({children:[],childNodes:[],style:{},setAttribute(){},getElementsByTagName:()=>[]}),createElementNS:()=>({}),importNode:()=>null,location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""}};function i(){const t="undefined"!=typeof document?document:{};return e(t,n),t}const o={document:n,navigator:{userAgent:""},location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""},history:{replaceState(){},pushState(){},go(){},back(){}},CustomEvent:function(){return this},addEventListener(){},removeEventListener(){},getComputedStyle:()=>({getPropertyValue:()=>""}),Image(){},Date(){},screen:{},setTimeout(){},clearTimeout(){},matchMedia:()=>({}),requestAnimationFrame:t=>"undefined"==typeof setTimeout?(t(),null):setTimeout(t,0),cancelAnimationFrame(t){"undefined"!=typeof setTimeout&&clearTimeout(t)}};function s(){const t="undefined"!=typeof window?window:{};return e(t,o),t}class r extends Array{constructor(t){super(...t||[]),function(t){const e=t.__proto__;Object.defineProperty(t,"__proto__",{get:()=>e,set(t){e.__proto__=t}})}(this)}}function l(t=[]){const e=[];return t.forEach((t=>{Array.isArray(t)?e.push(...l(t)):e.push(t)})),e}function h(t,e){return Array.prototype.filter.call(t,e)}function u(t,e){const n=s(),o=i();let l=[];if(!e&&t instanceof r)return t;if(!t)return new r(l);if("string"==typeof t){const n=t.trim();if(n.indexOf("<")>=0&&n.indexOf(">")>=0){let t="div";0===n.indexOf("<li")&&(t="ul"),0===n.indexOf("<tr")&&(t="tbody"),0!==n.indexOf("<td")&&0!==n.indexOf("<th")||(t="tr"),0===n.indexOf("<tbody")&&(t="table"),0===n.indexOf("<option")&&(t="select");const e=o.createElement(t);e.innerHTML=n;for(let t=0;t<e.childNodes.length;t+=1)l.push(e.childNodes[t])}else l=function(t,e){if("string"!=typeof t)return[t];const n=[],i=e.querySelectorAll(t);for(let t=0;t<i.length;t+=1)n.push(i[t]);return n}(t.trim(),e||o)}else if(t.nodeType||t===n||t===o)l.push(t);else if(Array.isArray(t)){if(t instanceof r)return t;l=t}return new r(function(t){const e=[];for(let n=0;n<t.length;n+=1)-1===e.indexOf(t[n])&&e.push(t[n]);return e}(l))}u.fn=r.prototype;var a=Object.freeze({__proto__:null,addClass:function(...t){const e=l(t.map((t=>t.split(" "))));return this.forEach((t=>{t.classList.add(...e)})),this},removeClass:function(...t){const e=l(t.map((t=>t.split(" "))));return this.forEach((t=>{t.classList.remove(...e)})),this},toggleClass:function(...t){const e=l(t.map((t=>t.split(" "))));this.forEach((t=>{e.forEach((e=>{t.classList.toggle(e)}))}))},hasClass:function(...t){const e=l(t.map((t=>t.split(" "))));return h(this,(t=>e.filter((e=>t.classList.contains(e))).length>0)).length>0},attr:function(t,e){if(1===arguments.length&&"string"==typeof t)return this[0]?this[0].getAttribute(t):void 0;for(let n=0;n<this.length;n+=1)if(2===arguments.length)this[n].setAttribute(t,e);else for(const e in t)this[n][e]=t[e],this[n].setAttribute(e,t[e]);return this},removeAttr:function(t){for(let e=0;e<this.length;e+=1)this[e].removeAttribute(t);return this},prop:function(t,e){if(1!==arguments.length||"string"!=typeof t){for(let n=0;n<this.length;n+=1)if(2===arguments.length)this[n][t]=e;else for(const e in t)this[n][e]=t[e];return this}return this[0]?this[0][t]:this},data:function(t,e){let n;if(void 0===e){if(n=this[0],!n)return;if(n.dom7ElementDataStorage&&t in n.dom7ElementDataStorage)return n.dom7ElementDataStorage[t];const e=n.getAttribu
|
||
|
//# sourceMappingURL=dom7.min.js.map
|