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

Uncaught DOMException: Element.querySelectorAll: '> .dropdown-submenu > a' is not a valid selector #3691

Closed
yuchkkicn opened this issue Apr 30, 2024 · 5 comments · Fixed by #3694
Labels

Comments

@yuchkkicn
Copy link

in 1.6.0 version, may be have a one error

mkdocs.yml file have below content
image

However, you will find have a one error in browser
image

@pawamoy
Copy link
Sponsor Contributor

pawamoy commented May 2, 2024

Thank you, I was able to confirm the issue. I've edited the title accordingly.

It's possibly related to the changes made in #3649. @squidfunk could you take a look?

@pawamoy pawamoy added the Bug label May 2, 2024
@pawamoy pawamoy changed the title bug feedback Uncaught DOMException: Element.querySelectorAll: '> .dropdown-submenu > a' is not a valid selector May 2, 2024
@pawamoy
Copy link
Sponsor Contributor

pawamoy commented May 2, 2024

Here's a small repro. Extract it, create a venv, install mkdocs, serve, and observe behavior by clicking on the Section 3 dropdown.

repro3691.zip

@squidfunk
Copy link
Sponsor Contributor

Here's what's happening: the slugify function that is used by toc.slugify seems to filter all characters out (as it only seems to keep ASCII), resulting in an "" (empty string) anchor. This leads to the following invalid selector:

<a href="#" class="dropdown-item">Section 3</a>

This selector is passed to document.querySelector which says that an empty value for an anchor is not valid. Solution: choose another slugify function. Here's what we recommend to the users of Material for MkDocs:

markdown_extensions:
  - toc:
      slugify: !!python/object/apply:pymdownx.slugs.slugify
        kwds:
          case: lower

Note that this requires to pip install pymdown-extensions. Sorry for linking to our documentation, MkDocs own documentation does not seem to have a section (yet?) on configuring slugification for non-Latin languages correctly.

@squidfunk
Copy link
Sponsor Contributor

Oops, yes, there was another error related to the refactoring. I opened a PR which fixes the problem for the reproduction #3694, but it might still be necessary to change the slugify function to something else.

@squidfunk
Copy link
Sponsor Contributor

@tomchristie do you have any plans when the fix will be released, e.g., as part of bugfix release like 1.6.1? The reported issue is hitting all users that use the default mkdocs theme and have at least one 3rd level section.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants