Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update miscellaneous parts of the source to reasonably modern language alternatives, remove polyfills, improve some JSDoc comments, remove traces of IE #2114

Merged
merged 2 commits into from
Jul 16, 2023

Conversation

trusktr
Copy link
Member

@trusktr trusktr commented Jul 3, 2023

Continues from

Part of

Summary

Updated a bunch of pieces of code to using modern patterns. Avoided refactoring, mostly changes happened inline, or were small refactorings only.

Some things that we updated:

  • var -> let/const
  • function () {} -> () => {}
  • merge() -> Object.assign()
  • a.concat(b) -> [...a, ...b]
  • Object.assign({}, a, b) -> {...a, ...b}
  • (function() {...})() -> {...}
  • [].slice.call(a) -> Array.from(a)
  • hasOwn(a, b) -> Object.keys(a).includes(b)
  • for (let i = 0; i<len; i++) const item = arr[i] -> for (const item of arr)
  • {foo: function() {}} -> {foo() {}}
  • "..." + a + "..." -> `...${a}...`
  • etc

Deleted

  • CSS var polyfill
  • replaceState/pushState fallback
  • IE fallbacks

BREAKING: In a minority of cases syntax updates may break apps running in very old browsers (such as Internet Explorer), or apps that build Docsify in a custom way with old build tools. To upgrade, build Docsify for older browsers in a custom way, or update existing build tools to handle newer syntax.

DEPRECATED: $docsify.themeColor is deprecated and will be eventually removed, use a --theme-color CSS variable in your style sheet.

What kind of change does this PR introduce?

Code style update
Refactor
Docs

For any code change,

  • Related documentation has been updated if needed
  • Related tests have been updated or tests have been added

Does this PR introduce a breaking change? (check one)

  • Yes (see above)
  • No

Related issue, if any:

Simplification and modernization issue: #2104

Tested in the following browsers:

  • Chrome
  • Firefox
  • Safari
  • Edge
  • IE

@vercel
Copy link

vercel bot commented Jul 3, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docsify-preview ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 16, 2023 5:30pm

@trusktr trusktr marked this pull request as ready for review July 3, 2023 08:30
@codesandbox-ci
Copy link

codesandbox-ci bot commented Jul 3, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit b621e0e:

Sandbox Source
docsify-template Configuration

@trusktr trusktr mentioned this pull request Jul 3, 2023
17 tasks
</style>
`).trim()
);
},
Copy link
Member Author

@trusktr trusktr Jul 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If someone writes

window.$docsify = {
  themeColor: 'deeppink'
}

they will see this in console:

Screenshot 2023-07-02 at 4 53 07 PM

We can remove deprecations after some time. Maybe 6 months? Or 10 months?

…language alternatives, remove polyfills, improve some JSDoc comments, remove traces of IE

BREAKING: In a minority of cases syntax updates may break apps running in very old browsers (such as Internet Explorer), or apps that build Docsify in a custom way with old build tools. To upgrade, build Docsify for older browsers in a custom way, or update existing build tools to handle newer syntax.

DEPRECATED: `$docsify.themeColor` is deprecated and will be eventually removed, use a `--theme-color` CSS variable in your style sheet.
Copy link
Member

@Koooooo-7 Koooooo-7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
Those changes recently seems a little big radical, I would prefer that we may need more members review.
cc @sy-records @jhildenbiddle

@trusktr
Copy link
Member Author

trusktr commented Jul 6, 2023

If someone disapproves and prefers to remove changes like for(;;)->for(of), etc, we can do that.

All the current features are well supported in browsers today, all tests pass, and the deployment looks good!

Note: The Vue feature has not been working in Vercel deployments for quite some time. It has been broken in Vercel since before any of my recent changes (before delete-ssr). I'm not sure if it was always broken or when it broke.

Base automatically changed from update-rollup to develop July 16, 2023 17:16
@@ -62,4 +62,3 @@ If yes, please describe the impact and migration path for existing applications:
- [ ] Firefox
- [ ] Safari
- [ ] Edge
- [ ] IE
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No more! 🥳

@trusktr trusktr merged commit 7da3521 into develop Jul 16, 2023
@trusktr trusktr deleted the modernize-source-code branch July 16, 2023 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants