Reminder that `typeof null` is 'object'

Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/discussions/2619#discussioncomment-5757274
This commit is contained in:
Raymond Hill 2023-04-28 16:59:14 -04:00
parent c31e087946
commit 536bfb3387
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 2 additions and 2 deletions

View File

@ -145,12 +145,12 @@ function renderData(data, depth = 0) {
} }
return out.join('\n'); return out.join('\n');
} }
if ( typeof data !== 'object' ) { if ( typeof data !== 'object' || data === null ) {
return `${indent}${data}`; return `${indent}${data}`;
} }
const out = []; const out = [];
for ( const [ name, value ] of Object.entries(data) ) { for ( const [ name, value ] of Object.entries(data) ) {
if ( typeof value === 'object' ) { if ( typeof value === 'object' && value !== null ) {
out.push(`${indent}${name}:`); out.push(`${indent}${name}:`);
out.push(renderData(value, depth + 1)); out.push(renderData(value, depth + 1));
continue; continue;