/
dope.min.js
14 lines (14 loc) · 4.15 KB
/
dope.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/*!
* dope 2.2.2
* http://github.com/ryanve/dope
* MIT License (c) Ryan Van Etten
*/
(function(t,q,g){"undefined"!=typeof module&&module.exports?module.exports=g():t[q]=g()})(this,"dope",function(){function t(a,b){return b.toUpperCase()}function q(a){return"string"!=typeof a?"number"==typeof a||"boolean"==typeof a?""+a:"":a.replace(y,"").replace(I,t)}function g(a){return(a="string"==typeof a?a.replace(y,"$1").replace(J,"$1-$2"):"number"==typeof a?""+a:"")?"data-"+a.toLowerCase():a}function u(a){var b;return"string"==typeof a&&a?"false"===a?!1:"true"===a?!0:"null"===a?null:"undefined"===
a||(b=+a)||0===b||"NaN"===a?b:a:a}function z(a,b,c,d){var e,f=0,l,h=0,g=[];if(null==a)return g;d=!0===d;for(e=a.length;f<e;)if((l=b.call(c,a[f],f++,a))||!d)g[h++]=l;return g}function m(a,b,c){for(var d=a.length,e=0;e<d;e++)a[e]&&a[e].nodeType&&b(a[e],c);return a}function K(a,b,c){var d,e,f,g,h;if(a.attributes)for(d="boolean"==typeof c?/^data-/:d,g=0,h=a.attributes.length;g<h;)if(f=a.attributes[g++])e=""+f.name,d&&d.test(e)!==c||null==f.value||b.call(a,f.value,e,f)}function L(a){var b;if(a&&1===a.nodeType){if(b=
A&&a.dataset)return b;b={};K(a,function(a,d){b[q(d)]=""+a},!0);return b}}function B(a,b){if(a){var c,d=a.dataset;if(d&&A){if(d===b)return;for(c in d)delete d[c]}b&&n(a,b)}}function C(a,b,c){for(var d in b)M.call(b,d)&&c(a,d,b[d])}function p(a,b,c){if((a=a.nodeType?a:a[0])&&a.setAttribute&&(b="function"==typeof b?b.call(a):b))if("object"==typeof b)C(a,b,p);else{if(void 0===c)return b=a.getAttribute(b),null==b?c:""+b;c="function"==typeof c?c.call(a):c;c=""+c;a.setAttribute(b,c);return c}}function n(a,
b,c){var d,e="function"==typeof b;if((a=a.nodeType?a:a[0])&&a.setAttribute){if(void 0===b&&c===b)return L(a);b=e?b.call(a):b;if("object"!=typeof b||!e&&(d=void 0===c&&g(b[0]))){if(b=d||g(b)){if(void 0===c)return b=a.getAttribute(b),null==b?c:d?u(b):""+b;c="function"==typeof c?c.call(a):c;c=""+c;a.setAttribute(b,c);return c}}else e&&D(a),b&&C(a,b,n)}}function D(a,b){var c,d=0;if((a=a.nodeType?a:a[0])&&a.removeAttribute)if(void 0===b)B(a);else for(b="string"==typeof b?b.split(v):[].concat(b);d<b.length;)(c=
g(b[d++]))&&a.removeAttribute(c)}function w(a,b){var c=0;if((a=a.nodeType?a:a[0])&&a.removeAttribute)for(b="string"==typeof b?b.split(v):[].concat(b);c<b.length;c++)b[c]&&a.removeAttribute(b[c])}function k(a,b,c){var d,e,f=0,l=0,h=[];b=!0===b;a="string"==typeof a?a.split(N):"number"==typeof a?""+a:a;for(d=a.length;f<d;)e=a[f++],(e=b?g(e):e.replace(O,""))&&(h[l++]=e);return!1===c?h:l?"["+h.join("],[").replace(P,"\\\\.")+"]":""}function E(a,b){var c,d,e,f,g=a.length,h=[],k=0;if(!g)return h;f=r("*",
b);for(c=0;e=f[c];c++)for(d=g;d--;)if(null!=p(e,a[d])){h[k++]=e;break}return h}var F=document,f={},s=f.fn={},M=f.hasOwnProperty,A="undefined"!=typeof DOMStringMap,Q="undefined"!=typeof JSON&&JSON.parse,x="querySelectorAll",G=!!F[x]||!(x="getElementsByTagName"),r=function(a,b){return a?(b||F)[x](a):[]},J=/([a-z])([A-Z])/g,I=/-(.)/g,N=/\s*[\s\,]+\s*/,O=/^[\[\s]+|\s+|[\]\s]+$/g,y=/^[\[\s]?(data-)?|\s+|[\]\s]?$/g,P=/\\*\./g,v=/\s+/,R=/^\s+|\s+$/,H="".trim?function(a){return null==a?"":a.trim()}:function(a){return null==
a?"":a.replace(R,"")};f.queryData=G?function(a,b){return!1===b?k(a,!0,b):r(k(a,!0),b)}:function(a,b){a=k(a,!0,!1);return!1===b?a:E(a,b)};f.queryAttr=G?function(a,b){return!1===b?k(a,b,b):r(k(a),b)}:function(a,b){a=k(a,!1,!1);return!1===b?a:E(a,b)};f.map=z;f.parse=u;f.parseJSON=function(a){a=u(a);if("string"==typeof a)try{a=Q(H(a))}catch(b){}return a};f.trim=H;f.qsa=r;f.attr=p;f.removeAttr=w;f.dataset=n;f.deletes=D;f.camelize=q;f.datatize=g;s.dataset=function(a,b){var c="object"==typeof a?!(void 0===
b&&g(a[0])):"function"==typeof a;return void 0!==b||c?(a=c?a:g(a))?m(this,function(d,e){e="function"==typeof b?b.call(d):b;c?n(d,a,e):d.setAttribute(a,""+e)}):void 0===b?b:this:n(this[0],a)};s.attr=function(a,b){var c="object"==typeof a||"function"==typeof a;return void 0!==b||c?a?m(this,function(d,e){e="function"==typeof b?b.call(d):b;c?p(d,a,e):d.setAttribute(a,""+e)}):void 0===b?b:this:p(this[0],a)};s.deletes=function(a){if(void 0===a)return m(this,B);a="string"==typeof a?a.split(v):[].concat(a);
return m(this,w,z(a,g))};s.removeAttr=function(a){return m(this,w,a)};return f});