-
Notifications
You must be signed in to change notification settings - Fork 46.4k
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
Fix crash on master introduced during the radio bugfix #10207
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f665727
Add a regression test that passes in Stack but fails in Fiber
gaearon d692bd3
Fix updateValueIfChanged() lazy path to work with DOM argument
gaearon be59a9e
Slightly reorder lines for clarity and record tests
gaearon 6899a50
Also test the change event code path
gaearon 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 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 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 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 |
---|---|---|
|
@@ -128,32 +128,41 @@ var inputValueTracking = { | |
inst._wrapperState.valueTracker = trackValueOnNode(node, inst); | ||
}, | ||
|
||
// TODO: in practice "subject" can currently be Stack instance, | ||
// Fiber, or DOM node. This is hard to understand. We should either | ||
// make it accept only DOM nodes, or only Fiber/Stack instances. | ||
updateValueIfChanged(subject: SubjectWithWrapperState | Fiber) { | ||
if (!subject) { | ||
return false; | ||
} | ||
var tracker = getTracker(subject); | ||
|
||
var isNode = (subject: any).nodeType === ELEMENT_NODE; | ||
var tracker = getTracker(subject); | ||
if (!tracker) { | ||
if (typeof (subject: any).tag === 'number') { | ||
if (isNode) { | ||
// DOM node | ||
inputValueTracking.trackNode((subject: any)); | ||
} else if (typeof (subject: any).tag === 'number') { | ||
// Fiber | ||
inputValueTracking.trackNode((subject: any).stateNode); | ||
} else { | ||
// Stack | ||
inputValueTracking.track((subject: any)); | ||
} | ||
return true; | ||
} | ||
|
||
var lastValue = tracker.getValue(); | ||
|
||
var node = subject; | ||
|
||
// TODO: remove check when the Stack renderer is retired | ||
if ((subject: any).nodeType !== ELEMENT_NODE) { | ||
var node; | ||
if (isNode) { | ||
// DOM node | ||
node = subject; | ||
} else { | ||
// Fiber and Stack | ||
node = ReactDOMComponentTree.getNodeFromInstance(subject); | ||
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. Just to be clear for myself 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. It does, yeah. See ReactDOMComponentTree.js#L190-L194 |
||
} | ||
|
||
var lastValue = tracker.getValue(); | ||
var nextValue = getValueFromNode(node); | ||
|
||
if (nextValue !== lastValue) { | ||
tracker.setValue(nextValue); | ||
return true; | ||
|
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.
do we also want to exercise the change plugin route? e.g. trigger a change event on the input.
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.
How to do this?
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.
SimulateNative.change(node)
should work, if the event triggered it passed through the function. It isn't specifically gonna catch a failure in Fiber but it covers the all paths throughupdateValueIfChanged
.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.
That was a great idea, thanks.