Complete and well-tested shims / polyfills for various DOM API's missing in not-so-modern browsers.
npm install --save dom-shims
Apply all the shims by requiring the module without assignment:
require('dom-shims');
Or apply specific shims:
require('dom-shims/shim/CustomEvent');
require('dom-shims/shim/Element.classList');
require('dom-shims/shim/Element.matches');
- CustomEvent constructor
- Element#classList[1]
- Element#length
- Element#add(tokens...)
- Element#contains(token)
- Element#item(token)
- Element#remove(tokens...)
- Element#toggle(token, force)
- Element#closest
- Element#matches[2]
NOTES:
-
Ensures all browsers have
classList
support for SVG elements, multiple-argument support foradd
andremove
,force
-argument support fortoggle
, and correctlength
anditem
values even when theclass
value is mutated by means other thanclassList
. -
Patches IE 9's implementation, which lacks support for Elements not attached to the
document
.
DOM Level 4 mutation macros for:
- Element#append()
- Element#prepend()
- Element#after()
- Element#before()
- Element#remove()
- Element#replace()
Intended support for:
- Chrome
- Firefox
- IE9+
- Safari 6+
- Android 4+
- Safari iOS 5.1+
- Opera
Thanks to the following libraries for inspiration, ideas, and workarounds: