Skip to main content
Tweeted twitter.com/StackSalesforce/status/803844841226596352
Add gist with reduced test case.
Source Link
dsharrison
  • 4k
  • 1
  • 24
  • 57

I have a lightning component setup where in a parent component I dynamically create a component and assign it to an <aura:attribute type="Aura.Component" />. The dynamically created child component has an <aura:method /> on it. The controller action for that method does some DOM manipulation on a node inside the dynamically created component (this should be totally valid in Locker Service since we are accessing a DOM node inside the same component). However, getElement() is not available when the component was dynamically created. If I instead directly place the component inside the parent component with <c:myCmp /> when I call the same function getElement() is available.

Is there something special I need to do in order to make sure dynamically created components have getElement() available within their own controller code or is this simply a bug in Locker Service?

If need be I can put together a reduced test case and throw it inUPDATE - GIST

Here is a gist that will showcase the issue: https://gist.github.com/dsharrison/bf2ceaf22820bbfb79cef042fd2e5d8d

With Locker Service disabled, both buttons will report that getElement() is available. Once enabled, the dynamic button will lose access to getElement().

I have a lightning component setup where in a parent component I dynamically create a component and assign it to an <aura:attribute type="Aura.Component" />. The dynamically created child component has an <aura:method /> on it. The controller action for that method does some DOM manipulation on a node inside the dynamically created component (this should be totally valid in Locker Service since we are accessing a DOM node inside the same component). However, getElement() is not available when the component was dynamically created. If I instead directly place the component inside the parent component with <c:myCmp /> when I call the same function getElement() is available.

Is there something special I need to do in order to make sure dynamically created components have getElement() available within their own controller code or is this simply a bug in Locker Service?

If need be I can put together a reduced test case and throw it in a gist.

I have a lightning component setup where in a parent component I dynamically create a component and assign it to an <aura:attribute type="Aura.Component" />. The dynamically created child component has an <aura:method /> on it. The controller action for that method does some DOM manipulation on a node inside the dynamically created component (this should be totally valid in Locker Service since we are accessing a DOM node inside the same component). However, getElement() is not available when the component was dynamically created. If I instead directly place the component inside the parent component with <c:myCmp /> when I call the same function getElement() is available.

Is there something special I need to do in order to make sure dynamically created components have getElement() available within their own controller code or is this simply a bug in Locker Service?

UPDATE - GIST

Here is a gist that will showcase the issue: https://gist.github.com/dsharrison/bf2ceaf22820bbfb79cef042fd2e5d8d

With Locker Service disabled, both buttons will report that getElement() is available. Once enabled, the dynamic button will lose access to getElement().

deleted 18 characters in body
Source Link
Mohith Shrivastava
  • 92k
  • 19
  • 161
  • 214

I have a lightning component setup where in a parent component I dynamically create a component and assign it to an <aura:attribute type="Aura.Component" />. The dynamically created child component has an <aura:method /> on it. The controller action for that method does some DOM manipulation on a node inside the dynamically created component (this should be totally valid in Locker Service since we are accessing a DOM node inside the same component). However, getElement() is not available when the component was dynamically created. If I instead directly place the component inside the parent component with <c:myCmp /> when I call the same function getElement() is available.

Is there something special I need to do in order to make sure dynamically created components have getElement() available within their own controller code or is this simply a bug in Locker Service?

If need be I can put together a reduced test case and throw it in a gist.

Thanks!

-D.S.

I have a lightning component setup where in a parent component I dynamically create a component and assign it to an <aura:attribute type="Aura.Component" />. The dynamically created child component has an <aura:method /> on it. The controller action for that method does some DOM manipulation on a node inside the dynamically created component (this should be totally valid in Locker Service since we are accessing a DOM node inside the same component). However, getElement() is not available when the component was dynamically created. If I instead directly place the component inside the parent component with <c:myCmp /> when I call the same function getElement() is available.

Is there something special I need to do in order to make sure dynamically created components have getElement() available within their own controller code or is this simply a bug in Locker Service?

If need be I can put together a reduced test case and throw it in a gist.

Thanks!

-D.S.

I have a lightning component setup where in a parent component I dynamically create a component and assign it to an <aura:attribute type="Aura.Component" />. The dynamically created child component has an <aura:method /> on it. The controller action for that method does some DOM manipulation on a node inside the dynamically created component (this should be totally valid in Locker Service since we are accessing a DOM node inside the same component). However, getElement() is not available when the component was dynamically created. If I instead directly place the component inside the parent component with <c:myCmp /> when I call the same function getElement() is available.

Is there something special I need to do in order to make sure dynamically created components have getElement() available within their own controller code or is this simply a bug in Locker Service?

If need be I can put together a reduced test case and throw it in a gist.

Source Link
dsharrison
  • 4k
  • 1
  • 24
  • 57

Locker Service DOM accessibility when action invoked via method

I have a lightning component setup where in a parent component I dynamically create a component and assign it to an <aura:attribute type="Aura.Component" />. The dynamically created child component has an <aura:method /> on it. The controller action for that method does some DOM manipulation on a node inside the dynamically created component (this should be totally valid in Locker Service since we are accessing a DOM node inside the same component). However, getElement() is not available when the component was dynamically created. If I instead directly place the component inside the parent component with <c:myCmp /> when I call the same function getElement() is available.

Is there something special I need to do in order to make sure dynamically created components have getElement() available within their own controller code or is this simply a bug in Locker Service?

If need be I can put together a reduced test case and throw it in a gist.

Thanks!

-D.S.