Search In This Blog

2020-01-15

getElement is not working in Lightning tag

SFDC defines it as Invalid DOM Access.
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/security_dom.htm
<lightning:card aura:id="map" title="Current Boat Location">
    <div style="{!'width: ' + v.width + '; height: ' + v.height}">
        Please make a selection
    </div>
</lightning:card>

Because c:domLocker, below will be error.
var mapElement = component.find("map").getElement();

Change Dom as:
<lightning:card title="Current Boat Location">
    <div aura:id="map" style="{!'width: ' + v.width + '; height: ' + v.height}">
        Please make a selection
    </div>
</lightning:card>