( dehydratedData: DehydratedData | null, path: ?InspectedElementPath, )
| 327 | } |
| 328 | |
| 329 | export function hydrateHelper( |
| 330 | dehydratedData: DehydratedData | null, |
| 331 | path: ?InspectedElementPath, |
| 332 | ): Object | null { |
| 333 | if (dehydratedData !== null) { |
| 334 | const {cleaned, data, unserializable} = dehydratedData; |
| 335 | |
| 336 | if (path) { |
| 337 | const {length} = path; |
| 338 | if (length > 0) { |
| 339 | // Hydration helper requires full paths, but inspection dehydrates with relative paths. |
| 340 | // In that event it's important that we adjust the "cleaned" paths to match. |
| 341 | return hydrate( |
| 342 | data, |
| 343 | cleaned.map(cleanedPath => cleanedPath.slice(length)), |
| 344 | unserializable.map(unserializablePath => |
| 345 | unserializablePath.slice(length), |
| 346 | ), |
| 347 | ); |
| 348 | } |
| 349 | } |
| 350 | |
| 351 | return hydrate(data, cleaned, unserializable); |
| 352 | } else { |
| 353 | return null; |
| 354 | } |
| 355 | } |
no test coverage detected