fbpx Skip to content

Aquent | DEV6

Multiple Definitions of a Property Not Allowed in Strict Mode

Written by: Chad Upton

Although we do a lot of automated testing and even have a sizeable team of real people doing manual testing, some issues still get through. That’s why we also employ a live error catching script in our Angular applications. We used to use Airbrake although we’ve come to prefer Bugsnag.

When our AngularJS application encounters a javascript error, the Bugsnag code catches the error and sends us a notification. Then we can login to Bugsnag and look at the stacktrace and other details about the error to try and recreate it and then fix it. In many cases, we’re able to fix bugs before users even report them!

One of the most prolific javascript errors/warnings that I’ve ever seen is this one, “Multiple definitions of a property not allowed in strict mode”. The funny thing is that it only occurs in Internet Explorer (nearly every version). I suspect you’re reading this because you’re trying to solve the same issue. I tracked this error down to a line in our code similar to this:

<button name="Play" ng-class="{'disabled': songSelected === false,'disabled': browserSupported === false}" ... >

Basically, if there’s no song selected or the browser is not supported then the play button will be disabled. This works great in Chrome, Firefox, and Safari, but IE throws a warning about it. Unfortunately, IE believes that Angular is creating duplicate properties under the hood. Strict mode doesn’t allow duplicate properties, so the browser throws an error. I examined the Angular source code and couldn’t find where that would be true, but it’s possibly a bug in IE since none of the other browsers report it as an issue. So, how do you make IE happy? Change it to this:

<button name="Play" ng-class="{'disabled': songSelected === false,'disabled': browserSupported === false}" ... >

If you need to augment your development team with more great full stack developers, or you’d like some training for your developers then give us a shout because we’re happy to help!