1
0
Fork 0
mirror of https://github.com/gorhill/uMatrix.git synced 2024-06-28 11:00:38 +12:00

Move MutationObserver shim

Since it will be used only for older Safari versions, move it to Safari
related code, so it doesn't pollute the content scripts.
This commit is contained in:
Deathamns 2014-11-11 17:14:54 +01:00 committed by gorhill
parent ef30ab4c2d
commit 03af075a64

View file

@ -197,6 +197,20 @@ if (self.chrome) {
return;
}
window.MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
if (!window.MutationObserver) {
// dummy, minimalistic shim for older versions (<6)
// only supports node insertions, but currently we don't use it for anything else
window.MutationObserver = function(handler) {
this.observe = function(target) {
target.addEventListener('DOMNodeInserted', function(e) {
handler([{addedNodes: [e.target]}]);
}, true);
};
}
}
var beforeLoadEvent = document.createEvent('Event');
beforeLoadEvent.initEvent('beforeload');