Comparing version 3.0.0 to 3.1.0
16
index.js
@@ -11,3 +11,3 @@ /* global MutationObserver */ | ||
var observer = new MutationObserver(function (mutations) { | ||
if (watch.length < 1) return | ||
if (Object.keys(watch).length < 1) return | ||
for (var i = 0; i < mutations.length; i++) { | ||
@@ -40,5 +40,5 @@ if (mutations[i].attributeName === KEY_ATTR) { | ||
function turnon (index) { | ||
function turnon (index, el) { | ||
if (watch[index][0] && watch[index][2] === 0) { | ||
watch[index][0]() | ||
watch[index][0](el) | ||
watch[index][2] = 1 | ||
@@ -48,5 +48,5 @@ } | ||
function turnoff (index) { | ||
function turnoff (index, el) { | ||
if (watch[index][1] && watch[index][2] === 1) { | ||
watch[index][1]() | ||
watch[index][1](el) | ||
watch[index][2] = 0 | ||
@@ -67,6 +67,6 @@ } | ||
if (mutation.oldValue === k) { | ||
off(k) | ||
off(k, mutation.target) | ||
} | ||
if (newValue === k) { | ||
on(k) | ||
on(k, mutation.target) | ||
} | ||
@@ -87,3 +87,3 @@ }) | ||
if (onloadid === k) { | ||
fn(k) | ||
fn(k, nodes[i]) | ||
} | ||
@@ -90,0 +90,0 @@ }) |
{ | ||
"name": "on-load", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "On load/unload events for DOM elements using a MutationObserver", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -16,5 +16,5 @@ # on-load | ||
var div = document.createElement('div') | ||
onload(div, function () { | ||
onload(div, function (el) { | ||
console.log('in the dom') | ||
}, function () { | ||
}, function (el) { | ||
console.log('out of the dom') | ||
@@ -21,0 +21,0 @@ }) |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
4493
0