Skip to content

Commit 1a58e2e

Browse files
authored
[3.10] Fix calendar error in IE11 (#35819)
* Fix calendar error in IE11 * calendar fix
1 parent 1d15ec9 commit 1a58e2e

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

media/system/js/fields/calendar.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,21 @@
2727
return str;
2828
};
2929

30+
// CustomEvent polyfill for IE
31+
(function () {
32+
33+
if ( typeof window.CustomEvent === "function" ) return false;
34+
35+
function CustomEvent ( event, params ) {
36+
params = params || { bubbles: false, cancelable: false, detail: undefined };
37+
var evt = document.createEvent('CustomEvent');
38+
evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail );
39+
return evt;
40+
}
41+
42+
window.CustomEvent = CustomEvent;
43+
})();
44+
3045
var JoomlaCalendar = function (element) {
3146

3247
// Initialize only if the element exists
@@ -238,7 +253,7 @@
238253
this.params.onUpdate(this);
239254
}
240255

241-
this.inputField.dispatchEvent(new Event('change', {bubbles: true, cancelable: true}));
256+
this.inputField.dispatchEvent(new CustomEvent('change', {bubbles: true, cancelable: true}));
242257

243258
if (this.dateClicked) {
244259
this.close();
@@ -796,7 +811,7 @@
796811
self.inputField.setAttribute('data-alt-value', "0000-00-00 00:00:00");
797812
self.inputField.setAttribute('value', '');
798813
self.inputField.value = '';
799-
self.inputField.dispatchEvent(new Event('change', {bubbles: true, cancelable: true}));
814+
self.inputField.dispatchEvent(new CustomEvent('change', {bubbles: true, cancelable: true}));
800815
});
801816

802817
if (this.params.showsTodayBtn) {

0 commit comments

Comments
 (0)