AzureAD / azure-activedirectory-library-for-js

The code for ADAL.js and ADAL Angular has been moved to the MSAL.js repo. Please open any issues or PRs at the link below.
https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/maintenance/adal-angular
Apache License 2.0
627 stars 374 forks source link

Library does not work on Win 8.0 + IE10 because of "use strict" check SCRIPT1047 #801

Closed diegodorazio closed 4 years ago

diegodorazio commented 6 years ago

When including adal-angular.js on IE10 on Win 8.0, the browser issues a javascript error and fails to load the js file.

The error is: SCRIPT1047: In strict mode, function declarations cannot be nested inside a statement or block. They may only appear at the top level or directly inside a function body.

The offending bit of code (which was introduced in v1.0.16) is the following:

               if ($injector.has('$transitions')) {
                    var $transitions = $injector.get('$transitions');

                    function onStartStateChangeHandler(transition) {
                        stateChangeHandler(null, transition.to(), transition.params('to'), transition.from(), transition.params('from'));
                    }

                    function onErrorStateChangeHandler(transition) {
                        stateChangeErrorHandler(null, transition.to(), transition.params('to'), transition.from(), transition.params('from'), transition.error());
                    }

                    $transitions.onStart({}, onStartStateChangeHandler);
                    $transitions.onError({}, onErrorStateChangeHandler);
                }

The 2 functions onStartStateChangeHandler and onErrorStateChangeHandler use a function declaration inside a code block, and this is not accepted by IE10 on Win 8.0 (see SCRIPT1047 error message above)

It would be quite simple to fix: just change those 2 functions from function declaration to function expression,, e.g.:

var onStartStateChangeHandler = function (transition) { ... }
var onErrorStateChangeHandler = function (transition) { ... }
bobboteck commented 6 years ago

I also had the same problem and solved the same way. The error tells me visual studio when I start debugging. The test is done with Visual Studio 2015, Windows Server 2012 and IE11.

m4m4m4 commented 5 years ago

This also affects UglifyJS which throws an error

jmckennon commented 4 years ago

All current authentication work from Microsoft is delivered through the msal js library here. adal js is still supported only for security fixes. We recommend moving to msal js for any advanced feature requests and bugfixes.