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

Delegate event bubbling does not match native behavior in shadow dom #755

Closed
michaelw85 opened this issue Jun 26, 2019 · 0 comments · Fixed by #758

Comments

@michaelw85
Copy link
Contributor

commented Jun 26, 2019

I'm submitting a bug report

  • Library Version:
    Latest version, current master (2.3.2)

Please tell us about your environment:

  • Operating System:
    Windows 10

  • Node Version:
    v10.15.1

  • NPM Version:
    6.9.0

  • Webpack
    4.27.0

  • Browser:
    Chrome Version 75.0.3770.100 (Official Build) (64-bit)

  • Language:
    all

Current behavior:
When using a click delegate on a custom element with shadow dom the callback is not fired.

<custom-comp click.delegate="expectToTrigger()"></...>

Expected/desired behavior:
According to this documentation and by testing in chrome click events should be able to cross the shadow dom boundary.

  • What is the expected behavior?
    Click delegate should fire on custom element regardless of using shadow dom or not.

  • What is the motivation / use case for changing the behavior?
    Behavior should be similar/equal to native behavior since I'm under the impression this is the vision of Aurelia.
    From a technical perspective I am now forced to use the less performant trigger or custom events.

Possible root cause:
event-manager:70

function handleDelegatedEvent(event) {
  event.propagationStopped = false;
  let target = findOriginalEventTarget(event);

  while (target && !event.propagationStopped) {
    if (target.delegatedCallbacks) {
      let callback = target.delegatedCallbacks[event.type];
      if (callback) {
        if (event.stopPropagation !== stopPropagation) {
          event.standardStopPropagation = event.stopPropagation;
          event.stopPropagation = stopPropagation;
        }
        if ('handleEvent' in callback) {
          callback.handleEvent(event);
        } else {
          callback(event);
        }
      }
    }

    // 🔽🔽🔽 this will receive null when the shadow root is reached and will break the loop
    target = target.parentNode;
  }
}
michaelw85 pushed a commit to michaelw85/binding that referenced this issue Jul 16, 2019
Michael Withagen
fix(event-manager): shadow dom event bubbling
Delegate events should be able to pass shadow dom boundry similar to native
events.

Closes aurelia#755
michaelw85 added a commit to michaelw85/binding that referenced this issue Jul 16, 2019
fix(event-manager): shadow dom event bubbling
Delegate events should be able to pass shadow dom boundry similar to native
events.

Closes aurelia#755
michaelw85 added a commit to michaelw85/binding that referenced this issue Aug 13, 2019
michaelw85 added a commit to michaelw85/binding that referenced this issue Sep 5, 2019
fix(event-manager): update d.ts
Add escapeShadowRoot to d.ts

Related: aurelia#758 aurelia#755
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.