Lightning Locker Compatibility - riadhmankai/AgGrid-SF GitHub Wiki

Lightning Locker Compatibility

Overview

The AgGrid-SF project is designed to be fully compatible with Salesforce's Lightning Locker Service. This compatibility ensures that the AG Grid component can be used securely within the Salesforce ecosystem while adhering to the best practices and security standards set by Salesforce.

Key Considerations

  1. Locker Service Restrictions: Lightning Locker Service enforces strict security measures, which may restrict certain JavaScript functionalities. Ensure that your code adheres to these restrictions to avoid runtime errors.

  2. Dynamic Resource Loading: When loading external libraries or resources, make sure to handle them in a way that complies with Locker Service. The AgGrid-SF project dynamically loads AG Grid resources from a CDN, which is compatible with Locker Service.

  3. Component Isolation: Each Lightning Web Component (LWC) operates in its own isolated environment. This means that global variables and functions are not accessible across components. Ensure that any shared functionality is encapsulated within the component or passed through properties.

  4. Event Handling: Use standard event handling practices when working with AG Grid within the LWC. Custom events should be dispatched properly to ensure they are captured by parent components.

  5. Testing: Always test your implementation in a Salesforce environment with Locker Service enabled. This will help identify any potential issues early in the development process.

Best Practices

  • Use Lightning Base Components: Whenever possible, utilize Salesforce's Lightning Base Components alongside AG Grid to maintain consistency and compatibility with the Lightning framework.

  • Avoid Inline Styles and Scripts: Inline styles and scripts may not work as expected under Locker Service. Instead, use external stylesheets and scripts.

  • Stay Updated: Keep an eye on updates from Salesforce regarding Locker Service and AG Grid. Compatibility improvements and new features may be introduced that enhance the integration.

Conclusion

By following the guidelines and best practices outlined above, you can ensure that your implementation of the AgGrid-SF project remains compatible with Salesforce's Lightning Locker Service, providing a secure and efficient user experience.