Socket
Socket
Sign inDemoInstall

domtokenlist

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    domtokenlist

Enables support for the DOMTokenList interface in IE8-9, and fixes buggy implementations in newer browsers.


Version published
Maintainers
1
Install size
27.8 kB
Created

Readme

Source

DOMTokenList Polyfill

Enables support for the DOMTokenList interface in IE8-9, and fixes buggy implementations in newer browsers.

npm install domtokenlist
component install Alhadis/DOMTokenList

What this does:

  • Adds seamless, dynamically-updating support for token-lists in IE8-9
  • Fixes inability to add/remove multiple tokens in IE10+ (#920755)
  • Adds support for forced toggling if it's missing (#878564)

This polyfill works at feature-level, meaning it doesn't identify shortcomings based on browser vendor or version (though I'm hoping that's common sense to most developers these days).

Total size

  • 2.27 KBs minified
  • 1.21 KBs minified & gzipped

SVG support

Include svg-fix.js before the main polyfill if you're working with SVG elements. For modularity's sake, I've isolated all SVG-specific fixes to their own file.

Why should I use yours? Others work fine.

They might, but so far, every one I've encountered has issues working with both the classList and className attributes simultaneously.

For example, assume the following scenario:

<!DOCTYPE html>
<html class="bar">

<script>
	var root = document.documentElement;
	var rootClasses = root.classList;

	console.log(rootClasses[0]); // Outputs "bar", as expected

	root.className = "foo " + root.className;

	console.log(rootClasses[0]); // Outputs "bar" instead of "foo"
</script>

This is an edge case, but expecting developers to avoid the .className attribute as well as direct references to token-lists (which might be done for brevity's sake) wasn't enough to satisfy me. I wanted a true, transparent, lightweight and dynamic polyfill for the interface I loved so much.

Keywords

FAQs

Last updated on 02 Feb 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc