forcedotcom/aura

Programmatic onRender handler broken by LockerService

Jeff17Robbins opened this issue · 2 comments

I have a super class TestSuper

<aura:component abstract="true" extensible="true">
    <aura:handler name="init" value="{! this }" action="{! c.onInit }" />
    {!v.body}
</aura:component>

Its controller attempts to provide a handler for the onRender event for its sub classes (so the sub classes don't have to add boilerplate <aura:handler name="render"...> tags needlessly)

({
    onInit: function(superComponent, event, helper) {
        var cmp = superComponent.getConcreteComponent();

        cmp.addValueHandler({ 
            value: cmp.getReference('this'), 
            event: 'render', 
            action: superComponent.getReference('c.onRender')
        });
    },

    onRender: function(superComponent, event, helper) {
    },
})

A sub class TestSub

<aura:component implements="flexipage:availableForAllPageTypes" extends="c:TestSuper" access="global">
    <h1>hello</h1>
    {!v.body}
</aura:component>

If I set API version 39.0 (no LockerService), this code works. If I switch to 41.0, I get this error

Action failed: c:TestSuper$controller$onInit [config.action.getExpression is not a function]


componentConstructor.Component.$addValueHandler$()@https://lddemo.lightning.force.com/auraFW/javascript/vKJIibmD6bCBPWJooXYNvQ/aura_proddebug.js:8635:70
Object.value [as addValueHandler])@https://lddemo.lightning.force.com/auraFW/javascript/vKJIibmD6bCBPWJooXYNvQ/aura_proddebug.js:25247:45
onInit()@https://lddemo.lightning.force.com/flexipageEditor/components/c/TestSuper.js:12:13

It appears (although I'm a newbie) that superComponent.getReference('c.onRender') doesn't work under LockerService. If the sub class component where attempting to access an abritrary component's innards, I'd expect LockerService to prevent that.

But isn't the superComponent a "part of" the sub component because extends="c:TestSuper" , and so shouldn't this work under LockerService?

hi
have you gotten the answers

Not yet!