This Salesforce lightning web component works fine in Chrome, but in Mozilla firefox the title does not load when clicking on an icon, and the error " [Lightning Web Security: Cannot access rangeParent.]" appears. Resolve this error so that the component works as expected in Firefox also.
Assistant
The error you're encountering in Firefox, specifically the message "[Lightning Web Security: Cannot access rangeParent.]", is likely related to the way the Lightning Web Security (LWS) enforces security policies that may restrict certain DOM manipulations. This issue can arise especially when dealing with popups or modals within Lightning Web Components (LWC).
Steps to Resolve the Issue
Here are some steps you can take to address the issue and ensure that the component works as expected in Firefox:
Ensure Proper Event Handling:
Make sure that all event handlers are correctly defined and that they do not attempt to access or manipulate the DOM in ways that are restricted by LWS. In your case, this could involve reviewing how you're binding popups to markers and ensuring that those actions comply with LWS rules.
Use this.template.querySelector:
When manipulating DOM elements directly, use this.template.querySelector to ensure that the elements are correctly scoped to the current component instance. For example, when accessing or modifying marker popups, ensure you're using this method to retrieve elements.
Check Popup Implementation:
Your implementation for creating popups with L.popup() should be scrutinized. Ensure that the popup content is being set correctly and that you're not trying to access properties or methods that might not exist or are restricted in Firefox.
Update Marker Creation Logic:
In the createMarker function of mapOfThingsMarkers.js, ensure that the bindPopup method is used correctly. Try setting the popup content in a way that is compatible with LWS. For example:
After making changes, thoroughly test the component in Firefox to ensure that the popups behave as expected. You may need to debug using the Firefox Developer Tools to inspect the console for errors and the network tab for any failed requests.
Check for Known Issues:
Review Salesforce documentation and known issues for LWC regarding browser compatibility, especially focusing on Firefox. Sometimes, there are browser-specific quirks or required polyfills that need to be included in your project.
Example Adjustment
Here’s an example adjustment you could make in the mapOfThingsMarkers.js file to ensure proper handling of popups:
By ensuring that your component is compliant with Lightning Web Security and effectively managing DOM manipulations, you should be able to resolve the "Cannot access rangeParent" error in Firefox. Make sure to implement the changes and test thoroughly across different browsers to confirm consistent behavior. If issues persist, consider reaching out to Salesforce support or consulting the developer community for insights on similar experiences.