Newer Version Available
Controlling Access
Use the access system attribute on these tags:
- aura:application
- aura:interface
- aura:component
- aura:attribute
- aura:event
Access Values
You can specify these values for the access system attribute.
Example
This sample component has global access.
1<aura:component access="global">
2 ...
3</aura:component>Access Violations
If your code accesses a resource, such as a component or attribute, that doesn’t have an access system attribute allowing you to access it, you see a warning in your browser console if you enabled debug mode.
Anatomy of an Access Check Warning
This is a sample access check warning message in the browser console for an access violation.
1WARNING: Access Check Failed ! ComponentService.getDef():'markup://c:targetComponent' is not visible to 'undefined'.A warning message has four parts:
- The context (who is trying to access the resource). In our example, this is undefined.
- The target (the resource being accessed). In our example, this is markup://c:targetComponent.
- The type of failure. In our example, this is not visible.
- The code that triggered the failure. This is usually a class method. In our example, this is ComponentService.getDef(), which means that the target definition (component) was not accessible. A definition describes metadata for a resource, such as a component.
Fixing Access Check Warnings
You can fix any access check warnings using one or more of these techniques.
- Add appropriate access system attributes to the resources that you own.
- Remove references in your code to resources that aren’t available.
- Ensure that any attribute that you’re accessing exists and you’re using the correct
case-sensitive spelling.
Accessing an undefined attribute or a private attribute triggers the same access violation message because the access context doesn’t know whether the attribute is undefined or private.
- Use $A.getCallback() to wrap code that accesses
a component outside the normal rerendering lifecycle, such as in a setTimeout() or setInterval() call or in an ES6 Promise.
$A.getCallback() preserves the current execution context and grants the correct access level to the asynchronous code. Otherwise, the framework loses context and allows access only to global resources.