Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

add CustomEvent polyfill, replace new event.constructor with CustomEvent

Ed Plato0bbd62223f24
diff --git a/web/js/natural-events/markers.js b/web/js/natural-events/markers.js
index e3ebbe374..9cdcbaa81 100644
--- a/web/js/natural-events/markers.js
+++ b/web/js/natural-events/markers.js
@@ -167,7 +167,7 @@ export default function markers (models, ui) {
var passEventToTarget = function (event, target) {
try {
- var eventCopy = new event.constructor(event.type, event);
+ var eventCopy = new CustomEvent(event.type, event);
target.dispatchEvent(eventCopy);
} catch (err) {
console.log(err);
diff --git a/web/js/polyfill.js b/web/js/polyfill.js
index bca6fdd38..502cd9510 100644
--- a/web/js/polyfill.js
+++ b/web/js/polyfill.js
@@ -163,6 +163,28 @@ export function polyfill () {
})();
}
+ /*
+ * CustomEvent()
+ *
+ * https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent
+ */
+ if (typeof window.CustomEvent !== 'function') {
+ (function () {
+ function CustomEvent(event, params) {
+ params = params || {
+ bubbles: false,
+ cancelable: false,
+ detail: undefined
+ };
+ var evt = document.createEvent('CustomEvent');
+ evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
+ return evt;
+ }
+ CustomEvent.prototype = window.Event.prototype;
+ window.CustomEvent = CustomEvent;
+ })();
+ }
+
/*
* Mobile device quirks. This section is mostly overwriting things that jquery.mobile is adding
*/