Skip to content

Commit

Permalink
refactor: use nullish coalescing assignment (#1229)
Browse files Browse the repository at this point in the history
Co-authored-by: meteorlxy <meteor.lxy@foxmail.com>
  • Loading branch information
Mister-Hope and meteorlxy committed May 11, 2023
1 parent a8c30ee commit 45de110
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ecosystem/plugin-nprogress/src/client/nprogress.ts
Expand Up @@ -224,7 +224,7 @@ const css = (function () {

function getStyleProp(name: string): string {
name = camelCase(name)
return cssProps[name] || (cssProps[name] = getVendorProp(name))
return (cssProps[name] ??= getVendorProp(name))
}

function applyCss(element: HTMLElement, prop: string, value: string): void {
Expand Down
Expand Up @@ -40,8 +40,7 @@ export const importCodePlugin: PluginWithOptions<ImportCodePluginOptions> = (

// extract imported files to env
if (importFilePath) {
const importedFiles = env.importedFiles || (env.importedFiles = [])
importedFiles.push(importFilePath)
;(env.importedFiles ??= []).push(importFilePath)
}

// render the import_code token as a fence token
Expand Down
3 changes: 1 addition & 2 deletions packages/markdown/src/plugins/linksPlugin/linksPlugin.ts
Expand Up @@ -130,8 +130,7 @@ export const linksPlugin: PluginWithOptions<LinksPluginOptions> = (
hrefAttr[1] = `${normalizedPath}${rawHash}`

// extract internal links for file / page existence check
const links = env.links || (env.links = [])
links.push({
;(env.links ??= []).push({
raw: hrefLink,
relative: relativePath,
absolute: absolutePath,
Expand Down

0 comments on commit 45de110

Please sign in to comment.