0

Like in which hook of the component the function was called ?

I need to assert that a function in my mixin is invoked only in the didInsertElement() hook and not before, so that the function could handle the DOM.

mukilane
  • 302
  • 3
  • 9

2 Answers2

0

You could check if this.element is in the dom like document.contains(this.element).

enspandi
  • 663
  • 4
  • 6
0

https://ember-twiddle.com/d3c73960184bc386683ade204268059c?openFiles=components.sample-component.js%2Ctemplates.components.sample-component.hbs

I have created a twiddle, this details you how to check if a function is called directly from didInsertElement. (This method uses error stack)

reference: How do you find out the caller function in JavaScript?

Neovire
  • 97
  • 1
  • 8