
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
lifecycle-events
Advanced tools
Enable lifecycle events for HTML elements: attached
, detached
.
$ npm install lifecycle-events
var lifecycleEvents = require('lifecycle-events');
//enable lifecycle events for all elements on the page
lifecycleEvents.enable();
$('.my-element').on('attached', function(){});
$('.my-other-element').on('detached', function(){});
//Disable all lifecycle events
lifecycleEvents.disable();
//Enable lifecycle events for a Node/NodeList
lifecycleEvents.enable(element);
element.addEventListener('attached', function(){});
element.addEventListener('detached', function(){});
//Disable lifecycle events for the previously added element/selector
lifecycleEvents.disable(element);
To make it work in IE and old browsers, you may need to polyfill MutationObserver
, WeakMap
, WeakSet
, Element.matches
, Element.contains
: //cdn.polyfill.io/v1/polyfill.min.js?features=default,WeakMap,WeakSet.
Enable lifecycle events for an Element, NodeList or selector. If no selector specified, '*'
is used. An optional container element/selector may be specified in speed purpose.
Disable lifecycle events for previously registered selector. If no selector specified, all lifecycle events are unbound.
Callback name used for attaching lifecycle event. attached
is used by default. Synomim: DOMNodeInserted
.
Callback name used for detaching lifecycle event. detached
is used by default.Synomim: DOMNodeRemoved
.
Also see viewport-events for enteredView
and leftView
events.
FAQs
Enable lifecycle events for DOM-elements: attached, detached
We found that lifecycle-events demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
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.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.