Skip to content

TestUtils.renderIntoDocument doesn't function as expected in all browsers #3789

Closed
@ezequiel

Description

@ezequiel

Hi,

Here is my program (jsfiddle):

var Input = React.createClass({
    render: function() {
        return (
            <input 
                {...this.props}
            />
        );
    }
});

var TestUtils = React.addons.TestUtils;
var inputInstance = 
        TestUtils.renderIntoDocument(
            <Input
                value='abc'
            />
        );

var inputDOMNode = React.findDOMNode(inputInstance);

inputDOMNode.focus();

// Place cursor at the end.
inputDOMNode.setSelectionRange(3, 3);

// Should log 3 twice.
console.log(inputDOMNode.selectionStart);
console.log(inputDOMNode.selectionEnd);

Problem: 0 is logged twice in Chrome and Firefox.
What I expected: 3 is logged twice. We see this in Safari.

The interesting part is if we use React.render(..., document.body) instead of TestUtils.renderIntoDocument the program works as expected.

I am using:

  • Chrome 42.0.2311.135
  • Firefox 37.0.2
  • Safari 8.0.5 (10600.5.17)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions