mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Fixed remaining DevTools broken tests by fixing a hydration/spread bug
This commit is contained in:
+7
-2
@@ -266,14 +266,19 @@ export function shallowDiffers(prev: Object, next: Object): boolean {
|
||||
}
|
||||
|
||||
export function getInObject(object: Object, path: Array<string | number>): any {
|
||||
return path.reduce((reduced: Object, attr: string | number): any => {
|
||||
return path.reduce((reduced: Object, attr: any): any => {
|
||||
if (reduced) {
|
||||
if (hasOwnProperty.call(reduced, attr)) {
|
||||
return reduced[attr];
|
||||
}
|
||||
if (typeof reduced[Symbol.iterator] === 'function') {
|
||||
// Convert iterable to array and return array[index]
|
||||
return [...reduced][attr];
|
||||
//
|
||||
// TRICKY
|
||||
// Don't use [...spread] syntax for this purpose.
|
||||
// This project uses @babel/plugin-transform-spread in "loose" mode which only works with Array values.
|
||||
// Other types (e.g. typed arrays, Sets) will not spread correctly.
|
||||
return Array.from(reduced)[attr];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user