-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IE 11 Compatibility #74
Comments
@jtitley , can you instruct me where the code to put? or can you give me changed file so that i can use into my project, btw thanks for your work. |
I've forked a copy here: Just copy getdtl-select.js I'll leave it up to the owner to determine if this gets folded into this version. I don't quite understand how the author generated the .min versions so I've left them alone. |
@jtitley Thanks , i used that working fine. |
@jtitley, great work! Many thanks |
@jtitley - I am facing the foreach issue when i used the getdtl-select.js in IE11(EDGE). What is the alternate solutions |
May I suggest some changes to support IE 11? I was finally able to achieve it and have all functionality working with the following changes. Since you know the code I think you can avoid this complex fix by avoiding some incompatible functions like ForEach and new Event.
In getmdl-select.js add the following function to replace new Event()
// For IE Compatibility
// source: https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent
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;
}
Where you use new Event, do the following:
var event;
try { event = new Event('closeSelect');} catch(err) {}
if (event == undefined) {
event = window.CustomEvent('closeSelect');
}
To support NodeList ForEach I added this in whenLoaded()
// source: https://developer.mozilla.org/en-US/docs/Web/API/NodeList/forEach
if (window.NodeList && !NodeList.prototype.forEach) {
NodeList.prototype.forEach = function (callback, thisArg) {
thisArg = thisArg || window;
for (var i = 0; i < this.length; i++) {
callback.call(thisArg, this[i], i, this);
}
};
}
The text was updated successfully, but these errors were encountered: