myGenericKind
to render an enyo.Scroller
containing a form
tag which acts as the scroller's controlParent
.mySpecificKind
to render it's components inside the form
tag.myGenericKind
to bubble the onDestroying
event all the way up to myHost
so that it can respond to the fact that it's child is about to be destroyed.myBubblyThing
to bubble the onDestroying
event all the way up to myHost
so that it can respond to the fact that it's child is about to be destroyed.onDestroying
event from myBubblyThing
never bubbles up to myHost
, because the controlParent
of myGenericKind.scroller
cannot find a bubbleTarget.controlParent
to the scroller (the form
tag). As soon as I remove it, there is no problem bubbling the destroy event. mySpecificKind
.form
tag inside the enyo.Scroller
as controlParent ánd still be able to bubble events from inside the controlParent up the tree.It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Component.destroyComponents()
iterates over its list of owned components (viagetComponents()
) and destroys each in FIFO order. So in your example, that's Scroller, form, anonymous control with content, and finally myBubblyThing.When you have the form as the controlParent, the event bubbling fails because when it gets to the form, it stops because the form has already gone through its
destroy()
and is no longer a child of or owned by anything. Therefore,getBubbleTarget()
returns nothing and the bubbling stops./exhale
The best solution probably depends on the rest of your app. One option is to dispatch your custom event starting at the components owner rather than itself.
http://jsfiddle.net/t6xr2v6h/6/
My first instinct was to override
getBubbleTarget()
but you likely don't want to do that for all events and that method doesn't receive any context about the event so it's all or nothing as it is. You could do something like this to indicate you need some special handling, though:http://jsfiddle.net/t6xr2v6h/7/
And probably several other hacky options ...
HTH!
As far as I know, the default implementation of getBubbleTarget successively looks for a bubbleTarget property, a parent property, and finally an owner property.
As I understand it, when the bubbling fails, all three of those properties are undefined. The overridden getBubbleTarget method just returns the owner property no-questions-asked.
But, if the original method thinks the owner property is undefined, why does the overridden method disagree?
That is, I see that it's working with the overridden method, and if I simply comment out the custom firingOnDestroying case within the overridden method it fails. But I cannot get my head around what the difference is.
So yeah, very very big thanks a lot for finding this solution!
If I use the following code: I would expect the following flow:
myBubblyThing.destroy
inheritsmyMixin.destroy
myMixin.destroy
callsmyBubblyThing.bubbleUp
, which is inherited fromenyo.Component.prototype.bubbleUp
myBubblyThing.bubbleUp
callsmyBubblyThing.getBubbleTarget
, which is inherited fromenyo.UiComponent.prototype.bubbleUp
myBubblyThing.getBubbleTarget
checks it'sbubbleTarget
,parent
and finallyowner
, finding that all of them areundefined
myBubblyThing.bubbleUp
has no bubble target, and thus returnsfalse
myMixin.destroy
method clearly is able to acccess the anowner
property. But assuming the same starting conditions as the scenario governing the reconstructed fail case in my previous post, it should already beenundefined
at this point?getBubbleTarget()
is what is returning nothing.That's ultimately why my solutions work. By skipping bubbling through the control's parent (the form), bubbling works because the owner hasn't been destroyed yet. It isn't destroyed until all of its components are destroyed. The order is driven by ownership only and not containment.