I've noticed that some lightning components don't have all of the same methods as others. For example, I instantiated an aura:html component and one of my custom components and the object definitions are substantially different. Is there a reason for this and are the differences in available properties documented somewhere for each of the components?

I was surprised I couldn't call destroy on the aura:html component

enter image description here

1 Answer 1


The first one is a SecureComponentRef and the second is a SecureComponent. SecureComponent is only passed into code that belongs to the component (e.g. its controller and renderer). In this context you are allowed to cmp.find(auraIdForSomeInternalPartOfYourImpl) and call getElement()/getElements() to access your implementation. SecureComponentRef is what you get in all other scenarios - those where you are referencing a component and should only have public API access to it (methods, attributes, events). This eliminates one of the most egregious implicit (and therefor unsupportable) dependency anti patterns:

var someComponentIDoNotOwn = cmp.find("foo"); 
var someInternalDOMDetailsIShouldNeverDependOn = someComponentIDoNotOwn.getElement();

or another variation on that theme: cmp.find("foo").find("bar") which reaches into the guts of another component and breaks encapsulation horridly.

Specific to .destroy() that looks like an oversight and I believe we need to add that to SecureComponentRef.

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.