-
Notifications
You must be signed in to change notification settings - Fork 49.6k
Add support for Fibers in ReactDOMComponentTree and ReactTreeTraversal #8232
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,10 +15,13 @@ | |
import type { HostChildren } from 'ReactFiberReconciler'; | ||
|
||
var ReactFiberReconciler = require('ReactFiberReconciler'); | ||
var ReactDOMComponentTree = require('ReactDOMComponentTree'); | ||
var ReactDOMFeatureFlags = require('ReactDOMFeatureFlags'); | ||
|
||
var warning = require('warning'); | ||
|
||
var { precacheFiberNode } = ReactDOMComponentTree; | ||
|
||
type DOMContainerElement = Element & { _reactRootContainer: ?Object }; | ||
|
||
type Container = Element; | ||
|
@@ -51,8 +54,14 @@ var DOMRenderer = ReactFiberReconciler({ | |
recursivelyAppendChildren(container, children); | ||
}, | ||
|
||
createInstance(type : string, props : Props, children : HostChildren<Instance | TextInstance>) : Instance { | ||
const domElement = document.createElement(type); | ||
createInstance( | ||
type : string, | ||
props : Props, | ||
children : HostChildren<Instance | TextInstance>, | ||
internalInstanceHandle : Object | ||
) : Instance { | ||
const domElement : Instance = document.createElement(type); | ||
precacheFiberNode(internalInstanceHandle, domElement); | ||
recursivelyAppendChildren(domElement, children); | ||
if (typeof props.className !== 'undefined') { | ||
domElement.className = props.className; | ||
|
@@ -61,6 +70,13 @@ var DOMRenderer = ReactFiberReconciler({ | |
domElement.textContent = props.children; | ||
} else if (typeof props.children === 'number') { | ||
domElement.textContent = props.children.toString(); | ||
} else if (typeof props.dangerouslySetInnerHTML === 'object' && | ||
props.dangerouslySetInnerHTML !== null && | ||
typeof props.dangerouslySetInnerHTML.__html === 'string') { | ||
domElement.innerHTML = props.dangerouslySetInnerHTML.__html; | ||
} | ||
if (typeof props.id === 'string') { | ||
domElement.id = props.id; | ||
} | ||
return domElement; | ||
}, | ||
|
@@ -81,11 +97,20 @@ var DOMRenderer = ReactFiberReconciler({ | |
domElement.textContent = newProps.children; | ||
} else if (typeof newProps.children === 'number') { | ||
domElement.textContent = newProps.children.toString(); | ||
} else if (typeof newProps.dangerouslySetInnerHTML === 'object' && | ||
newProps.dangerouslySetInnerHTML !== null && | ||
typeof newProps.dangerouslySetInnerHTML.__html === 'string') { | ||
domElement.innerHTML = newProps.dangerouslySetInnerHTML.__html; | ||
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. Does switching away from dangerouslySetInnerHTML work? 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. No this is broken in more than one way. We have an issue on it in the Umbrella. |
||
} | ||
if (typeof newProps.id === 'string') { | ||
domElement.id = newProps.id; | ||
} | ||
}, | ||
|
||
createTextInstance(text : string) : TextInstance { | ||
return document.createTextNode(text); | ||
createTextInstance(text : string, internalInstanceHandle : Object) : TextInstance { | ||
var textNode : TextInstance = document.createTextNode(text); | ||
precacheFiberNode(internalInstanceHandle, textNode); | ||
return textNode; | ||
}, | ||
|
||
commitTextUpdate(textInstance : TextInstance, oldText : string, newText : string) : void { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
why does this fail? sounds like something that should pass
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.
I think the error happens now because the event fires, so the expect does, but not yet sure why it isn't dispatched correctly.