Skip to content

myrne/dom-mutation-notifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dom-mutation-notifier Build Status Dependency Status

Friendly interface for MutationObserver. Eight events are implemented: (element|attribute|text|comment)(Added|Removed)

The constructor takes the same arguments as the observe method of MutationObserver. If no options are provided, childList will be watched by default.

MutationNotifier will only start observing when a valid event listener is added (with on). It will stop observing if all listeners have been removed (with off).

Usage

var MutationNotifier = require("dom-mutation-notifier")

var notifier = new MutationNotifier(document.querySelector("body"))
var addListener = function(element) {}
var rmListener = function(element) {}
notifier.on("elementAdded", addListener)
// Observing starts
notifier.on("elementRemoved", rmListener)
notifier.off("elementAdded", addListener)
notifier.off("elementRemoved", rmListener)
// Observing ends

License

dom-mutation-notifier is released under the MIT License. Copyright (c) 2017 Braveg1rl

About

Friendly interface for MutationObserver.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published