Commit Graph

65 Commits

Author SHA1 Message Date
Max Brunsfeld
5c545c0898 Don't register CommandRegistry's window listeners in AtomEnvironment constructor 2015-10-08 17:34:41 -07:00
Nathan Sobo
e1c9f3332d Reset commands in AtomEnvironment::reset 2015-10-07 15:25:01 -05:00
Nathan Sobo
f263fbe0d8 Drop jQuery from command-registry 2015-09-18 20:48:47 -06:00
Nathan Sobo
ccfa36d1b1 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>
2015-09-18 15:53:44 -07:00
Thomas Johansen
919445cf8a 🐛 Fix undefined reference to syntheticEvent 2015-09-06 10:27:26 +02:00
Nathan Sobo
aed785924d Continue to dispatch CustomEvent instances in CommandRegistry
This changes the approach used to synthesize an event to dispatch. Since
we can no longer point to the original event as our prototype, we build
a new CustomEvent instance and override select properties with
Object.defineProperty. This preserves the contract with event handlers
by giving them a true CustomEvent instance.
2015-09-06 10:27:25 +02:00
Thomas Johansen
6294bc22d7 Simplify workaround, and describe issue with Object.create + CustomEvent 2015-09-06 10:27:25 +02:00
Thomas Johansen
405eaf14d1 🙈 Add temporary hack to work around issue with CustomEvent
Since it's no longer possible to "properly" extend CustomEvent, we will need to
figure out a way to shadow the prototype chain, or some such.

See https://code.google.com/p/chromium/issues/detail?id=495437 for more details.
2015-09-06 10:27:24 +02:00
Cheng Zhao
e3f9074f4a Object.create doesn't work well with CustomEvent in Chrome 43 2015-09-06 10:27:24 +02:00
Max Brunsfeld
5c73e5a001 Add CommandRegistry::onDidDispatch 2015-08-24 14:10:02 -07:00
Ivan Zuzak
9aa78606b3 Catch both string and object targets 2015-06-22 18:47:41 +02:00
Ivan Zuzak
d47737718b Throw error for commands with non-function callbacks 2015-06-22 08:30:01 +02:00
Thomas Johansen
97f817c542 📝 Add sentence about lowercasing command names 2015-05-29 21:51:27 +02:00
Thomas Johansen
b4ff2e15d1 📝 Stronger wording, and change event to action 2015-05-23 00:03:01 +02:00
Thomas Johansen
dfd365cf51 📝 Rephrase the description of event 2015-05-22 23:42:23 +02:00
Thomas Johansen
93eeda1ccc 📝 Document command name standard
Resolves #6893
2015-05-22 23:29:59 +02:00
Kevin Sawicki
84bab1c67b Use selector validator provided by clear-cut 2015-04-13 18:03:14 -07:00
Kevin Sawicki
4c6722832b ⬆️ clear-cut@2.0 2015-04-13 18:01:40 -07:00
Kevin Sawicki
5449658011 Remove specificity caching now handled by clear-cut 2015-04-13 17:47:25 -07:00
Kevin Sawicki
590a4b0fd5 Add explicit return after for loop 2015-03-19 11:48:40 -07:00
Kevin Sawicki
ce33e63532 selector-parser -> selector-validator 2015-03-04 10:02:04 -08:00
Kevin Sawicki
c172f78ab5 Use consistent selector error 2015-03-04 10:02:03 -08:00
Kevin Sawicki
2a12f7779d Add selector parser helper class 2015-03-04 10:02:03 -08:00
Kevin Sawicki
8ba098b640 Throw an error when adding an invalid selector 2015-03-04 10:02:03 -08:00
Nathan Sobo
d4b0b33d86 📝 ability to pass DOM elements to atom.commands.add 2014-12-05 09:44:52 -08:00
Nathan Sobo
08dd51a12f Merge pull request #4121 from atom/mb-inline-commands-in-palette
Include inline commands in the command palette
2014-11-10 10:25:36 -07:00
Nathan Sobo
832e7113f7 Include all inline commands on the bubble path in ::findCommands 2014-11-10 10:10:52 -07:00
Nathan Sobo
d48719ab1c Ignore jQuery and duplicates in CommandRegistry::findCommands
Now that jQuery has been patched to add inline listeners and inline
listeners are reported from findCommands, there’s no reason to include
commands based on $.fn.events. Also, we need to ensure the same command
doesn’t get added to the list twice since it could get added by both
inline and selector-based listeners.
2014-11-10 10:09:24 -07:00
Max Brunsfeld
0c40a1ef92 Include inline commands in command palette 2014-11-10 10:09:24 -07:00
Lee Dohm
d09c4010f6 Remove obsolete jQuery reference
Noticed that "soon" is now
2014-11-07 22:23:12 -08:00
Kevin Sawicki
d1fcfabf0b Move comment above module.exports
Make it parseable by donna

Refs atom/donna#2
2014-10-28 16:20:11 -07:00
Kevin Sawicki
de3703d1ea 📝 Mark CommandRegistry and atom.commands public 2014-10-23 14:08:09 -07:00
Kevin Sawicki
bbfac9430e Use -> instead of => 2014-10-14 18:06:40 -07:00
Nathan Sobo
1eb3d8bf99 Use ‘atom-text-editor’ custom tag name for TextEditorElement 2014-10-09 07:39:14 -07:00
Nathan Sobo
bc790ee838 Only try selector based listeners if target has .webkitMatchesSelector 2014-10-08 13:21:15 -07:00
Nathan Sobo
c39f2019db Remove unused __handledByCommandRegistry property 2014-10-08 11:56:50 -07:00
Nathan Sobo
f869edee2f Forward preventDefault to original event 2014-10-08 11:56:50 -07:00
Nathan Sobo
cdb4ed1327 Integrate jQuery::on and ::trigger with command registry dispatch 2014-10-08 11:56:50 -07:00
Nathan Sobo
0d55a377fb Support inline listeners
This extends the command registry to support listeners registered on
individual elements in addition to selectors. The analogy is inline
styles vs selector-based styles. I’m hoping this will be the foundation
of integrating cleanly with legacy commands registered via our
jQuery::command extension.
2014-10-08 11:56:50 -07:00
Nathan Sobo
7d71eeedf4 Break command dispatch as soon as currentTarget is null 2014-09-24 15:28:02 -06:00
Nathan Sobo
6d55bab4c8 Fix CommandRegistry::get/restoreSnapshot
I didn’t realize that deepClone was not handling functions correctly.
I’ve implemented clone manually to the exact depth needed instead.
2014-09-24 15:26:38 -06:00
Nathan Sobo
b7765d9416 Process commands invoked with jQuery trigger in CommandRegistry
Especially in specs, trigger has been used to invoke events. jQuery does
not invoke native listeners in this situation, so we use ::on to listen
for them instead. If we didn’t handle the event with a native capture
handler, we’ll still support invoking via trigger.
2014-09-24 14:34:29 -06:00
Nathan Sobo
7d31b17273 Use the CommandRegistry to register activation event listeners
Commands registered with the command registry will always be handled
first, so as long as we disable any listeners in the registry that were
already invoked for the current command, we don’t need to disable jQuery
methods before replaying the command after activating the package.

This commit adds the ability to call .disableInvokedListeners on the
event passed to the command listeners. This returns a function which
can be called to reenable them.
2014-09-24 14:34:28 -06:00
Nathan Sobo
066f6bf03c Forward stop[Immediate]Propagation to original event in CommandRegistry
Previously, stopping propagation would work on the synthetic bubbling
phase of the command registry itself, but the original event would
continue to propagate which is counterintuitive.
2014-09-24 14:34:28 -06:00
Nathan Sobo
40f8b990d0 Handle dispatching non-existent commands 2014-09-24 14:34:28 -06:00
Nathan Sobo
a492596f7f Allow atom.commands to participate in activationEvents
* Activation events can be handled via atom.commands
* Pre-existing listeners registered via atom.commands are disabled when
  replaying events for the activated package.
2014-09-24 14:34:28 -06:00
Nathan Sobo
2df5957f9b Restore commands after each spec
This commit adds the ability to get and restore snapshots of command
listeners. Whatever commands are installed before specs begin are
preserved, but commands added during specs are always cleared away.
2014-09-24 14:34:28 -06:00
Nathan Sobo
09b5ac887a Return whether a dispatched command matched a listener 2014-09-24 14:34:28 -06:00
Nathan Sobo
67ff8f4382 Don’t clear commands after specs
Commands are typically registered once at eval time. Clearing them
means that commands aren’t available except in the first spec.
2014-09-24 14:34:27 -06:00
Nathan Sobo
0c9fd46030 Add CommandRegistry::dispatch for tests 2014-09-24 14:34:27 -06:00