Modern DOM functionalities for every browser
A fully tested and covered polyfill for new DOM Level 4 entries
Many thanks to cdnjs for hosting this script. Following an example on how to include it.
<script
src="//cdnjs.cloudflare.com/ajax/libs/dom4/2.0.0/dom4.js"
>/* DOM4 */</script>
Both query
and queryAll
have been removed, while CSS :scope
selector has been added.
This is a fully tested and covered polyfill for both new DOM Level 4 parentNode entries:
And for new DOM Level 4 childNode entries:
The implemented test is conform to current specifications.
Other fixes/standardized behaviors include:
KeyboardEvent
, MouseEvent
and the latest way to create new Event('type')
:scope
selector for any HTML Element (no document
since useless, sorry)requestAnimationFrame
and cancelAnimationFrame
are polyfilled too but the least legacy fallback to setTimeout does not support accurate timing and doesn't slow down execution with that logic. Feel free to load upfront other polyfills if needed.If you need other polyfills too, have a look at another DOM-shim repo.
Theoretically compatible with all browsers you know that are truly used these days, here a list:
It's way easier if you tell me which browser in a current relevant market share is not supported :-)
For IE8 only it's recommended to include ie8 script before dom4
or CustomEvent
, addEventListener
, and dispatchEvent
won't work as expected.
The minified version is here, while the max one here. If you want to test directly try this page, it should be green.
If you found a bug, want to contribute or have any questions feel free to fill an issue or pull request, and help us to improve the Dom4
Dom4 Code released under the MIT license.