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

mutationobserver-shim

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mutationobserver-shim - npm Package Compare versions

Comparing version 0.2.7 to 0.2.8

16

dist/mutationobserver.min.js

@@ -1,9 +0,9 @@

// MutationObserver-Shim v0.2.7 (github.com/megawac/MutationObserver.js)
// mutationobserver-shim v0.2.8 (github.com/megawac/MutationObserver.js)
// Authors: Graeme Yeates (github.com/megawac)
this.MutationObserver=this.MutationObserver||this.WebKitMutationObserver||function(v){function m(b){var a=this;a.g=[];a.k=function(){var c=a.takeRecords();c.length&&b.call(a,c,a);a.f=setTimeout(a.k,m._period)}}function r(b){var a={type:null,target:null,addedNodes:[],removedNodes:[],previousSibling:null,nextSibling:null,attributeName:null,attributeNamespace:null,oldValue:null},c;for(c in b)a[c]!==v&&b[c]!==v&&(a[c]=b[c]);return a}function E(b,a){var c=A(b,a);return function(d){var f=d.length;a.a&&
c.a&&y(d,b,c.a,a.d);(a.c||a.e)&&F(d,b,c,a);d.length!==f&&(c=A(b,a))}}function y(b,a,c,d){for(var f={},u=a.attributes,w,h,n=u.length;n--;)w=u[n],h=w.name,d&&d[h]===v||(w.value!==c[h]&&b.push(r({type:"attributes",target:a,attributeName:h,oldValue:c[h],attributeNamespace:w.namespaceURI})),f[h]=!0);for(h in c)f[h]||b.push(r({target:a,type:"attributes",attributeName:h,oldValue:c[h]}))}function F(b,a,c,d){function f(a,c,n,p,f){var m=a.length-1;f=-~((m-f)/2);for(var g,k,e;e=a.pop();)g=n[e.h],k=p[e.i],d.c&&
f&&Math.abs(e.h-e.i)>=m&&(b.push(r({type:"childList",target:c,addedNodes:[g],removedNodes:[g],nextSibling:g.nextSibling,previousSibling:g.previousSibling})),f--),d.a&&k.a&&y(b,g,k.a,d.d),d.b&&3===g.nodeType&&g.nodeValue!==k.b&&b.push(r({type:"characterData",target:g,oldValue:k.b})),d.e&&u(g,k)}function u(a,c){for(var n=a.childNodes,p=c.c,m=n.length,v=p?p.length:0,g,k,e,l,s,x=0,t=0,q=0;t<m||q<v;)l=n[t],s=(e=p[q])&&e.j,l===s?(d.a&&e.a&&y(b,l,e.a,d.d),d.b&&3===l.nodeType&&l.nodeValue!==e.b&&b.push(r({type:"characterData",
target:l,oldValue:e.b})),k&&f(k,a,n,p,x),d.e&&(l.childNodes.length||e.c&&e.c.length)&&u(l,e),t++,q++):(g||(g={},k=[]),l&&(g[e=B(l)]||(g[e]=!0,-1===(e=z(p,l,q,"j"))?d.c&&(b.push(r({type:"childList",target:a,addedNodes:[l],nextSibling:l.nextSibling,previousSibling:l.previousSibling})),x++):k.push({h:t,i:e})),t++),s&&s!==n[t]&&(g[e=B(s)]||(g[e]=!0,-1===(e=z(n,s,t))?d.c&&(b.push(r({type:"childList",target:c.j,removedNodes:[s],nextSibling:p[q+1],previousSibling:p[q-1]})),x--):k.push({h:e,i:q})),q++));
k&&f(k,a,n,p,x)}u(a,c)}function A(b,a){var c=!0;return function f(b){var m=3===b.nodeType,h={j:b};m||8===b.nodeType?m&&a.b&&(h.b=b.nodeValue):(a.a&&c&&(h.a=C(b.attributes,function(b,c){if(!a.d||a.d[c.name])b[c.name]=c.value;return b})),c&&(a.c||a.b||a.a&&a.e)&&(h.c=G(b.childNodes,f)),c=a.e);return h}(b)}function B(b){try{return b.id||(b.mo_id=b.mo_id||D++)}catch(a){try{return b.nodeValue}catch(c){return D++}}}function G(b,a){for(var c=[],d=0;d<b.length;d++)c[d]=a(b[d],d,b);return c}function C(b,a){for(var c=
{},d=0;d<b.length;d++)c=a(c,b[d],d,b);return c}function z(b,a,c,d){for(;c<b.length;c++)if((d?b[c][d]:b[c])===a)return c;return-1}m._period=30;m.prototype={observe:function(b,a){var c={a:!!(a.attributes||a.attributeFilter||a.attributeOldValue),c:!!a.childList,e:!!a.subtree,b:!(!a.characterData&&!a.characterDataOldValue)},d=this.g,f=z(d,b,0,"m");0<=f&&d.splice(f,1);a.attributeFilter&&(c.d=C(a.attributeFilter,function(a,b){a[b]=!0;return a}));d.push({m:b,l:E(b,c)});this.f||this.k()},takeRecords:function(){for(var b=
[],a=this.g,c=0;c<a.length;c++)a[c].l(b);return b},disconnect:function(){this.g=[];clearTimeout(this.f);this.f=null}};var D=1;return m}();
this.MutationObserver=this.MutationObserver||this.WebKitMutationObserver||function(v){function m(a){this.g=[];this.k=a}function F(a){(function c(){var d=a.takeRecords();d.length&&a.k(d,a);a.f=setTimeout(c,m._period)})()}function r(a){var b={type:null,target:null,addedNodes:[],removedNodes:[],previousSibling:null,nextSibling:null,attributeName:null,attributeNamespace:null,oldValue:null},c;for(c in a)b[c]!==v&&a[c]!==v&&(b[c]=a[c]);return b}function G(a,b){var c=A(a,b);return function(d){var g=d.length;
b.a&&c.a&&z(d,a,c.a,b.d);(b.c||b.e)&&H(d,a,c,b);d.length!==g&&(c=A(a,b))}}function z(a,b,c,d){for(var g={},u=b.attributes,w,h,p=u.length;p--;)w=u[p],h=w.name,d&&d[h]===v||(w.value!==c[h]&&a.push(r({type:"attributes",target:b,attributeName:h,oldValue:c[h],attributeNamespace:w.namespaceURI})),g[h]=!0);for(h in c)g[h]||a.push(r({target:b,type:"attributes",attributeName:h,oldValue:c[h]}))}function H(a,b,c,d){function g(b,c,g,n,x){var m=b.length-1;x=-~((m-x)/2);for(var f,k,e;e=b.pop();)f=g[e.h],k=n[e.i],
d.c&&x&&Math.abs(e.h-e.i)>=m&&(a.push(r({type:"childList",target:c,addedNodes:[f],removedNodes:[f],nextSibling:f.nextSibling,previousSibling:f.previousSibling})),x--),d.a&&k.a&&z(a,f,k.a,d.d),d.b&&3===f.nodeType&&f.nodeValue!==k.b&&a.push(r({type:"characterData",target:f,oldValue:k.b})),d.e&&u(f,k)}function u(b,c){for(var p=b.childNodes,n=c.c,m=p.length,v=n?n.length:0,f,k,e,l,s,y=0,t=0,q=0;t<m||q<v;)l=p[t],s=(e=n[q])&&e.j,l===s?(d.a&&e.a&&z(a,l,e.a,d.d),d.b&&3===l.nodeType&&l.nodeValue!==e.b&&a.push(r({type:"characterData",
target:l,oldValue:e.b})),k&&g(k,b,p,n,y),d.e&&(l.childNodes.length||e.c&&e.c.length)&&u(l,e),t++,q++):(f||(f={},k=[]),l&&(f[e=B(l)]||(f[e]=!0,-1===(e=C(n,l,q,"j"))?d.c&&(a.push(r({type:"childList",target:b,addedNodes:[l],nextSibling:l.nextSibling,previousSibling:l.previousSibling})),y++):k.push({h:t,i:e})),t++),s&&s!==p[t]&&(f[e=B(s)]||(f[e]=!0,-1===(e=C(p,s,t))?d.c&&(a.push(r({type:"childList",target:c.j,removedNodes:[s],nextSibling:n[q+1],previousSibling:n[q-1]})),y--):k.push({h:e,i:q})),q++));
k&&g(k,b,p,n,y)}u(b,c)}function A(a,b){var c=!0;return function g(a){var m=3===a.nodeType,h={j:a};m||8===a.nodeType?m&&b.b&&(h.b=a.nodeValue):(b.a&&c&&(h.a=D(a.attributes,function(a,c){if(!b.d||b.d[c.name])a[c.name]=c.value;return a})),c&&(b.c||b.b||b.a&&b.e)&&(h.c=I(a.childNodes,g)),c=b.e);return h}(a)}function B(a){try{return a.id||(a.mo_id=a.mo_id||E++)}catch(b){try{return a.nodeValue}catch(c){return E++}}}function I(a,b){for(var c=[],d=0;d<a.length;d++)c[d]=b(a[d],d,a);return c}function D(a,b){for(var c=
{},d=0;d<a.length;d++)c=b(c,a[d],d,a);return c}function C(a,b,c,d){for(;c<a.length;c++)if((d?a[c][d]:a[c])===b)return c;return-1}m._period=30;m.prototype={observe:function(a,b){for(var c={a:!!(b.attributes||b.attributeFilter||b.attributeOldValue),c:!!b.childList,e:!!b.subtree,b:!(!b.characterData&&!b.characterDataOldValue)},d=this.g,g=0;g<d.length;g++)d[g].m===a&&d.splice(g,1);b.attributeFilter&&(c.d=D(b.attributeFilter,function(a,b){a[b]=!0;return a}));d.push({m:a,l:G(a,c)});this.f||F(this)},takeRecords:function(){for(var a=
[],b=this.g,c=0;c<b.length;c++)b[c].l(a);return a},disconnect:function(){this.g=[];clearTimeout(this.f);this.f=null}};var E=1;return m}(void 0);

@@ -6,3 +6,3 @@ ###Compiled files

- Original: 23.4 kB
- Minified: 3.3 kB
- Gzipped: 781 bytes
- Minified: 3.4 kB
- Gzipped: 779 bytes

@@ -23,24 +23,30 @@ /*!

function MutationObserver(listener) {
var self = this;
/**
* @type {Array.<function(Array.<MutationRecord>)>}
* @type {Array.<Object>}
* @private
*/
self._watched = [];
/**
* Recursive timeout function to check all observed items for mutations
* @private
*/
self._checker = function() {
var mutations = self.takeRecords();
this._watched = [];
/** @private */
this._listener = listener;
}
/**
* Start a recursive timeout function to check all items being observed for mutations
* @type {MutationObserver} observer
* @private
*/
function startMutationChecker(observer) {
(function check() {
var mutations = observer.takeRecords();
if (mutations.length) { //fire away
listener.call(self, mutations, self); //call is not spec but consistent with other implementations
//calling the listener with context is not spec but currently consistent with FF and WebKit
observer._listener(mutations, observer);
}
/** @private */
self._timeout = setTimeout(self._checker, MutationObserver._period);
};
observer._timeout = setTimeout(check, MutationObserver._period);
})();
}
/**
/**
* Period to check for mutations (~32 times/sec)

@@ -52,3 +58,3 @@ * @type {number}

/**
/**
* Exposed API

@@ -62,4 +68,4 @@ * @expose

* not going to throw here but going to follow the current spec config sets
* @param {Node} $target
* @param {Object} config : MutationObserverInit configuration dictionary
* @param {Node|null} $target
* @param {Object|null} config : MutationObserverInit configuration dictionary
* @expose

@@ -69,3 +75,3 @@ * @return undefined

observe: function($target, config) {
/**
/**
* Using slightly different names so closure can go ham

@@ -108,3 +114,3 @@ * @type {!Object} : A custom mutation config

if (!this._timeout) {
this._checker();
startMutationChecker(this);
}

@@ -144,6 +150,5 @@ },

* @param {Object} data
* @return {MutationRecord}
* @return {Object} a MutationRecord
*/
function MutationRecord(data) {
/** @typedef {MutationRecord} */
var settings = { //technically these should be on proto so hasOwnProperty will return false for non explicitly props

@@ -263,3 +268,3 @@ type: null,

/*
* Helper to identify node rearrangment and stuff...
* Helper to identify node rearrangment and stuff...
* There is no gaurentee that the same node will be identified for both added and removed nodes

@@ -338,3 +343,3 @@ * if the positions have been shuffled.

var numAddedNodes = 0;
//iterate over both old and current child nodes at the same time

@@ -439,3 +444,3 @@ var i = 0, j = 0;

* Cones a element into a custom data structure designed for comparision. https://gist.github.com/megawac/8201012
*
*
* @param {Node} $target

@@ -479,3 +484,3 @@ * @param {!Object} config : A custom mutation config

}
recurse = config.descendents;

@@ -490,3 +495,3 @@ }

*
* @param {Node} set
* @param {NodeList} set
* @param {!Object} $node : A custom cloned node

@@ -538,3 +543,3 @@ * @param {number} idx : index to start the loop

* **Reduce** builds up a single result from a list of values
* @param {Array|NodeList} set
* @param {Array|NodeList|NamedNodeMap} set
* @param {Function} iterator

@@ -579,2 +584,2 @@ * @param {*} [memo] Initial value of the memo.

return MutationObserver;
})();
})(void 0);

@@ -5,3 +5,3 @@ {

"description": "MutationObserver shim for ES3 environments",
"version": "0.2.7",
"version": "0.2.8",
"keywords": [

@@ -38,14 +38,14 @@ "DOM",

"devDependencies": {
"phantomjs": "1.9.x",
"grunt": "~0.4.2",
"grunt-bumpup": "~0.5.0",
"grunt-closurecompiler": "0.9",
"grunt-contrib-connect": "0.7",
"grunt-contrib-jshint": ">= 0.8",
"grunt-contrib-qunit": "~0.5.0",
"grunt-file-info": "1.0.4",
"grunt-saucelabs": "4.1.x",
"grunt-contrib-jshint": ">= 0.8",
"grunt-contrib-qunit": "0.3.x",
"grunt-contrib-connect": "0.7",
"grunt-closurecompiler": "0.9",
"grunt-file-info": "~1.0.4",
"grunt-bumpup": "~0.5.0",
"grunt-tagrelease": "~0.3.1",
"matchdep": "~0.3.0"
"matchdep": "~0.3.0",
"phantomjs": "1.9.x"
}
}
}
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