Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

159
Views
Failed to execute 'createNodeIterator' on 'Document': parameter 1 is not of type 'Node'. - lwc

I'm working with lightning web components (lwc) from Salesforce.

I'm trying to load this library as Static Resource to use it in one of my components, in order to sanitize some data -> DOMPurify . I'm using just the min js file.

import { loadStyle, loadScript } from 'lightning/platformResourceLoader';
import DOMPURIFY from '@salesforce/resourceUrl/DOMPurifyMin'

export default class classNameHere extends LightningElement {

DOMPurifyInitialized = false

renderedCallback() {
        if (this.DOMPurifyInitialized) {
            return;
        }
        this.DOMPurifyInitialized = true;
        Promise.all([
            loadScript(this, DOMPURIFY)
        ])
            .then(() => {
                this.initDOMPurify()
            })
            .catch((error) => {
                this.dispatchEvent(
                    new ShowToastEvent({
                        title: 'Error loading this',
                        message: error.message,
                        variant: 'error'
                    })
                );
            });
    }

    initDOMPurify() {
        console.log('inside initDom')
        console.log(DOMPurify.sanitize(`<img src=x onerror=alert(1)//>`))
    }

}

I can reach initDOMPurify, but then it fails in that second console.log() that uses DOMPurify.

Error message in catch block: Failed to execute 'createNodeIterator' on 'Document': parameter 1 is not of type 'Node'.

Any ideas? I haven't found much information about this kind of error.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!