Skip to content
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

Behavior event handlers shouldn't be called if event.stopImmediatePropagation() is called #63

Closed
signals4change opened this issue May 14, 2015 · 3 comments
Labels

Comments

@signals4change
Copy link

Hi there

I think when event handler in module return false, event handlers in behaviors must not be called.
propose change in bindEventType function for simulate bubbling between module and behaviors:

function bindEventType(element, type, handlers) {
        function eventHandler(event) {
            var targetElement = getNearestTypeElement(event.target),
                elementType = targetElement ? targetElement.getAttribute('data-type') : '',
                result
                ;

```
        for (var i = 0; i < handlers.length; i++) {
            //handlers[i](event, targetElement, elementType);                
            result = handlers[i](event, targetElement, elementType);
            if(result===false) return false;                
        }

        return result;
    }

    // @NOTE(nzakas): Using jQuery for event normalization
    $(element).on(type, eventHandler);

    return eventHandler;
}
```

@signals4change signals4change changed the title Hi Change in bindEventType May 14, 2015
@nzakas nzakas changed the title Change in bindEventType Behavior event handlers shouldn't be called if event.stopImmediatePropagation() is called May 15, 2015
@nzakas
Copy link
Contributor

nzakas commented May 15, 2015

The way we specified to do this is to call event.stopImmediatePropagation(). However, I see that isn't working currently. We should fix it so it does.

@nzakas nzakas added the bug label May 15, 2015
@j3tan
Copy link
Contributor

j3tan commented Jun 9, 2015

Do we guarantee that when (module => behavior A => behavior B) that event.stopImmediatePropagation() called in module stops Behavior A & B and a event.stopImmediatePropagation() in Behavior A only stops only B?

Also, is there a way to detect if an event is stopped without using jQuery? I don't see anything in the Event spec.

@nzakas
Copy link
Contributor

nzakas commented Jun 9, 2015

If we start by implementing #47, we could use that internally to setup event handlers. Then, the browser would handle event.stopImmediatePropagation() on its own (assuming we had one DOMEventDelegate for each module and behavior, and they were created in order on the same element). So, we wouldn't need to detect anything, we would get it for free.

@nzakas nzakas closed this as completed in e54cc71 Jul 30, 2015
jstoffan pushed a commit that referenced this issue Jul 12, 2022
Beginnings of quickstart docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants