Skip to content

Commit

Permalink
Disable tests of recovering from node.normalize()
Browse files Browse the repository at this point in the history
According to facebook#9836 we're intentionally chosing to not support this until
we have better proof of this being a big need. E.g. to protect against
extensions. In a way that it's not better to push extensions to be fixed.
  • Loading branch information
sebmarkbage committed Jun 5, 2017
1 parent 5aa3153 commit 903b49f
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 54 deletions.
6 changes: 0 additions & 6 deletions scripts/fiber/tests-failing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,3 @@ src/renderers/dom/shared/__tests__/ReactDOMServerIntegration-test.js
* should not blow away user-entered text on successful reconnect to a controlled checkbox
* should not blow away user-selected value on successful reconnect to an uncontrolled select
* should not blow away user-selected value on successful reconnect to an controlled select

src/renderers/dom/shared/__tests__/ReactDOMTextComponent-test.js
* can reconcile text merged by Node.normalize() alongside other elements
* can reconcile text merged by Node.normalize()
* can reconcile text arbitrarily split into multiple nodes
* can reconcile text arbitrarily split into multiple nodes on some substitutions only
122 changes: 74 additions & 48 deletions src/renderers/dom/shared/__tests__/ReactDOMTextComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,33 @@ describe('ReactDOMTextComponent', () => {
expect(childNodes[2].data).toBe('bar');
});

it('can reconcile text merged by Node.normalize() alongside other elements', () => {
var el = document.createElement('div');
var inst = ReactDOM.render(
<div>{'foo'}{'bar'}{'baz'}<span />{'qux'}</div>,
el,
);

var container = ReactDOM.findDOMNode(inst);
container.normalize();

inst = ReactDOM.render(<div>{'bar'}{'baz'}{'qux'}<span />{'foo'}</div>, el);
container = ReactDOM.findDOMNode(inst);
expect(container.textContent).toBe('barbazquxfoo');
});

it('can reconcile text merged by Node.normalize()', () => {
/**
* The following Node.normalize() tests are intentionally failing.
* See #9836 tracking whether we'll need to fix this or if it's unnecessary.
*/

xit(
'can reconcile text merged by Node.normalize() alongside other elements',
() => {
var el = document.createElement('div');
var inst = ReactDOM.render(
<div>{'foo'}{'bar'}{'baz'}<span />{'qux'}</div>,
el,
);

var container = ReactDOM.findDOMNode(inst);
container.normalize();

inst = ReactDOM.render(
<div>{'bar'}{'baz'}{'qux'}<span />{'foo'}</div>,
el,
);
container = ReactDOM.findDOMNode(inst);
expect(container.textContent).toBe('barbazquxfoo');
},
);

xit('can reconcile text merged by Node.normalize()', () => {
var el = document.createElement('div');
var inst = ReactDOM.render(<div>{'foo'}{'bar'}{'baz'}</div>, el);

Expand All @@ -116,7 +127,7 @@ describe('ReactDOMTextComponent', () => {
expect(el.textContent).toBe('');
});

it('can reconcile text arbitrarily split into multiple nodes', () => {
xit('can reconcile text arbitrarily split into multiple nodes', () => {
var el = document.createElement('div');
var inst = ReactDOM.render(<div><span />{'foobarbaz'}</div>, el);

Expand All @@ -138,37 +149,52 @@ describe('ReactDOMTextComponent', () => {
expect(container.textContent).toBe('barbazqux');
});

it('can reconcile text arbitrarily split into multiple nodes on some substitutions only', () => {
xit(
'can reconcile text arbitrarily split into multiple nodes on some substitutions only',
() => {
var el = document.createElement('div');
var inst = ReactDOM.render(
<div>
<span />{'bar'}<span />{'foobarbaz'}{'foo'}{'barfoo'}<span />
</div>,
el,
);

var container = ReactDOM.findDOMNode(inst);
let childNodes = filterOutComments(ReactDOM.findDOMNode(inst).childNodes);
let textNode = childNodes[3];
textNode.textContent = 'foo';
container.insertBefore(
document.createTextNode('bar'),
childNodes[3].nextSibling,
);
container.insertBefore(
document.createTextNode('baz'),
childNodes[3].nextSibling,
);
let secondTextNode = childNodes[5];
secondTextNode.textContent = 'bar';
container.insertBefore(
document.createTextNode('foo'),
childNodes[5].nextSibling,
);

inst = ReactDOM.render(
<div>
<span />{'baz'}<span />{'barbazqux'}{'bar'}{'bazbar'}<span />
</div>,
el,
);
container = ReactDOM.findDOMNode(inst);
expect(container.textContent).toBe('bazbarbazquxbarbazbar');
},
);

xit('can unmount normalized text nodes', () => {
var el = document.createElement('div');
var inst = ReactDOM.render(
<div><span />{'bar'}<span />{'foobarbaz'}{'foo'}{'barfoo'}<span /></div>,
el,
);

var container = ReactDOM.findDOMNode(inst);
let childNodes = filterOutComments(ReactDOM.findDOMNode(inst).childNodes);
let textNode = childNodes[3];
textNode.textContent = 'foo';
container.insertBefore(
document.createTextNode('bar'),
childNodes[3].nextSibling,
);
container.insertBefore(
document.createTextNode('baz'),
childNodes[3].nextSibling,
);
let secondTextNode = childNodes[5];
secondTextNode.textContent = 'bar';
container.insertBefore(
document.createTextNode('foo'),
childNodes[5].nextSibling,
);

inst = ReactDOM.render(
<div><span />{'baz'}<span />{'barbazqux'}{'bar'}{'bazbar'}<span /></div>,
el,
);
container = ReactDOM.findDOMNode(inst);
expect(container.textContent).toBe('bazbarbazquxbarbazbar');
ReactDOM.render(<div>{''}{'foo'}{'bar'}</div>, el);
el.normalize();
ReactDOM.render(<div />, el);
expect(el.innerHTML).toBe('<div></div>');
});
});

0 comments on commit 903b49f

Please sign in to comment.