From c0762c0f8bb4f0a60d96be5dc6b6a6b5bb0c1411 Mon Sep 17 00:00:00 2001 From: Robert Manolea Date: Tue, 3 Mar 2020 12:12:27 +0100 Subject: [PATCH] Allow events to bubble outside of shadowDOM --- delegated-events.js | 1 + delegated-events.js.flow | 1 + test/bench.js | 1 + test/test.js | 2 ++ 4 files changed, 5 insertions(+) diff --git a/delegated-events.js b/delegated-events.js index 9fcbd29..cda4102 100644 --- a/delegated-events.js +++ b/delegated-events.js @@ -121,6 +121,7 @@ export function fire(target, name, detail) { new CustomEvent(name, { bubbles: true, cancelable: true, + composed: true, detail: detail }) ); diff --git a/delegated-events.js.flow b/delegated-events.js.flow index e0fae4f..40154da 100644 --- a/delegated-events.js.flow +++ b/delegated-events.js.flow @@ -3,6 +3,7 @@ type Event = { bubbles: boolean; cancelable: boolean; + composed: boolean; currentTarget: Element; deepPath?: () => EventTarget[]; defaultPrevented: boolean; diff --git a/test/bench.js b/test/bench.js index be2e82d..c3feb84 100644 --- a/test/bench.js +++ b/test/bench.js @@ -111,6 +111,7 @@ import {on, off} from '../delegated-events'; new CustomEvent('test:bench', { bubbles: true, cancelable: true, + composed: true, detail: {index: i} }) ); diff --git a/test/test.js b/test/test.js index 1d5342e..c845588 100644 --- a/test/test.js +++ b/test/test.js @@ -15,6 +15,7 @@ describe('delegated event listeners', function() { const observer = function(event) { assert(event.bubbles); assert(event.cancelable); + assert(event.composed); assert.equal(event.type, 'test:detail'); assert.deepEqual(event.detail, {id: 42, login: 'hubot'}); assert.strictEqual(document.body, event.target); @@ -58,6 +59,7 @@ describe('delegated event listeners', function() { const observer = function(event) { assert(event.bubbles); assert(event.cancelable); + assert(event.composed); assert.equal(event.type, 'test:on'); assert.deepEqual({id: 42, login: 'hubot'}, event.detail); assert.strictEqual(document.body, event.target);