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!
This commit is contained in:
Peter Blazejewicz
2017-12-17 17:02:12 +01:00
parent 6d9978eb72
commit e2971b3f44
2 changed files with 13 additions and 3 deletions
+7 -3
View File
@@ -4,7 +4,8 @@
// Drew Noakes <https://github.com/drewnoakes>,
// Thomas B Homburg <https://github.com/homburg>,
// Tatu Tamminen <https://github.com/ttamminen>,
// Uwe Wiemer <https://github.com/hallowatcher>
// Uwe Wiemer <https://github.com/hallowatcher>,
// Peter Blazejewicz <https://github.com/peterblazejewicz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
@@ -97,6 +98,9 @@ declare namespace ReactModal {
declare class ReactModal extends React.Component<ReactModal.Props> {
/* 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;
}
+6
View File
@@ -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 = () => { };