Google Maps Cannot Be Used In Lightning Web Components

Recently I was tasked with investigating which 3rd-party mapping solutions can be used within Salesforce lightning web components. And boy-oh-boy is there a lot of misinformation out there. Especially on the topic of using Google Maps within LWCs. I’ll start by saying this: you cannot use Google Maps in LWCs (Visualforce is still an option though). The odd thing is that several, high-ranking (in Google Search) blogs say you can. Some even have code samples! I have a theory on why this is the case. If you ask the most used AI tools out there many will declare that you can indeed use Google Maps within LWCs. And I suspect that bloggers who didn’t know better ran with this answer and started generating content and code from those AI tools. Once again, you cannot do this. There is no secret tag you can include in the markup. No, you cannot …

Read more

Salesforce LWC: “Error: Failed to execute ‘removeChild’ on ‘Node’: The node to be removed is not a child of this node. at HTMLDivElement.removeChild”

I recently came across this error when implementing the 3rd party image carousel library called Glider into a Salesforce lightning web component. The message doesn’t give much away, does it? Given the hours I lost investigating the issue I thought I’d share the solution. Salesforce does not like 3rd party libraries manipulating the DOM. They do make it possible though e.g. if you know that the library is going to inject elements into a container element you can flag that container element like so: However, some libraries require that you partially set up an expected DOM structure and then the library’s initialisation sprinkles whatever else it needs within that structure. In my case, Glider injects a “track” (wrapper) <div> around the elements that you can flip through. Interestingly, SF LWC is fine with this unless you are conditionally re-rendering the part of the page that contains Glider. In that case, …

Read more