From dad36aad2f2301398891425a90c38811549fc5d1 Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Mon, 1 Jun 2015 15:21:40 -0700 Subject: [PATCH] bump(electron): Electron 0.27.1, Chromium 43 Summary: 0.27.1? Nope webview still broken Update atom-keymap As of Chromium 42, you cannot subclass CustomEvent or Event using Object.create(event). This caused the CommandRegistry to break. Creating a new object with the properties of the event seems to work fine. Resolves "Deprecated attempt to access property 'target' on a non-Event object. dispatchEvent fireCustomEventevent-test.html:8 global codeevent-test.html:21 event-test.html:8" in Safari and "TypeError: Illegal Invocation" in Chromium Test Plan: Tests still pass Reviewers: evan Reviewed By: evan Differential Revision: https://phab.nylas.com/D1584 --- package.json | 4 ++-- src/command-registry.coffee | 17 ++++++++++------- src/keymap-extensions.coffee | 16 +++++++++++++--- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 5f182db3b..ab8d441c6 100644 --- a/package.json +++ b/package.json @@ -11,12 +11,12 @@ "bugs": { "url": "https://github.com/nylas/edgehill/issues" }, - "electronVersion": "0.26.0", + "electronVersion": "0.27.2", "dependencies": { "asar": "^0.5.0", "6to5-core": "^3.5", "async": "^0.9", - "atom-keymap": "^3.1", + "atom-keymap": "^5.1", "autolinker": "0.15.2", "bluebird": "^2.9", "clear-cut": "0.4.0", diff --git a/src/command-registry.coffee b/src/command-registry.coffee index 0502bac38..529bfc6bd 100644 --- a/src/command-registry.coffee +++ b/src/command-registry.coffee @@ -167,12 +167,11 @@ class CommandRegistry # * `commandName` {String} indicating the name of the command to dispatch. dispatch: (target, commandName, detail) -> event = new CustomEvent(commandName, {bubbles: true, detail}) - eventWithTarget = Object.create event, - target: value: target - preventDefault: value: -> - stopPropagation: value: -> - stopImmediatePropagation: value: -> - @handleCommandEvent(eventWithTarget) + Object.defineProperty(event, 'target', {value: target}) + Object.defineProperty(event, 'preventDefault', {value: -> }) + Object.defineProperty(event, 'stopPropagation', {value: -> }) + Object.defineProperty(event, 'stopImmediatePropagation', {value: -> }) + @handleCommandEvent(event) onWillDispatch: (callback) -> @emitter.on 'will-dispatch', callback @@ -194,7 +193,8 @@ class CommandRegistry matched = false currentTarget = originalEvent.target - syntheticEvent = Object.create originalEvent, + syntheticEvent = _.extend({}, originalEvent) + syntheticEventProps = eventPhase: value: Event.BUBBLING_PHASE currentTarget: get: -> currentTarget preventDefault: value: -> @@ -209,6 +209,9 @@ class CommandRegistry abortKeyBinding: value: -> originalEvent.abortKeyBinding?() + for prop, def in syntheticEventProps + Object.defineProperty(syntheticEvent, prop, def) + @emitter.emit 'will-dispatch', syntheticEvent loop diff --git a/src/keymap-extensions.coffee b/src/keymap-extensions.coffee index 821abbc0c..7ffd3d7ef 100644 --- a/src/keymap-extensions.coffee +++ b/src/keymap-extensions.coffee @@ -3,13 +3,23 @@ path = require 'path' KeymapManager = require 'atom-keymap' CSON = require 'season' {jQuery} = require 'space-pen' +Grim = require 'grim' + +bundledKeymaps = require('../package.json')?._atomKeymaps KeymapManager::onDidLoadBundledKeymaps = (callback) -> @emitter.on 'did-load-bundled-keymaps', callback KeymapManager::loadBundledKeymaps = -> - @loadKeymap(path.join(@resourcePath, 'keymaps')) - @emit 'bundled-keymaps-loaded' + keymapsPath = path.join(@resourcePath, 'keymaps') + if bundledKeymaps? + for keymapName, keymap of bundledKeymaps + keymapPath = path.join(keymapsPath, keymapName) + @add(keymapPath, keymap) + else + @loadKeymap(keymapsPath) + + @emit 'bundled-keymaps-loaded' if Grim.includeDeprecatedAPIs @emitter.emit 'did-load-bundled-keymaps' KeymapManager::getUserKeymapPath = -> @@ -50,7 +60,7 @@ KeymapManager::subscribeToFileReadFailure = -> else error.message - atom.notifications.addError(message, {detail: detail, dismissable: true}) + atom.notifications.addError(message, {detail, dismissable: true}) # This enables command handlers registered via jQuery to call # `.abortKeyBinding()` on the `jQuery.Event` object passed to the handler.