Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nodelist-foreach-polyfill

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nodelist-foreach-polyfill - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

6

CHANGELOG.md

@@ -7,2 +7,6 @@ ## 1.0.0

- changed to use [MDN's polyfill](https://developer.mozilla.org/en-US/docs/Web/API/NodeList/forEach)
- changed to use [MDN's polyfill](https://developer.mozilla.org/en-US/docs/Web/API/NodeList/forEach#Polyfill)
## 1.2.0
- updated to the latest [MDN's polyfill](https://developer.mozilla.org/en-US/docs/Web/API/NodeList/forEach#Polyfill) (thanks [christiansany](https://github.com/christiansany))

6

index.js
if (window.NodeList && !NodeList.prototype.forEach) {
NodeList.prototype.forEach = function (callback, argument) {
argument = argument || window;
NodeList.prototype.forEach = function (callback, thisArg) {
thisArg = thisArg || window;
for (var i = 0; i < this.length; i++) {
callback.call(argument, this[i], i, this);
callback.call(thisArg, this[i], i, this);
}
};
}

@@ -0,0 +0,0 @@ ISC License

{
"name": "nodelist-foreach-polyfill",
"version": "1.1.0",
"version": "1.2.0",
"description": "Simple polyfill for the NodeList.forEach method.",

@@ -14,2 +14,8 @@ "main": "index.js",

"author": "Jared Williams (imagitama)",
"keywords": [
"IE11",
"NodeList",
"forEach",
"polyfill"
],
"license": "ISC",

@@ -16,0 +22,0 @@ "bugs": {

# NodeList.forEach polyfill
MDN polyfill for the `NodeList.forEach` method.
Provides a polyfill for [Nodelist.prototype.forEach()](https://developer.mozilla.org/en-US/docs/Web/API/NodeList/forEach) to all Browsers supporting [ES5](https://caniuse.com/#search=es5).
It polyfills `forEach` support for `NodeList` objects (a common result of `document.querySelectorAll`).
## Native support
Chrome 51, Firefox 50, Opera 38, Safari 10
Chrome 51, Firefox 50, Opera 38, Safari 10
Android Browser none, IE Mobile none, IE none
See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/NodeList/forEach) for more information.
Android Browser none, IE Mobile none, IE none
## Import
See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/NodeList/forEach)
```JavaScript
// CommonJS
require('nodelist-foreach-polyfill');
// ES6 Modules import / Typescript import
import 'nodelist-foreach-polyfill';
```
## Usage
Import before any usages of `document.querySelectorAll("#foo").forEach((elem) => { ... })` etc.
```JavaScript
// Get Nodelist from DOM via document.querySelectorAll()
var elements = document.querySelectorAll('.foo');
// Loop through nodelist
elements.forEach(function(element, index, nodelist) {
console.log(this, element, index, nodelist);
});
```
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc