From e2971b3f4414409dcb18a7d76f8a64aa7ba14252 Mon Sep 17 00:00:00 2001 From: Peter Blazejewicz Date: Sun, 17 Dec 2017 17:02:12 +0100 Subject: [PATCH] Fix definition of ReactModal.setAppElement This comit changes: - definition of static setAppElement method to support string type - as ReactModal allows to use selector instead of element reference - sample tests to include static method coverage Thanks! --- types/react-modal/index.d.ts | 10 +++++++--- types/react-modal/react-modal-tests.tsx | 6 ++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/types/react-modal/index.d.ts b/types/react-modal/index.d.ts index 715f4c3b01..16ee347cfd 100644 --- a/types/react-modal/index.d.ts +++ b/types/react-modal/index.d.ts @@ -4,7 +4,8 @@ // Drew Noakes , // Thomas B Homburg , // Tatu Tamminen , -// Uwe Wiemer +// Uwe Wiemer , +// Peter Blazejewicz // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -97,6 +98,9 @@ declare namespace ReactModal { declare class ReactModal extends React.Component { /* Override base styles for all instances of this component. */ static defaultStyles: ReactModal.Styles; - /* Call this to properly hide your application from assistive screenreaders and other assistive technologies while the modal is open. */ - static setAppElement(appElement: HTMLElement): void; + /** + * Call this to properly hide your application from assistive screenreaders + * and other assistive technologies while the modal is open. + */ + static setAppElement(appElement: string | HTMLElement): void; } diff --git a/types/react-modal/react-modal-tests.tsx b/types/react-modal/react-modal-tests.tsx index 8ce91bf15f..76958adbb3 100644 --- a/types/react-modal/react-modal-tests.tsx +++ b/types/react-modal/react-modal-tests.tsx @@ -1,6 +1,12 @@ import * as React from "react"; import ReactModal = require('react-modal'); +// tests for static method +// string +ReactModal.setAppElement("#main"); +// HTMLElement +ReactModal.setAppElement(document.getElementById("#main")); + class ExampleOfUsingReactModal extends React.Component { render() { const onAfterOpenFn = () => { };