Chapter 1: LWC Tutorial – Lightning Locker and Lightning Locker Tools
On top of standard restrictions applied via native web APIs, lightning lockers implement a few more restrictions for security purposes.
What are lightning locker features?
- Components can only access elements that are part of it’s DOM
- The window is wrapped as SecureWindow
- Element is wrapped as SecureElement
- The document is wrapped as SecureDocument
- We can’t use third-party web components (Only allows you to use components in lightning or c namespace)
- Locker blocks access to global objects like $A, Aura, they are blocked as they might cause cross framework dependencies
Lightning Locker Tools
Lightning Locker tools help you develop secure code that is compatible and runs efficiently with Lightning Locker.
Lightning Locker API Viewer
For example, setTimeOut, alert, console, etc are supported inside the lightning locker while Element. attachShadow is not allowed (because the LWC framework takes care of attaching shadow DOM to element)