function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Srinivas SSrinivas S 

javaScript error while creating the component from the visualforce page in Latest Chrome Browser if the Locker service is activated.

We are getting the following error upon clicking on a tab which will create lighting component from the javaScript -
Uncaught (in promise) TypeError: Cannot set property 'innerHTML' of null
    at AuraInstance.message (/auraFW/javascript/zsWZWPmRKjQt6GsG2UtCYg/aura_proddebug.js:18708)
    at AuraInstance.handleError (/auraFW/javascript/zsWZWPmRKjQt6GsG2UtCYg/aura_proddebug.js:18676)
    at AuraInstance.$reportError$ (/auraFW/javascript/zsWZWPmRKjQt6GsG2UtCYg/aura_proddebug.js:18685)
    at reportError (/auraFW/javascript/zsWZWPmRKjQt6GsG2UtCYg/aura_proddebug.js:18523)

Please help me with any work around.

Thanks,
Srinivas
NagendraNagendra (Salesforce Developers) 
Hi Srinivas,

InnerHTML of null means the script is trying to set HTML value but the html markup element is not present in the dom it could be that you maybe trying to update some HTML value init or some handler which could cause this issue.

It would help if you can paste your code and during which operation this error is coming.

Thanks,
Nagendra.
Chidanand MChidanand M
Hi Nagendra,

I am also facing the same issue when i  try to load the component from vf page.
Could you please let me know if you have any solution for the same.

Below is my code
 
VF Page

<apex:page standardController="Opportunity" showHeader="false" sidebar="false" standardStylesheets="false" extensions="BarCodeSearchCtrl" action="{!dmlOperation}">

<apex:includeLightning />
  <div style="width:30%;height:100px;" id="FlipcardContainer" />

    <!-- accepts three parameters: value, field, object  -->

    
    {!searchResult}
    <apex:outputPanel rendered="{!searchResult}">       
        <script type="text/javascript">
        
         $Lightning.use("c:QRSCanApp", function() {
         $Lightning.createComponent("c:QRScan",
         { 
          },
         "FlipcardContainer",
         function(cmp) {
             console.log('Component created, do something cool here');
         });
         });
        </script>
    </apex:outputPanel>
    
    

</apex:page>

Extension

public with sharing class BarCodeSearchCtrl {

    public BarCodeSearchCtrl(ApexPages.StandardController controller) {

    }

    
    public list<sObject> multipleResultList {get;set;}
    public boolean searchResult {get;set;}
    public String redirectId{get;set;}
    
    

    public PageReference dmlOperation() {
    
        string fromScan= ApexPages.CurrentPage().getParameters().get('fromScan');
        string fieldValue = ApexPages.CurrentPage().getParameters().get('fieldValue');
        redirectId = fieldValue;
        system.debug('url:' + ApexPages.currentPage().getURL());
        system.debug('fieldValue :' + fieldValue );
        system.debug('fromScan:' + fromScan);
        system.debug('redirectId :' + redirectId);

        fieldValue ='0060K00000RSM8G';

        Opportunity opp = [Select Id,Name,StageName from Opportunity where Id=:fieldValue];
        opp.stageName='Complete';
        update opp;
        searchResult = true;
        return null;
         
    }


}

QRScanApp.App

<aura:application extends="ltng:outApp" >
    <c:QRScan />
</aura:application>

QRScan.cmp

<aura:component implements="flexipage:availableForAllPageTypes,force:appHostable,force:hasRecordId">
<!--<ltng:require styles="{!$Resource.SLDS24 + '/assets/styles/lightning-design-system-ltng.css'}"/>-->

    <aura:attribute type="string" default="Id Only" name="UrlType" required="True"/>
    <aura:attribute type="string" default="Scan" name="messageText" />
    <aura:attribute type="boolean" default="false" name="Spinner" />
    <aura:attribute type="string" name="baseURL" default="https://chiducts-dev-ed.my.salesforce.com"/>
    <aura:attribute type="string" name="fromScan" default="Yes"/>

    
    <aura:handler event="aura:waiting" action="{!c.showSpinner}"/>
    <aura:handler event="aura:doneWaiting" action="{!c.hideSpinner}"/>

    <aura:attribute type="string" name="CustomObject" />
    <aura:attribute type="string" name="CustomField" />
    <aura:attribute name="recordId" type="Id" />
    <aura:attribute name="test" type="boolean" default="false"/>
    
   	<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <aura:handler event="force:refreshView" action="{!c.isRefreshed}" />

    <aura:if isTrue="{!v.test == true}">
        <c:QRScan />
    </aura:if>
    
    <!--<aura:handler event="force:refreshView" action="{!c.doInit}" />-->
    {!v.Spinner}
    {!v.messageText}
    <!--loading spinner start... style=Brand Medium (blue dots)-->
     <aura:if isTrue="{!v.Spinner}">
        <div aura:id="spinnerId" class="slds-spinner_container">
           <div class="slds-spinner--brand  slds-spinner slds-spinner--large slds-is-relative" role="alert">
             <span class="slds-assistive-text">Loading</span>
             <div class="slds-spinner__dot-a"></div>
             <div class="slds-spinner__dot-b"></div>
           </div>
        </div>
     </aura:if>
  <!-- Loading spinner end-->  
</aura:component>

QRScan.ctrl

({
    doInit : function(component, event, helper) {
        
        var urlEvent = $A.get("e.force:navigateToURL");
        //option 2 QR codes contains just the record Id 
         if (component.get("v.UrlType") == "Id Only"){
           var callback = component.get("v.baseURL")
              + "/apex/BarCodeSearch?fieldValue=SCANNED_DATA";              
            
            //alert(callback);
            
            var url = "scan://scan?callback=" + encodeURIComponent(callback);    
            //alert(url);
            
            urlEvent.setParams({
                "url": url
            });
             
             
         }
        
        //use an custom field using a special VF page to search and redirect to the object
        
        urlEvent.fire();
        //component.set("v.test",true);
    },
    
     
    // this function automatic call by aura:waiting event  
    showSpinner: function(component, event, helper) {
       // make Spinner attribute true for display loading spinner 
        component.set("v.Spinner", true); 
   },
    
 // this function automatic call by aura:doneWaiting event 
    hideSpinner : function(component,event,helper){
     // make Spinner attribute to false for hide loading spinner    
       component.set("v.Spinner", false);
    },
        
})