New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #9667: Updated createTextInstance to create the text node on correct document #10723
Changes from 9 commits
54e6f1d
d610579
716dcd1
cf0ac10
5509e8c
1ffced7
c66397c
459e2ab
205e561
4b19c77
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1117,5 +1117,35 @@ describe('ReactDOMFiber', () => { | |
'to empty a container.', | ||
); | ||
}); | ||
|
||
it('should render a text component with a text DOM node on the same document as the container', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've verified that this test case fails in the current master. |
||
// 1. Create a new document through the use of iframe | ||
// 2. Set up the spy to make asserts when a text component | ||
// is rendered inside the iframe container | ||
var textContent = 'Hello world'; | ||
var iframe = document.createElement('iframe'); | ||
document.body.appendChild(iframe); | ||
var iframeDocument = iframe.contentDocument; | ||
iframeDocument.write( | ||
'<!DOCTYPE html><html><head></head><body><div></div></body></html>', | ||
); | ||
iframeDocument.close(); | ||
var iframeContainer = iframeDocument.body.firstChild; | ||
|
||
var actualDocument; | ||
var textNode; | ||
iframeContainer.appendChildBackup = iframeContainer.appendChild; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good catch - goober from a previous attempt at it. |
||
|
||
spyOn(iframeContainer, 'appendChild').and.callFake(node => { | ||
actualDocument = node.ownerDocument; | ||
textNode = node; | ||
}); | ||
|
||
ReactDOM.render(textContent, iframeContainer); | ||
|
||
expect(textNode.textContent).toBe(textContent); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add an assertion on the number of calls for iframeContainer.appendChild here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sophiebits I've added this check. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sophiebits ping? |
||
expect(actualDocument).not.toBe(document); | ||
expect(actualDocument).toBe(iframeDocument); | ||
}); | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you put the annotation on the function getOwnerDocumentFromRootContainer's definition? It's necessary to "cancel out" the
: any
cast.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would I still need this
Document
type? I think flow should be able to infer, right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, we don't need this one any more.