polyfills.compat.classList.meta.json Maven / Gradle / Ivy
The newest version!
{"browsers":{"ie":"6 - 11","ie_mob":"10 - *","safari":"4 - 4.1"},"dependencies":["Object.defineProperty"],"repo":"http://purl.eligrey.com/github/classList.js","license":"https://github.com/eligrey/classList.js/blob/master/LICENSE.md","spec":"https://html.spec.whatwg.org/multipage/dom.html#dom-classlist","docs":"https://developer.mozilla.org/en-US/docs/Web/API/Element/classList","detectSource":"'classList' in document.createElement('_') && document.createElementNS && 'classList' in document.createElementNS('http://www.w3.org/2000/svg', 'g')","testSource":"","baseDir":"compat/classList","hasTests":true,"testsSource":"/* eslint-env mocha, browser*/\n/* global proclaim, it */\n\nit(\"Should be able to add a class using #toggle\", function() {\n\tvar el = document.createElement(\"p\");\n\tvar classList = el.classList;\n\tclassList.toggle(\"classA\");\n\tproclaim.equal(classList.contains(\"classA\"), true);\n});\n\nit(\"Should be able to remove a class using #toggle and return false when indicating class is removed\", function() {\n\tvar el = document.createElement(\"p\");\n\tvar classList = el.classList;\n\tel.className = \"classA\";\n\n\tproclaim.equal(classList.toggle(\"classA\"), false);\n\tproclaim.equal(classList.contains(\"classA\"), false);\n});\n\nit(\"Should allow classes to be added using #add\", function() {\n\tvar el = document.createElement(\"p\");\n\tvar classList = el.classList;\n\n\tclassList.add(\"classA\");\n\tproclaim.equal(classList.contains(\"classA\"), true);\n});\n\nit(\"Should force add a class using toggle if the second argument is true\", function() {\n\tvar el = document.createElement(\"p\");\n\tvar classList = el.classList;\n\tclassList.add(\"classA\");\n\tclassList.toggle(\"classA\", true);\n\tproclaim.equal(classList.contains(\"classA\"), true);\n});\n\nit(\"Should be indexable\", function() {\n\tvar el = document.createElement(\"p\");\n\tvar classList = el.classList;\n\tel.className = \"a b\";\n\n\t// for old ie\n\tclassList.toString();\n\n\tproclaim.equal(classList[0], 'a');\n\tproclaim.equal(classList[1], 'b');\n});\n\nit(\"Should be indexable using the #item method\", function() {\n\tvar el = document.createElement(\"p\");\n\tvar classList = el.classList;\n\tel.className = \"a b\";\n\n\t// for old ie\n\tclassList.toString();\n\n\tproclaim.equal(classList.item(0), 'a');\n\tproclaim.equal(classList.item(1), 'b');\n});\n\nit(\"Should return the length using the #length method\", function() {\n\tvar el = document.createElement(\"p\");\n\tvar classList = el.classList;\n\tel.className = \"a b\";\n\n\t// for old ie\n\tclassList.toString();\n\n\tproclaim.equal(classList.length, 2);\n});\n\nit(\"Should remove duplicate instances of class\", function() {\n\tvar el = document.createElement(\"p\");\n\tvar classList = el.classList;\n\tel.className = \"a a a\";\n\n\tclassList.remove(\"a\");\n\tproclaim.equal(classList.contains(\"a\"), false);\n\tproclaim.equal(el.className, \"\");\n});\n\nit(\"Should work on svg elements\", function() {\n\tif (!!document.createElementNS && !!document.createElementNS('http://www.w3.org/2000/svg', 'svg')) {\n\t\tvar el = document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\");\n\t\tvar classList = el.classList;\n\t\tel.setAttribute('class', 'a');\n\n\t\tclassList.add(\"b\");\n\t\tproclaim.equal(classList.contains(\"b\"), true);\n\t\tproclaim.equal(el.className.baseVal, \"a b\");\n\t}\n});\n\nit(\"Should be configurable\", function() {\n\tproclaim.equal(Object.getOwnPropertyDescriptor(Element.prototype, 'classList').configurable, true);\n});"}