-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Eventmaps implemented #4
base: master
Are you sure you want to change the base?
Conversation
…gered before the assertion
Thank you for working on the solution! I finally had a chance to take a look and the implementation seems brilliant. However, I noticed, that this change causes the issue I previously mentioned: the normal event bubbling from child components inside the teleported block is changed and an event stopped in the child component's handler somehow still ends up in teleport's parent's handler. Minimalistic example: <template name="app">
<h1>Clicked {{counter}}</h1>
{{#Teleport ''}}
<button type="button">App click</button>
{{> clicker ''}}
{{/Teleport}}
</template>
<template name="clicker">
<button type="button">Clicker click</button>
</template> Template.app.onCreated(function () {
this.counter = new ReactiveVar(0);
});
Template.app.events({
'click button'(event, instance) {
instance.counter.set(instance.counter.get() + 1);
},
});
Template.clicker.events({
'click button'(event) {
event.stopPropagation();
} Now, clicking on the |
@arggh I fixed the semicolons. For the event bubbling it will take a while, because I think we also need to test, if the other event properties (target, defaultTarget, currentTarget, cancelable etc.) are working, too. I will consider a test function for that, first. Edit: as I need this feature especially with events in combination with Bootstrap modals I will check also if it breaks the modal events, too and hopefully be able to deduce a more generic test from it. |
I am a bit stuck at work but I keep track of this and come back, once finished with current tasks. |
After reading through the gh code of the Blaze repo I found that I can traverse the
parentView
tree upwards until I find the surrounding Template. So no additional parameters required.The good thing is that there is always a parent Template to be found, so there should be no case where the
while
loop is causing an infinite.To be on the safe side I could add a counter and throw an Error if it reaches the 10000 or so. What do you think?
Once the parent view has been found we can access it's Template with the
__eventMaps
property and assign it to the contentBlock.Finally we assign the parent views
templateInstance
to the newly created view. Otherwise the second parameter in the event callback would not have the scope of our parent Template's instance.I could not write a test to check for the proper
templateInstance
within theTemplate.dest.events
part, mainly because I get circular errors and I think this is due to the test environment. What do you think?