Newer Version Available

This content describes an older version of this product. View Latest

Disable Lightning Locker for a Component

Disable Lightning Locker for an Aura component by setting the Salesforce API version to 39.0 or lower for the component. If a component is set to at least API version 40.0, Lightning Locker is enabled.

Salesforce API version 40.0 corresponds to Summer ’17, when Lightning Locker was enabled for all orgs. Lightning Locker is disabled for any component created before Summer ’17 because these components have an API version less than 40.0.

Component versioning enables you to associate a component with a Salesforce API version. When you create a component, the default version is the latest API version.

In previous releases, you could set the API version of a component to 39.0 using the Developer Console. However, you can’t use the console for this purpose because the console supports only the six previous API versions.

Now, you set the API version in the component’s metadata file using Salesforce CLI. In the AuraDefinitionBundle metadata of your component, use the apiVersion field to set the API version to 39.0.

In this example, the metadata file myComponent.cmp-meta.xml for component myComponent.cmp sets the API version to 39.0.

1<?xml version="1.0" encoding="UTF-8"?>
2<AuraDefinitionBundle xmlns="http://soap.sforce.com/2006/04/metadata">
3    <apiVersion>39.0</apiVersion>
4    <description>My Component</description>
5</AuraDefinitionBundle>

For consistency and ease of debugging, we recommend that you set the same API version for all components in your app, when possible.

If your component uses a base component that has a minimum API version greater than 39.0, you can’t disable Locker on your component. For example, the base component lightning:map requires API version 44.0 or later, as shown in the Specification page in the Component Reference. If you use lightning:map and set apiVersion to 39.0 in myComponent.cmp-meta.xml, you see an error. For example, this error displays if you add the component to a page in Lightning App Builder.

1Component API version is too old: 'markup://c:myComponent' must be set to API version '44' or later to use component 'markup://lightning:map'

If a component’s apiVersion is set to 39.0 to disable Locker, the component is not affected by the Locker API version setting for the org. Locker is still disabled in the component.

Note