Home > database >  Uncaught TypeError: Cannot read properties of null (reading 'className')
Uncaught TypeError: Cannot read properties of null (reading 'className')

Time:01-25

I have updated the jQuery version in the application and I am getting an error in the DatePickerComponent with jQuery 3.5.0.here i am getting error on .ClassName; i don't know what to do about it

...
else {
    if (myOwnFormat == 'HH:mm:ss' || myOwnFormat == 'HH:mm') {
        var className = document.getElementById("icon_"   pickerId).className;
        $("#icon_"   pickerId).removeClass(className).addClass("alarm_clock");
    }
    return myOwnFormat;
}

enter image description here

enter image description here

CodePudding user response:

document.getElementById("icon_" pickerId) is returning null and you are trying to get .className from null. This should fix your error.

else {
  if (myOwnFormat == 'HH:mm:ss' || myOwnFormat == 'HH:mm') {
    if(document.getElementById("icon_"   pickerId)) {
       var className = document.getElementById("icon_"   pickerId).className;
       $("#icon_"   pickerId).removeClass(className).addClass("hcm-grid_calar_saat");
    }
  }
  return myOwnFormat;
}

CodePudding user response:

As part of increasing the Security features as part of Spring 22 Release, Salesforce has moved few components to Private API. resulting which this error is being popped-up. Unfortunately this was not mentioned in the release notes, but you can find it in the console with "sfdc-lightning/charts/vbar.js has been deprecated. Please update your code to use lightning-vbar-chart".

The workaround would be using the standard 'Report Chart' component in lightning page.

  •  Tags:  
  • Related