Previously in this blog series I have discussed a few Internet Explorer 9 (IE9) quirks, including form submission and Bootstrap accordions. This time I’ll be addressing a different problem child: Internet Explorer 11 (IE11).
Recently I came across an issue where my application was not instantiating one of my JavaScript controllers. I couldn’t for the life of me figure out why it wasn’t. It worked in Chrome, Firefox, and even IE9! Only IE11 was having issues.
It turned out that the controller in question had an object with a duplicate key. This error was caused because we were using strict mode in our code, and it’s a good example of why it’s best practice to use a linter to catch silly mistakes.
Once I removed the duplicate, the controller was instantiated in IE11 and all was well.
Before:
var params = {
status: 'DRAFT',
file: filename,
username: 'Kelleigh',
status: 'DRAFT'
};
After:
var params = {
status: 'DRAFT',
file: filename,
username: 'Kelleigh'
};
“ECMAScript 5‘s strict mode is a way to opt in to a restricted variant of JavaScript. Strict mode isn’t just a subset: it intentionally has different semantics from normal code… Strict mode makes several changes to normal JavaScript semantics. First, strict mode eliminates some JavaScript silent errors by changing them to throw errors. Second, strict mode fixes mistakes that make it difficult for JavaScript engines to perform optimizations… Third, strict mode prohibits some syntax likely to be defined in future versions of ECMAScript.” – MDN’s Strict Mode Documentation
You can see Microsoft’s documentation about strict mode in Internet Explorer here. Strict mode was not supported until IE10. Their documentation lists several other scenarios that can cause the same issue of a controller not being instantiated, including duplicate parameters in functions, using variables that have not been declared, and more.
Stay tuned for more Internet Explorer quirks.
Resources/Further Reading:
Contact Us
Ready to achieve your vision? We're here to help.
We'd love to start a conversation. Fill out the form and we'll connect you with the right person.
Searching for a new career?
View job openings