Skip to content
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

IE11 "Object doesn't support this action" when using new CustomEvent #276

Closed
Booster2ooo opened this issue Aug 20, 2018 · 2 comments
Closed

Comments

@Booster2ooo
Copy link

Hello,

When using the application in IE11, OidcSecurityService.setupModule fails with the error "Object doesn't support this action". This error is caused by the following snippet:

window.dispatchEvent(
    new CustomEvent('oidc-silent-renew-init', {
        detail: instanceId,
    })
);

oidc.security.service.ts#L167

For IE versions >= 9, custom events must be created using document.createEvent() then initialized using the initCustomEvent method of the previously created event, something approaching:

const customEvent = document.createEvent("CustomEvent");
customEvent.initCustomEvent('oidc-silent-renew-init', false, false,{
    detail: instanceId,
});

An alternative would be to use a polyfill.

(function () {
  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;
   }

  CustomEvent.prototype = window.Event.prototype;

  window.CustomEvent = CustomEvent;
})();

Those are anwers were found on StackOverflow.

Best regards

@damienbod
Copy link
Owner

closing this, please re-open is required

@jfhector
Copy link

Thanks @Booster2ooo for this clear explanation. I've been struggling with a similar issue in my repo. I've come across your post and the fix worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants