Browse Source

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.
pull/2/head
Deathamns 10 years ago
committed by gorhill
parent
commit
03af075a64
  1. 14
      src/js/vapi-client.js

14
src/js/vapi-client.js

@ -197,6 +197,20 @@ if (self.chrome) {
return; 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'); var beforeLoadEvent = document.createEvent('Event');
beforeLoadEvent.initEvent('beforeload'); beforeLoadEvent.initEvent('beforeload');

Loading…
Cancel
Save