Swar Chaa
Swar Chaa

Reputation: 1

Getting error as ERROR TypeError: Argument not optional in IE 11

The below code works in all other browsers ,except IE11 in IE it throws the following error as "ERROR TypeError: Argument not optional" and the project is being developed in Angular 10

 private togglePageClass(mode: boolean) {
    if (mode) {
      document.getElementById('templateHolder')['classList'].add(...this.pageClass);
    } else {
      document.getElementById('templateHolder')['classList'].remove(...this.pageClass);
    }
  }

and the page class value is being set as follows

 let Mode: string = this.pageLayout['settings']['mode'].split('-')[1];
    if (this.pageLayout['template'] === 'landing_page') {
      this.pageClass = [this.pageLayout['settings']['id'], 'page-landing'];
    } else if (this.getConfig('configSettings')['100'] === 'on') {
      if (this.pageLayout['settings']['mode'] === 'abc') {
        this.pageClass = [this.pageLayout['settings']['id'], 'page-' + this.pageLayout['template'], Mode, 'a'];
      } else if (this.pageLayout['settings']['mode'] === 'xyz') {
        this.pageClass = [this.pageLayout['settings']['id'], 'page-' + this.pageLayout['template'], Mode, 'b'];
      } else {
        this.pageClass = [this.pageLayout['settings']['id'], 'page-' + this.pageLayout['template'], Mode];
      }
    } else {
      this.pageClass = [this.pageLayout['settings']['id'], 'page-' + this.pageLayout['template'], Mode];
    }

and I have made all the necessary changes in angular json and related files as per angular.io guidelines to enable running an app in ie 11

Upvotes: 0

Views: 409

Answers (1)

Dinesh N
Dinesh N

Reputation: 21

I also faced this issue in IE11 for the md-checkbox in angular-material. I changed fixed the issue by doing the below change. This is coming from document.createTreeWalker(element, NodeFilter.SHOW_TEXT, null) this method and I added false as 4th param that is fixed my error.

Upvotes: 2

Related Questions