mirror of
https://github.com/atom/atom.git
synced 2026-01-24 06:18:03 -05:00
Preserve all event properties when dispatching commands
Fixes https://github.com/atom/vim-mode/issues/863 Fixes https://github.com/atom/atom/issues/8845 --- Re-applying this commit because it was accidentally merged from stable to beta and master with `--strategy ours` (discarding the changes) instead of `-X ours` (discarding conflicting changes). Signed-off-by: Max Brunsfeld <maxbrunsfeld@github.com>
This commit is contained in:
committed by
Max Brunsfeld
parent
ac9630cc08
commit
ccfa36d1b1
@@ -115,6 +115,15 @@ describe "CommandRegistry", ->
|
||||
grandchild.dispatchEvent(dispatchedEvent)
|
||||
expect(dispatchedEvent.abortKeyBinding).toHaveBeenCalled()
|
||||
|
||||
it "copies non-standard properties from the original event to the synthetic event", ->
|
||||
syntheticEvent = null
|
||||
registry.add '.child', 'command', (event) -> syntheticEvent = event
|
||||
|
||||
dispatchedEvent = new CustomEvent('command', bubbles: true)
|
||||
dispatchedEvent.nonStandardProperty = 'testing'
|
||||
grandchild.dispatchEvent(dispatchedEvent)
|
||||
expect(syntheticEvent.nonStandardProperty).toBe 'testing'
|
||||
|
||||
it "allows listeners to be removed via a disposable returned by ::add", ->
|
||||
calls = []
|
||||
|
||||
|
||||
@@ -227,6 +227,9 @@ class CommandRegistry
|
||||
Object.defineProperty dispatchedEvent, 'abortKeyBinding', value: ->
|
||||
event.abortKeyBinding?()
|
||||
|
||||
for key in Object.keys(event)
|
||||
dispatchedEvent[key] = event[key]
|
||||
|
||||
@emitter.emit 'will-dispatch', dispatchedEvent
|
||||
|
||||
loop
|
||||
|
||||
Reference in New Issue
Block a user