Skip to content

Commit 9079d37

Browse files
committed
use nullish coalescing
1 parent b02d30d commit 9079d37

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

packages/view/src/drivers/handlebars/helpers/append.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ export default function append (stackName: string, context: any): void {
88
throw new Error('Provide a name when using the "append" handlebars helper.')
99
}
1010

11-
context.data.root = context.data.root || {}
12-
const stacks = context.data.root.stacks || {}
13-
const stack = stacks[stackName] || []
11+
context.data.root = context.data.root ?? {}
12+
const stacks = context.data.root.stacks ?? {}
13+
const stack = stacks[stackName] ?? []
1414

1515
// @ts-expect-error
1616
stack.push({ mode: 'append', data: context.fn(this) })

packages/view/src/drivers/handlebars/helpers/prepend.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ export default function prepend (stackName: string, context: any): void {
88
throw new Error('Provide a name when using the "prepend" handlebars helper.')
99
}
1010

11-
context.data.root = context.data.root || {}
12-
const stacks = context.data.root.stacks || {}
13-
const stack = stacks[stackName] || []
11+
context.data.root = context.data.root ?? {}
12+
const stacks = context.data.root.stacks ?? {}
13+
const stack = stacks[stackName] ?? []
1414

1515
// @ts-expect-error
1616
stack.unshift({ mode: 'prepend', data: context.fn(this) })

packages/view/src/drivers/handlebars/helpers/stack.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ export default function stack (name: string, context: any): string {
1515
throw new Error('Provide a name when using the "stack" handlebars helper.')
1616
}
1717

18-
const data = context.data.root || {}
19-
const stacks = data.stacks || {}
20-
const stack = stacks[name] || []
18+
const data = context.data.root ?? {}
19+
const stacks = data.stacks ?? {}
20+
const stack = stacks[name] ?? []
2121

2222
const content = stack
2323
.reduce((carry: string[], { mode, data }: { mode: string, data: string }) => {

0 commit comments

Comments
 (0)