Skip to content

Instantly share code, notes, and snippets.

@nedarb
Created January 18, 2018 22:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nedarb/e1b06d3543dfd0d0fcb7a4e7b9b7bbcf to your computer and use it in GitHub Desktop.
Save nedarb/e1b06d3543dfd0d0fcb7a4e7b9b7bbcf to your computer and use it in GitHub Desktop.
Salesforce Lightning Locker test component
<aura:component implements="clients:availableForMailAppAppPage,clients:hasItemContext,flexipage:availableForAllPageTypes">
<aura:attribute name="window" type="String" access="private" />
<aura:attribute name="document" type="String" access="private" />
<aura:handler name="init" value="{! this }" action="{! c.init }" />
<aura:handler Name="change" value="{!v.messageBody}" action="{!c.handleMessageBodyChanged}" />
<!-- This has JQUERY included
<ltng:require scripts="https://code.jquery.com/jquery-3.2.0.min.js"/>
<br/> -->
<lightning:card title="Custom component show body">
<p class="slds-p-horizontal--small">
<div id="myDiv" aura:id="div1">
<p>See how LockerService uses secure wrappers</p>
<p>window={!v.window}</p>
<p>document={!v.document}</p>
</div>
<lightning:button name="myButton" label="Peek in DOM"
aura:id="button1" onclick="{!c.peekInDom}"/>
</p>
</lightning:card>
</aura:component>
({
init: function (cmp, event, helper) {
cmp.set('v.window', window + '');
cmp.set('v.document', document + '');
},
handleMessageBodyChanged : function(component, event, helper) {
component.set('v.myMessageBody', event.getParam('value').trim());
},
peekInDom : function(cmp, event, helper) {
console.log("div1: ", cmp.find("div1").getElement());
console.log("button1: ", cmp.find("button1"));
console.log("button name: ", event.getSource().get("v.name"));
// add debugger statement for inspection
// always remove this from production code
debugger;
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment