Skip to content

Commit 45de110

Browse files
refactor: use nullish coalescing assignment (#1229)
Co-authored-by: meteorlxy <meteor.lxy@foxmail.com>
1 parent a8c30ee commit 45de110

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

ecosystem/plugin-nprogress/src/client/nprogress.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ const css = (function () {
224224

225225
function getStyleProp(name: string): string {
226226
name = camelCase(name)
227-
return cssProps[name] || (cssProps[name] = getVendorProp(name))
227+
return (cssProps[name] ??= getVendorProp(name))
228228
}
229229

230230
function applyCss(element: HTMLElement, prop: string, value: string): void {

packages/markdown/src/plugins/importCodePlugin/importCodePlugin.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ export const importCodePlugin: PluginWithOptions<ImportCodePluginOptions> = (
4040

4141
// extract imported files to env
4242
if (importFilePath) {
43-
const importedFiles = env.importedFiles || (env.importedFiles = [])
44-
importedFiles.push(importFilePath)
43+
;(env.importedFiles ??= []).push(importFilePath)
4544
}
4645

4746
// render the import_code token as a fence token

packages/markdown/src/plugins/linksPlugin/linksPlugin.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ export const linksPlugin: PluginWithOptions<LinksPluginOptions> = (
130130
hrefAttr[1] = `${normalizedPath}${rawHash}`
131131

132132
// extract internal links for file / page existence check
133-
const links = env.links || (env.links = [])
134-
links.push({
133+
;(env.links ??= []).push({
135134
raw: hrefLink,
136135
relative: relativePath,
137136
absolute: absolutePath,

0 commit comments

Comments
 (0)