question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

reinitialize causes DOMException for missing or moved child node on Chrome Browser

See original GitHub issue

The error occurs, whenever the order config gets updated and is caused by the reinitialize function.

As an error example i point to the project-demo at https://enngage.github.io/ngx-paypal/. Just change the Dollar amount of the order and get this: ERROR DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is no longer a child of this node. Perhaps it was moved in response to a mutation? The error is kind of odd, because it removes the child node as expected, but still throws an error. So as a workaround just catching the error works.

Deps: Angular 11 ngx-paypal 6.2.0

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:3
  • Comments:6

github_iconTop GitHub Comments

5reactions
4lkicommented, Jan 18, 2021

@huntonas Ok, my first hotfix was to alter this:

if (this.payPalButtonContainerElem) {
                while (this.payPalButtonContainerElem.nativeElement.firstChild) {
                    this.payPalButtonContainerElem.nativeElement.removeChild(this.payPalButtonContainerElem.nativeElement.firstChild);
                }
            }

into this :

if (this.payPalButtonContainerElem) {
                try{
                    while (this.payPalButtonContainerElem.nativeElement.firstChild) {
                        this.payPalButtonContainerElem.nativeElement.removeChild(this.payPalButtonContainerElem.nativeElement.firstChild);
                    }
                }catch(e){}
            }

on line 313 of ngx-paypal.js

…but since i didn’t want to fork this repo and maintain my hotfix, i found a template based solution:

By not updating the component config, but recreating it with an ngIf Clause it never calls for reinitialize():

<ngx-paypal ngIf="payPalConfig" (scriptLoaded)="scriptLoaded($event)" [config]="payPalConfig"></ngx-paypal>

then simply set your payPalConfig to undefined first, to clear it from view before updating your payPalConfig.

updateConfig(config:any){
    this.payPalConfig = undefined;
    setTimeout(x => {
      this.paypalConfig = config;
    },200)
  }

Hope this helps

3reactions
daniel-ilancommented, Apr 25, 2021

I am getting the exact same issue, thanks for the solution. This needs to be resolved by the maintainers of this library

Read more comments on GitHub >

github_iconTop Results From Across the Web

Failed to execute 'removeChild' on 'Node' - Stack Overflow
Uncaught NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is no longer a child of this node. Perhaps it...
Read more >
Node.removeChild() - Web APIs - MDN Web Docs
The removeChild() method of the Node interface removes a child node from the DOM and returns the removed node.
Read more >
Changes - HtmlUnit - SourceForge
Use our own simple color class to reduce the java.awt dependencies. rbri. Remove, Element behaviors and HTML components (HTCs) have been removed from...
Read more >
WebDriver - W3C
The browser chrome is a non-normative term to refer to the ... Nodes. The WebDriver protocol consists of communication between: Local end.
Read more >
AccessibilityNodeInfo - Android Developers
Instead, you could traverse all the children to find the node. Or, use AccessibilityService#findFocus(int) for FOCUS_ACCESSIBILITY only since it has no such ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found