Closed canufeel closed 7 years ago
@canufeel I tried to reproduce this using a more similar approach to the existing tests: https://github.com/miguelcobain/ember-composability-tools/commit/03b99caadba35d52bb1bcbe25949daea9bd43df4
The test passes. This problem seems very strange, I don't see how calling init twice can possibly happen. Maybe you can enlighten me.
Basically as i understand the calls to this._super(...arguments)
work by wrapping a super function - https://github.com/emberjs/ember.js/blob/c329f95c1b07b4f70c74b075803dac8f8ba40e23/packages/ember-utils/lib/super.js#L30. When Ember executes init()
hook it first uses this wrap
method on it setting this._super
to be equal to init
of Ember.Component
itself. So until the extended component's init
has not finished execution this._super
would still point to Ember.Component
's init
method. In our case in initChild
or initParent
we would still invoke Ember.Component
init
method which is done twice. That is probably fine if we don't have any additional logic in between Ember.Component
and our mixin
in inheritance chain but when we do and that logic relies on single execution it might break things.
@canufeel I see. I thought we would be invoking initChild
/initParent
in those cases.
It's not trivial to test it the way I wanted to.
Probably we should use - https://github.com/emberjs/ember.js/blob/676fa7e774ada3951d37478ff22feb30f85604bb/packages/ember-metal/lib/mixin.js#L590
That apply would setup _super
wrapper for function called
But not really sure about that
I merged this.
It should be safe. Let me know if you find a more elegant way to test this (using sinon and render).
Ok, sure! Thanks!
Previously it would run twice which would completely break
paper-button
with icons forember-paper > v1.0.0-alpha.10
by causing infinite loop inember-hammertime
(adding it styleattributeBindings
twice and starting to rely on just added one https://github.com/html-next/ember-hammertime/blob/master/addon/mixins/touch-action.js#L85 as theotherStyleKey
which leads to infinite loop)