diff --git a/src/component/utils/__tests__/getContentEditableContainer-test.js b/src/component/utils/__tests__/getContentEditableContainer-test.js deleted file mode 100644 index c673027cb8..0000000000 --- a/src/component/utils/__tests__/getContentEditableContainer-test.js +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @emails oncall+draft_js - * @flow - * @format - */ - -'use strict'; - -jest.mock('ReactDOM'); - -const getContentEditableContainer = require('getContentEditableContainer'); - -test('fails if no Node is found for the editorContainer', () => { - /* $FlowFixMe(>=0.99.0 site=www) This comment suppresses an error found when - * Flow v0.99 was deployed. To see the error delete this comment and run - * Flow. */ - require('ReactDOM').findDOMNode.mockImplementation(() => null); - // $FlowExpectedError - expect(() => getContentEditableContainer({})).toThrow('Missing editorNode'); -}); - -test('fails if the firstChild of editorConainer is not an HTMLElement', () => { - const editor = {editorContainer: {}}; - const editableContainer = document.createTextNode('text'); - const editorContainerNode = {firstChild: editableContainer}; - /* $FlowFixMe(>=0.99.0 site=www) This comment suppresses an error found when - * Flow v0.99 was deployed. To see the error delete this comment and run - * Flow. */ - require('ReactDOM').findDOMNode.mockImplementation(() => editorContainerNode); - // $FlowExpectedError - expect(() => getContentEditableContainer(editor)).toThrow( - 'editorNode.firstChild is not an HTMLElement', - ); -}); - -test(`returns the firstChild of editor.editorContainer's DOM node`, () => { - const editor = {editorContainer: {}}; - const editableContainer = document.createElement('div'); - const editorContainerNode = {firstChild: editableContainer}; - /* $FlowFixMe(>=0.99.0 site=www) This comment suppresses an error found when - * Flow v0.99 was deployed. To see the error delete this comment and run - * Flow. */ - require('ReactDOM').findDOMNode.mockImplementation(() => editorContainerNode); - - // $FlowExpectedError - expect(getContentEditableContainer(editor)).toBe(editableContainer); - expect(require('ReactDOM').findDOMNode).toHaveBeenCalledWith( - editor.editorContainer, - ); -}); diff --git a/src/component/utils/getContentEditableContainer.js b/src/component/utils/getContentEditableContainer.js index 887f1485a1..0adc4ef2eb 100644 --- a/src/component/utils/getContentEditableContainer.js +++ b/src/component/utils/getContentEditableContainer.js @@ -13,13 +13,11 @@ import type DraftEditor from 'DraftEditor.react'; -const ReactDOM = require('ReactDOM'); - const invariant = require('invariant'); const isHTMLElement = require('isHTMLElement'); function getContentEditableContainer(editor: DraftEditor): HTMLElement { - const editorNode = ReactDOM.findDOMNode(editor.editorContainer); + const editorNode = editor.editorContainer; invariant(editorNode, 'Missing editorNode'); invariant( isHTMLElement(editorNode.firstChild),