I am using LWC framework to develop the component. It's built on ES6 Standard. I am trying to use XSLTProcessor for one of my requirements but it's giving me an error.
Failed to construct 'XSLTProcessor': Please use the 'new' operator, this DOM object constructor cannot be called as a function.
Code:
import { LightningElement } from 'lwc';
export default class DisplayReport extends LightningElement {
handleOnClick(){
if(window.XSLTProcessor){
console.log('XSLTProcessor TRUE')// Working
try
{
var xsltProcessor = new window.XSLTProcessor();
console.log('XSLTProcessor WORKING') // Not coming here
}
catch(e){
console.log(e.message); //Error displayed
}
}
if(window.DOMParser){
console.log('DOMParser TRUE')
try
{
var parser = new window.DOMParser();
console.log('DOMParser WORKING') //This is working
}
catch(e){
console.log(e.message); //No Errors
}
}
}
}
I am not sure why XSLTProcessor
is not working but DOMParser
is working.