mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2025-01-20 18:05:37 +08:00
Adding types for recurseButtons method. Per https://github.com/hodgef/react-simple-keyboard/issues/960
This commit is contained in:
parent
9be8a095e0
commit
1166a2824f
5
src/lib/@types/index.d.ts
vendored
5
src/lib/@types/index.d.ts
vendored
@ -312,6 +312,11 @@ declare module 'simple-keyboard' {
|
|||||||
* Clears keyboard listeners and DOM elements.
|
* Clears keyboard listeners and DOM elements.
|
||||||
*/
|
*/
|
||||||
destroy(): void;
|
destroy(): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Iterate on each button (ForEach)
|
||||||
|
*/
|
||||||
|
recurseButtons(fn: any): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Keyboard;
|
export default Keyboard;
|
||||||
|
@ -880,7 +880,7 @@ class SimpleKeyboard {
|
|||||||
* Execute an operation on each button
|
* Execute an operation on each button
|
||||||
*/
|
*/
|
||||||
recurseButtons(fn) {
|
recurseButtons(fn) {
|
||||||
if (!fn) return false;
|
if (!fn) return;
|
||||||
|
|
||||||
Object.keys(this.buttonElements).forEach(buttonName =>
|
Object.keys(this.buttonElements).forEach(buttonName =>
|
||||||
this.buttonElements[buttonName].forEach(fn)
|
this.buttonElements[buttonName].forEach(fn)
|
||||||
|
@ -1376,7 +1376,7 @@ it('Keyboard buttonAttribute will warn about invalid entries', () => {
|
|||||||
it('Keyboard recurseButtons will not work without a valid param', () => {
|
it('Keyboard recurseButtons will not work without a valid param', () => {
|
||||||
setDOM();
|
setDOM();
|
||||||
const keyboard = new Keyboard();
|
const keyboard = new Keyboard();
|
||||||
expect(keyboard.recurseButtons()).toBe(false);
|
expect(keyboard.recurseButtons()).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Keyboard will not work with a DOM element param without class', () => {
|
it('Keyboard will not work with a DOM element param without class', () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user