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

Validation too strict for stylesheet and scripts #3128

Closed
teikjun opened this issue Jul 27, 2020 · 0 comments · Fixed by #3120
Closed

Validation too strict for stylesheet and scripts #3128

teikjun opened this issue Jul 27, 2020 · 0 comments · Fixed by #3120
Labels
bug An error in the Docusaurus core causing instability or issues with its execution

Comments

@teikjun
Copy link
Contributor

teikjun commented Jul 27, 2020

🐛 Bug Report

The validation for stylesheets does not accept unknown fields.
The validation for scripts does not accept both defer and async.
As noted in this article, if you specify both, async takes precedence on modern browsers, while older browsers that support defer but not async will fallback to defer. So, it is valid to have both.

Have you read the Contributing Guidelines on issues?

Yes

To Reproduce

  1. Use the following config in docusaurus.config.js (this config comes from a user on discord):
  stylesheets: [
    {
      href: '/katex/katex.min.css',
      type: 'text/css',
      integrity:
        'sha384-zB1R0rpPzHqg7Kpt0Aljp8JPLqbXI3bhnPWROx27a9N0Ll6ZP/+DiW/UqRcLbRjq',
      crossorigin: 'anonymous',
    },
  ],
  scripts: [
    {
      src: `/analytics.js`,
      async: true,
      defer: true,
    },
  ],
  1. You should get the following error:
Error: "scripts[0]" does not match any of the allowed types
"stylesheets[0]" does not match any of the allowed types

Expected behavior

This should pass the validation.

Actual Behavior

ValidationError raised.

Your Environment

  • Docusaurus version used: alpha.59
  • Environment name and version (e.g. Chrome 78.0.3904.108, Node.js 10.17.0): Firefox, Node.js 13.11.0
  • Operating system and version (desktop or mobile): Windows
@teikjun teikjun added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Jul 27, 2020
@Josh-Cena Josh-Cena removed the status: needs triage This issue has not been triaged by maintainers label Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants