mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 23:37:04 +00:00
Make constructor parameter optional
This commit is contained in:
Vendored
+1
-1
@@ -10,7 +10,7 @@ interface ExtendedKeyboardEvent extends KeyboardEvent {
|
||||
|
||||
interface MousetrapStatic {
|
||||
(el: Element): MousetrapInstance;
|
||||
new (el: Element): MousetrapInstance;
|
||||
new (el?: Element): MousetrapInstance;
|
||||
addKeycodes(keycodes: { [key: number]: string }): void;
|
||||
stopCallback: (e: ExtendedKeyboardEvent, element: Element, combo: string) => boolean;
|
||||
bind(keys: string|string[], callback: (e: ExtendedKeyboardEvent, combo: string) => any, action?: string): void;
|
||||
|
||||
@@ -49,7 +49,11 @@ Mousetrap.reset();
|
||||
// event handler to the form element only, instead of the entire document.
|
||||
var element = document.querySelector('form');
|
||||
var instance = new Mousetrap(element);
|
||||
instance.bind('mod+s', function(){ console.log('Instance Saved'); });
|
||||
instance.bind('mod+s', function () { console.log('Instance Saved'); });
|
||||
|
||||
// Test that we can create an instance of mousetrap without passing element to the constructor.
|
||||
var documentInstance = new Mousetrap();
|
||||
documentInstance.bind('mod+s', function () { console.log('documentInstance Saved'); });
|
||||
|
||||
// Test that the factory method works as well.
|
||||
Mousetrap(element).bind('mod+s', function(){ console.log('Factory Saved'); });
|
||||
|
||||
Reference in New Issue
Block a user