miguelcobain / ember-composability-tools

ember-composability-tools - Helpers for building a somewhat different kind of components.
MIT License
39 stars 18 forks source link

ember-composibility-tools 0.0.2 breaks ember-leaflet #2

Closed ashleysommer closed 7 years ago

ashleysommer commented 7 years ago

This commit: https://github.com/miguelcobain/ember-composability-tools/commit/b3a7d7f0b293b2d535ca4d6761b0a1eb38582066 adds fallbacks to the K() function for didInsertParent() and willDestroyParent() for the parent mixin.

It seems that unfortunately these fallbacks actually override the didInsertParent() and willDestroyParent() functions inherited in an extended class.

For example, in ember leaflet, the leaflet-map component is defined as:

 BaseLayer.extend(ParentMixin, { ... });

As it is a top-level parent component, it's creation is triggered in the didInsertElement() function in the parent mixin, which in turn calls didInsertParent() on itself. As leaflet-map does not have a didInsertParent() function defined, it should use the function provided by BaseLayer, (which calls createLayer() and didCreateLayer() etc, as it should), but instead it now calls the new fallback didInsertElement() function defined to be K() in the parent mixin. This breaks the leaflet-map component, because it never gets createLayer() called, thus it never gets a _layer property assigned to itself.

miguelcobain commented 7 years ago

Thanks for this report! Nice find. Will release new versions with this fix.

miguelcobain commented 7 years ago

If I may ask, how did you find this bug? ember-leaflet was still using ember-composibility-tools 0.0.1.

ashleysommer commented 7 years ago

Great question.

I was writing an update for the ember-leaflet-layer-control package to get it work with ember-leaflet v3.0.2. The transition to using ember-composibility-tools in ember-leaflet v3.0.2 broke the current version of ember-leaflet-layer-controls, it had to be updated to use ember-composibility-tools in its components.

I added ember-composibility-tools to the dependencies, and it automatically brought in v0.0.2. I didn't realise it was different to the version ember-leaflet was using. After that, npm decided to use v0.0.2 for ember-leaflet too, and my test application stopped working. That's when I started stepping through with a debugger to find the problem.