[SalesForce] Aura component critical updates related to $A.createComponent() or $A.createComponents()

i just observed summer 19 release notes, and in my org critical updates area, we r using $A.createComponent()/ $A.createComponents() in bunch of our custom lightning cmps's. still i am not under stand how this critical updates 'll effects of our orgs, can you please explain how it'll effects for below code snippet.

we r using simple like below:

cmpcontroller.js

opencustomcmpmodal: function(component,field1,field2,field3){ 
var attributes = {
   'chldfield1': field1,
   'chldfield2': field2,
   'chldfield3': field3
};

    $A.createComponents(
                [
                    ["aura:html", {
                        "tag": "h2",
                        "body": 'Modal header',
                        "HTMLAttributes": { 
                            "class": "slds-text-heading_medium slds-hyphenate" 
                        }
                    }],
                    ["c:mycustomcomponent",attributes]
                ],
            function(components, status) {
                if (status === "SUCCESS") {
                    modalheader = components[0];
                    modalBody = components[1];
                   var promiseaction =  component.find('overlayLib').showCustomModal({
                       header:modalheader,
                        body: modalBody,
                        showCloseButton: true,
                        cssClass: "my-modal,my-custom-class,my-other-class"
                    });
                    component.set("v.modalPromise",promiseaction);
                }
            });
} 

Best Answer

The critical update applies only if your attributes used in have a function expression $A.createComponent/$A.createComponents

Lets say your attribute definition was as below

var attributes = {
  'chldfield1': field1,
  'chldfield2': function (x,y) { console.log('test')},
  'chldfield3': field3
};

The above assumes your component has an attribute of type "FUNCTION" like below

<aura:attribute name="chldfield2" type="Function" />

Notice that the chldfield2 has a function expression, this is where you will need to be worried and will test your component with critical update on.

If you do not have components with attribute as function you should be unaffected by this update.

However i suggest you enable this and test your component.

Also critical updates are mostly reversible for short span of time so you can always deactivate them until it is applied permanently.

Related Topic