Browse Source

Add document to listen target for custom events

pfrlv 5 years ago
parent
commit
c4d675ef1a
1 changed files with 5 additions and 1 deletions
  1. 5 1
      src/component.js

+ 5 - 1
src/component.js

@@ -229,7 +229,11 @@ export default class Component {
             // Listen for this event at the root level.
             document.addEventListener(event, handler)
         } else {
-            const listenerTarget = modifiers.includes('window') ? window : el
+            const listenerTarget = modifiers.includes('window')
+                ? window
+                : modifiers.includes('document')
+                ? document
+                : el
 
             const handler = e => {
                 const modifiersWithoutWindow = modifiers.filter(i => i !== 'window')