Repository navigation
Fix Object.prototype property names in autogenerated sidebars - #4309
Conversation
…otype properties Fixes withastro#4306
🦋 Changeset detectedLatest commit: 4c0888e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
✅ Deploy Preview for astro-starlight ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Hello! Thank you for opening your first PR to Starlight! ✨ Here’s what will happen next:
|
delucis
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
Thanks again @athulsreekumar 🚀
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) |  |  | --- ### Release Notes <details> <summary>withastro/starlight (@​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 - [#​4309](withastro/starlight#4309) [`3490c80`](withastro/starlight@3490c80) Thanks [@​athulsreekumar](https://github.com/athulsreekumar)! - Fixes autogenerated sidebar groups omitting directories whose names match `Object.prototype` properties, such as `constructor` or `toString` - [#​4290](withastro/starlight#4290) [`bf93823`](withastro/starlight@bf93823) Thanks [@​RaphaelFakhri](https://github.com/RaphaelFakhri)! - Fixes missing last-updated dates in production builds for pages whose file path contains special characters - [#​4295](withastro/starlight#4295) [`af9557e`](withastro/starlight@af9557e) Thanks [@​delucis](https://github.com/delucis)! - Fixes a formatting issue in some error messages impacting projects with Zod ≥4.5 installed - [#​4299](withastro/starlight#4299) [`a103f38`](withastro/starlight@a103f38) Thanks [@​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-->
* 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) ...

Description
Object.prototypeproperties (e.g.constructor,toString,hasOwnProperty).makeDir()created directory nodes as plain{}objects, so intreeify(),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.Object.create(null), so only real directory entries exist on them.constructor,toString, andhasOwnPropertydirectories (fails without the fix), plus a patch changeset.