File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -257,7 +257,7 @@ ctx.ReactOnRails = {
257
257
* Used by Rails server rendering to replay console messages.
258
258
*/
259
259
buildConsoleReplay ( ) : string {
260
- return buildConsoleReplay ( console . history ) ;
260
+ return buildConsoleReplay ( ) ;
261
261
} ,
262
262
263
263
/**
Original file line number Diff line number Diff line change @@ -11,7 +11,9 @@ declare global {
11
11
}
12
12
}
13
13
14
- export function consoleReplay ( consoleHistory : typeof console [ 'history' ] ) : string {
14
+ export function consoleReplay ( customConsoleHistory : typeof console [ 'history' ] | undefined = undefined ) : string {
15
+ const consoleHistory = customConsoleHistory ?? console . history ;
16
+
15
17
// console.history is a global polyfill used in server rendering.
16
18
// Must use Array.isArray instead of instanceof Array the history array is defined outside the vm if node renderer is used.
17
19
// In this case, the Array prototype used to define the array is not the same as the one in the global scope inside the vm.
@@ -41,6 +43,6 @@ export function consoleReplay(consoleHistory: typeof console['history']): string
41
43
return lines . join ( '\n' ) ;
42
44
}
43
45
44
- export default function buildConsoleReplay ( consoleHistory : typeof console [ 'history' ] ) : string {
45
- return RenderUtils . wrapInScriptTags ( 'consoleReplayLog' , consoleReplay ( consoleHistory ) ) ;
46
+ export default function buildConsoleReplay ( customConsoleHistory : typeof console [ 'history' ] | undefined = undefined ) : string {
47
+ return RenderUtils . wrapInScriptTags ( 'consoleReplayLog' , consoleReplay ( customConsoleHistory ) ) ;
46
48
}
You can’t perform that action at this time.
0 commit comments