Skip to content

Commit 0b3b303

Browse files
committed
fix(transform): check all console.error args in Fragment warning suppression
React 18 calls console.error with a format string and separate arguments (e.g. console.error('Invalid prop `%s` supplied to `%s`', 'data-ds', 'React.Fragment')), so checking only arguments[0] missed the match. Join all arguments before checking for 'data-ds' and 'React.Fragment'.
1 parent f94d138 commit 0b3b303

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

packages/domscribe-transform/src/plugins/turbopack/turbopack.loader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ function buildClientGlobalsPreamble(options: TurbopackLoaderOptions): string {
156156
`window.__DOMSCRIBE_CONSOLE_PATCHED__=true;` +
157157
`var _ce=console.error;` +
158158
`console.error=function(){` +
159-
`if(typeof arguments[0]==='string'&&arguments[0].indexOf('data-ds')!==-1&&arguments[0].indexOf('React.Fragment')!==-1)return;` +
159+
`if(typeof arguments[0]==='string'){var _s=Array.prototype.join.call(arguments,' ');if(_s.indexOf('data-ds')!==-1&&_s.indexOf('React.Fragment')!==-1)return}` +
160160
`return _ce.apply(console,arguments)` +
161161
`}}`,
162162
);

packages/domscribe-transform/src/plugins/vite/vite.plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ export function domscribe(options: VitePluginOptions = {}): Plugin {
315315
`window.__DOMSCRIBE_CONSOLE_PATCHED__=true;` +
316316
`var _ce=console.error;` +
317317
`console.error=function(){` +
318-
`if(typeof arguments[0]==='string'&&arguments[0].indexOf('data-ds')!==-1&&arguments[0].indexOf('React.Fragment')!==-1)return;` +
318+
`if(typeof arguments[0]==='string'){var _s=Array.prototype.join.call(arguments,' ');if(_s.indexOf('data-ds')!==-1&&_s.indexOf('React.Fragment')!==-1)return}` +
319319
`return _ce.apply(console,arguments)` +
320320
`}}`,
321321
injectTo: 'head-prepend',

packages/domscribe-transform/src/plugins/webpack/webpack.plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ export class DomscribeWebpackPlugin {
277277
`window.__DOMSCRIBE_CONSOLE_PATCHED__=true;` +
278278
`var _ce=console.error;` +
279279
`console.error=function(){` +
280-
`if(typeof arguments[0]==='string'&&arguments[0].indexOf('data-ds')!==-1&&arguments[0].indexOf('React.Fragment')!==-1)return;` +
280+
`if(typeof arguments[0]==='string'){var _s=Array.prototype.join.call(arguments,' ');if(_s.indexOf('data-ds')!==-1&&_s.indexOf('React.Fragment')!==-1)return}` +
281281
`return _ce.apply(console,arguments)` +
282282
`}}` +
283283
`</script>`,

0 commit comments

Comments
 (0)