mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Merge pull request #2480 from spicyj/text-stability
Test that text spans aren't remounted needlessly
This commit is contained in:
@@ -18,12 +18,28 @@ describe('ReactTextComponent', function() {
|
||||
React = require('React');
|
||||
});
|
||||
|
||||
it('should escape the rootID', function(){
|
||||
it('should escape the rootID', function() {
|
||||
var ThisThingShouldBeEscaped = '">>> LULZ <<<"';
|
||||
var ThisThingWasBeEscaped = '">>> LULZ <<<"';
|
||||
var thing = <div><span key={ThisThingShouldBeEscaped}>LULZ</span></div>;
|
||||
var html = React.renderToString(thing);
|
||||
expect(html).not.toContain(ThisThingShouldBeEscaped);
|
||||
expect(html).toContain(ThisThingWasBeEscaped);
|
||||
})
|
||||
});
|
||||
|
||||
it('updates a mounted text component in place', function() {
|
||||
var el = document.createElement('div');
|
||||
var inst = React.render(<div>{'foo'}{'bar'}</div>, el);
|
||||
|
||||
var foo = inst.getDOMNode().children[0];
|
||||
var bar = inst.getDOMNode().children[1];
|
||||
expect(foo.tagName).toBe('SPAN');
|
||||
expect(bar.tagName).toBe('SPAN');
|
||||
|
||||
var inst = React.render(<div>{'baz'}{'qux'}</div>, el);
|
||||
// After the update, the spans should have stayed in place (as opposed to
|
||||
// getting unmounted and remounted)
|
||||
expect(inst.getDOMNode().children[0]).toBe(foo);
|
||||
expect(inst.getDOMNode().children[1]).toBe(bar);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user