2

I'm having some issues understanding the custom types created by the Locker services. Some times I'm getting a SecureComponent and sometimes its a SecureComponentRef. I've tried looking for a explanation for these but have not been able to find any real documentation for the Locker Service. (other then just reading the Aura framework code). SecureComponent vs SecureComponentRef seems to be important because it impacts what the possible functions are. If someone could help explain why I get one vs the other that would help me understand what is possible.

PS. If anyone knows why the Locker service was rolled out with so little documentation for something that fundamentally impacts Lightning Components.

  • are you trying to use component.find("") on init of any component? – Manjot Singh Dec 29 '16 at 8:48
2

When you grab a reference to a component with LockerService on you get back a SecureComponentRef for components you do not have access to (from another namespace), and SecureComponent for components you do have access to. If you look at what functions are exposed on each you'll notice much less is exposed on SecureComponentRef. For security reasons, we want to restrict what you're able to do to components you don't have access to. You won't be able to destroy or get references to the underlying DOM elements, for example.

| improve this answer | |
  • This doesn't seem to 100% line up with what I've been experiencing. A good example would be a I'm getting a SecureComponentRef when I'm referencing an <legend> when its non-rendered but then when it is I'm getting a SecureComponent. I would think that the same access should apply irrespective of render state. I'll try to put together a sample of what caused the question. – John Jul 6 '16 at 1:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.