Skip to content

Fix Object.prototype property names in autogenerated sidebars - #4309

Merged
delucis merged 2 commits into
withastro:mainfrom
athulsreekumar:fix-sidebar-prototype-dir-names
Oct 29, 2026
Merged

delucis merged 2 commits into
withastro:mainfrom
athulsreekumar:fix-sidebar-prototype-dir-names

Conversation

@athulsreekumar

Copy link
Copy Markdown
Contributor

Description

  • Closes Autogenerated sidebars omit directories named constructor #4306
  • Autogenerated sidebar groups omitted directories whose names match Object.prototype properties (e.g. constructor, toString, hasOwnProperty). makeDir() created directory nodes as plain {} objects, so in treeify(), currentNode[part] ||= makeDir(...) resolved to the inherited property (truthy) and never created the directory. Pages inside were dropped from the tree, which also broke current-page highlighting and prev/next links.
  • Directory nodes are now created with Object.create(null), so only real directory entries exist on them.
  • Added a regression test covering constructor, toString, and hasOwnProperty directories (fails without the fix), plus a patch changeset.

@changeset-bot

changeset-bot Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4c0888e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@astrojs/starlight Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@netlify

netlify Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for astro-starlight ready!

Name Link
🔨 Latest commit 4c0888e
🔍 Latest deploy log https://app.netlify.com/projects/astro-starlight/deploys/6ae314360587be635a68cb29
😎 Deploy Preview https://deploy-preview-4309--astro-starlight.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 99 (🔴 down 1 from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: -
View the detailed breakdown and full score reports
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions Bot added the 🌟 core Changes to Starlight’s main package label Oct 28, 2026
@astrobot-houston

Copy link
Copy Markdown
Contributor

Hello! Thank you for opening your first PR to Starlight! ✨

Here’s what will happen next:

  1. Our GitHub bots will run to check your changes.
    If they spot any issues you will see some error messages on this PR.
    Don’t hesitate to ask any questions if you’re not sure what these mean!

  2. In a few minutes, you’ll be able to see a preview of your changes on Netlify 🤩

  3. One or more of our maintainers will take a look and may ask you to make changes.
    We try to be responsive, but don’t worry if this takes a few days.

@delucis delucis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the PR @athulsreekumar! The switch to Object.create(null) seems to work as expected.

Left one small nit on the test, but otherwise the changes look good to me.

@delucis delucis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks again @athulsreekumar 🚀

@delucis delucis changed the title Fix autogenerated sidebar omitting directories named like Object.prototype properties Fix Object.prototype property names in autogenerated sidebars Oct 29, 2026
@delucis
delucis merged commit 3490c80 into withastro:main Oct 29, 2026
20 checks passed
@astrobot-houston astrobot-houston mentioned this pull request Oct 29, 2026
dadezzz pushed a commit to dadezzz/university_notes that referenced this pull request Nov 3, 2026
This PR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [@astrojs/starlight](https://starlight.astro.build) ([source](https://github.com/withastro/starlight/tree/HEAD/packages/starlight)) | [`0.42.7` → `0.42.8`](https://renovatebot.com/diffs/npm/@astrojs%2fstarlight/0.42.7/0.42.8) | ![age](https://developer.mend.io/api/mc/badges/age/npm/@astrojs%2fstarlight/0.42.8?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@astrojs%2fstarlight/0.42.7/0.42.8?slim=true) |

---

### Release Notes

<details>
<summary>withastro/starlight (@&#8203;astrojs/starlight)</summary>

### [`v0.42.8`](https://github.com/withastro/starlight/blob/HEAD/packages/starlight/CHANGELOG.md#0428)

[Compare Source](https://github.com/withastro/starlight/compare/@astrojs/starlight@0.42.7...@astrojs/starlight@0.42.8)

##### Patch Changes

- [#&#8203;4309](withastro/starlight#4309) [`3490c80`](withastro/starlight@3490c80) Thanks [@&#8203;athulsreekumar](https://github.com/athulsreekumar)! - Fixes autogenerated sidebar groups omitting directories whose names match `Object.prototype` properties, such as `constructor` or `toString`

- [#&#8203;4290](withastro/starlight#4290) [`bf93823`](withastro/starlight@bf93823) Thanks [@&#8203;RaphaelFakhri](https://github.com/RaphaelFakhri)! - Fixes missing last-updated dates in production builds for pages whose file path contains special characters

- [#&#8203;4295](withastro/starlight#4295) [`af9557e`](withastro/starlight@af9557e) Thanks [@&#8203;delucis](https://github.com/delucis)! - Fixes a formatting issue in some error messages impacting projects with Zod ≥4.5 installed

- [#&#8203;4299](withastro/starlight#4299) [`a103f38`](withastro/starlight@a103f38) Thanks [@&#8203;clean99](https://github.com/clean99)! - Fixes empty sidebars when autogenerating entries from the docs root directory using `directory: ''`

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xOTguMCIsInVwZGF0ZWRJblZlciI6IjQ0LjE5OC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
HiDeoo added a commit to HiDeoo/starlight that referenced this pull request Nov 4, 2026
* main: (42 commits)
  Replace `js-yaml` with `yaml` (withastro#4218)
  i18n(de): improve `configuration` and `frontmatter` (withastro#4335)
  i18n(de): fix `findst` typo (withastro#4333)
  i18n(de): fix `Überschriftenebene` spelling (withastro#4334)
  Preserve prototype-named directories in localized routes (withastro#4316)
  i18n(de): update `plugins.mdx` (withastro#4330)
  i18n(es): update icons.mdx (withastro#4329)
  i18n(es): update badges.mdx (withastro#4327)
  i18n(es): update asides.mdx and icons.mdx (withastro#4326)
  docs: add @heydeacon/starlight to community plugins (withastro#4319)
  i18n(ko-KR): update `community-content`, `plugins` (withastro#4321)
  i18n(ru): update translations (withastro#4320)
  Prettier update follow-up (withastro#4322)
  [i18nIgnore] Update to v1 of `prettier-plugin-astro` (withastro#4175)
  [ci] release (withastro#4298)
  docs: fix icon name search (withastro#4310)
  i18n(ja): update plugins.mdx and community-content.mdx (withastro#4311)
  Fix Object.prototype property names in autogenerated sidebars (withastro#4309)
  Fix last updated dates for file paths containing special characters (withastro#4290)
  Fix `size-limit` CI job (withastro#4308)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🌟 core Changes to Starlight’s main package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Autogenerated sidebars omit directories named constructor

3 participants