{"version":3,"sources":["webpack:///./node_modules/component-classes/index.js"],"names":["index","err","re","toString","Object","prototype","ClassList","el","nodeType","Error","this","list","classList","module","exports","add","name","arr","array","push","className","join","remove","call","removeMatching","i","splice","length","test","toggle","force","has","getAttribute","replace","split","shift","contains"],"mappings":"8EAIA,IACE,IAAIA,EAAQ,EAAQ,KACpB,MAAOC,GACHD,EAAQ,EAAQ,KAOtB,IAAIE,EAAK,MAMLC,EAAWC,OAAOC,UAAUF,SAqBhC,SAASG,EAAUC,GACjB,IAAKA,IAAOA,EAAGC,SACb,MAAM,IAAIC,MAAM,uCAElBC,KAAKH,GAAKA,EACVG,KAAKC,KAAOJ,EAAGK,UAhBjBC,EAAOC,QAAU,SAASP,GACxB,OAAO,IAAID,EAAUC,IA0BvBD,EAAUD,UAAUU,IAAM,SAASC,GAEjC,GAAIN,KAAKC,KAEP,OADAD,KAAKC,KAAKI,IAAIC,GACPN,KAIT,IAAIO,EAAMP,KAAKQ,QAIf,OAHQlB,EAAMiB,EAAKD,IACVC,EAAIE,KAAKH,GAClBN,KAAKH,GAAGa,UAAYH,EAAII,KAAK,KACtBX,MAaTJ,EAAUD,UAAUiB,OAAS,SAASN,GACpC,GAAI,mBAAqBb,EAASoB,KAAKP,GACrC,OAAON,KAAKc,eAAeR,GAI7B,GAAIN,KAAKC,KAEP,OADAD,KAAKC,KAAKW,OAAON,GACVN,KAIT,IAAIO,EAAMP,KAAKQ,QACXO,EAAIzB,EAAMiB,EAAKD,GAGnB,OAFKS,GAAGR,EAAIS,OAAOD,EAAG,GACtBf,KAAKH,GAAGa,UAAYH,EAAII,KAAK,KACtBX,MAWTJ,EAAUD,UAAUmB,eAAiB,SAAStB,GAE5C,IADA,IAAIe,EAAMP,KAAKQ,QACNO,EAAI,EAAGA,EAAIR,EAAIU,OAAQF,IAC1BvB,EAAG0B,KAAKX,EAAIQ,KACdf,KAAKY,OAAOL,EAAIQ,IAGpB,OAAOf,MAeTJ,EAAUD,UAAUwB,OAAS,SAASb,EAAMc,GAE1C,OAAIpB,KAAKC,WACH,IAAuBmB,EACrBA,IAAUpB,KAAKC,KAAKkB,OAAOb,EAAMc,IACnCpB,KAAKC,KAAKkB,OAAOb,GAGnBN,KAAKC,KAAKkB,OAAOb,GAEZN,YAIL,IAAuBoB,EACpBA,EAGHpB,KAAKK,IAAIC,GAFTN,KAAKY,OAAON,GAKVN,KAAKqB,IAAIf,GACXN,KAAKY,OAAON,GAEZN,KAAKK,IAAIC,GAINN,OAUTJ,EAAUD,UAAUa,MAAQ,WAC1B,IAEID,GAFYP,KAAKH,GAAGyB,aAAa,UAAY,IAC7BC,QAAQ,aAAc,IAC5BC,MAAMhC,GAEpB,MADI,KAAOe,EAAI,IAAIA,EAAIkB,QAChBlB,GAWTX,EAAUD,UAAU0B,IACpBzB,EAAUD,UAAU+B,SAAW,SAASpB,GACtC,OAAON,KAAKC,KACRD,KAAKC,KAAKyB,SAASpB,MACfhB,EAAMU,KAAKQ,QAASF","file":"npm.component-classes.c920b4ddeb9b68365139.js","sourcesContent":["/**\n * Module dependencies.\n */\n\ntry {\n var index = require('indexof');\n} catch (err) {\n var index = require('component-indexof');\n}\n\n/**\n * Whitespace regexp.\n */\n\nvar re = /\\s+/;\n\n/**\n * toString reference.\n */\n\nvar toString = Object.prototype.toString;\n\n/**\n * Wrap `el` in a `ClassList`.\n *\n * @param {Element} el\n * @return {ClassList}\n * @api public\n */\n\nmodule.exports = function(el){\n return new ClassList(el);\n};\n\n/**\n * Initialize a new ClassList for `el`.\n *\n * @param {Element} el\n * @api private\n */\n\nfunction ClassList(el) {\n if (!el || !el.nodeType) {\n throw new Error('A DOM element reference is required');\n }\n this.el = el;\n this.list = el.classList;\n}\n\n/**\n * Add class `name` if not already present.\n *\n * @param {String} name\n * @return {ClassList}\n * @api public\n */\n\nClassList.prototype.add = function(name){\n // classList\n if (this.list) {\n this.list.add(name);\n return this;\n }\n\n // fallback\n var arr = this.array();\n var i = index(arr, name);\n if (!~i) arr.push(name);\n this.el.className = arr.join(' ');\n return this;\n};\n\n/**\n * Remove class `name` when present, or\n * pass a regular expression to remove\n * any which match.\n *\n * @param {String|RegExp} name\n * @return {ClassList}\n * @api public\n */\n\nClassList.prototype.remove = function(name){\n if ('[object RegExp]' == toString.call(name)) {\n return this.removeMatching(name);\n }\n\n // classList\n if (this.list) {\n this.list.remove(name);\n return this;\n }\n\n // fallback\n var arr = this.array();\n var i = index(arr, name);\n if (~i) arr.splice(i, 1);\n this.el.className = arr.join(' ');\n return this;\n};\n\n/**\n * Remove all classes matching `re`.\n *\n * @param {RegExp} re\n * @return {ClassList}\n * @api private\n */\n\nClassList.prototype.removeMatching = function(re){\n var arr = this.array();\n for (var i = 0; i < arr.length; i++) {\n if (re.test(arr[i])) {\n this.remove(arr[i]);\n }\n }\n return this;\n};\n\n/**\n * Toggle class `name`, can force state via `force`.\n *\n * For browsers that support classList, but do not support `force` yet,\n * the mistake will be detected and corrected.\n *\n * @param {String} name\n * @param {Boolean} force\n * @return {ClassList}\n * @api public\n */\n\nClassList.prototype.toggle = function(name, force){\n // classList\n if (this.list) {\n if (\"undefined\" !== typeof force) {\n if (force !== this.list.toggle(name, force)) {\n this.list.toggle(name); // toggle again to correct\n }\n } else {\n this.list.toggle(name);\n }\n return this;\n }\n\n // fallback\n if (\"undefined\" !== typeof force) {\n if (!force) {\n this.remove(name);\n } else {\n this.add(name);\n }\n } else {\n if (this.has(name)) {\n this.remove(name);\n } else {\n this.add(name);\n }\n }\n\n return this;\n};\n\n/**\n * Return an array of classes.\n *\n * @return {Array}\n * @api public\n */\n\nClassList.prototype.array = function(){\n var className = this.el.getAttribute('class') || '';\n var str = className.replace(/^\\s+|\\s+$/g, '');\n var arr = str.split(re);\n if ('' === arr[0]) arr.shift();\n return arr;\n};\n\n/**\n * Check if class `name` is present.\n *\n * @param {String} name\n * @return {ClassList}\n * @api public\n */\n\nClassList.prototype.has =\nClassList.prototype.contains = function(name){\n return this.list\n ? this.list.contains(name)\n : !! ~index(this.array(), name);\n};\n"],"sourceRoot":""}