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

onnodesinserted

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

onnodesinserted

Listen to node inserted events

  • 0.8.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

onNodesInserted

Get notified when DOM node is inserted. Browser support: Any that supports document.querySelectorAll

onNodesInserted attempts to use animationStart event, but falls back to setTimeout in older browsers.

Example

// onNodesInserted takes 10ms to start. It avoids getting elements on initial load
onNodesInserted('.hello', function(newElements) {
	console.log(newElements); // [div]
});

// wait 100ms, so onNodesInserted is listening
setTimeout(function() {
	document.creatElement('div');
	div.className = 'hello';
	document.body.appendChild(div);
}, 100);

API

// Listen to nodes inserted. CSS_SELECTOR must be 2.1 to support IE8
// Callback gets passed an array of HTMLElements
onNodesInserted(<CSS_SELECTOR>,<CALLBACK>);

// For older browsers, onNodesInserted polls for new DOM elements. Set the poll time. By default it's 400ms.
onNodesInserted.setPollTime(<POLL_TIME>);

Keywords

FAQs

Package last updated on 12 Jul 2014

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc