Repository navigation
fix: look up map and layer IDs from outside as own keys only - #149
Merged
Merged
Conversation
Map IDs and layer IDs reach the app from the state URL and localStorage. Read them through a small pure function, ownEntry, so an ID that is not an own key behaves like any other unknown ID. cacheHash is now created without a prototype, and getPoiLayer uses the same lookup in the app and in sources. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
addMarker and clearMarker are public and take a layer ID, so read the layer through ownEntry there and in the source methods addPoi and clearPoi. Also note in the changelog that map IDs must be strings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kochizufan
marked this pull request as ready for review
October 30, 2026 19:54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Map IDs and layer IDs reach the app from the state URL and from
localStorage. This change makes those lookups accept own keys only, so an ID that the app does not hold is treated like any other unknown ID.ownEntry(record, key)insrc/own-lookup.ts. It returns a value only for a string key that the record itself owns. It is not exported from the package entry and adds nothing toMaplatApp.prototype.cacheHashis now created withObject.create(null), and all 16 reads insrc/index.tsand both reads insrc/element.tsgo throughownEntry. The write and the internal identity check keep direct indexing.getPoiLayerusesownEntryin bothsrc/index.tsandsrc/source/mixin.ts, and returnsundefinedfor a non-string ID.showPoiLayer,hidePoiLayerand restoring hidden layers all go through it.addMarker,clearMarker,addPoiandclearPoiread the layer throughownEntrytoo.spec/legacy-api-surface.spec.tsare unchanged. A numeric map ID no longer resolves; the public type isstring, and the changelog notes this.dist/is not rebuilt here.Verification
Before the fix means the new tests on code without the matching change:
6f3ef11for the first five E2E tests and four source checks,e9da6a0for the marker E2E test and source check. After the fix means this branch.e2e/own-key-lookup.spec.tsObject.prototypewas changed, a laterchangeMapdid not settle,getPoiLayerreturned a valuespec/own-lookup.spec.tsspec/own-key-lookup-sources.spec.tsindex.tsandelement.ts, noObject.create(null), directpoisreadsvitest runtsc --noEmiteslint src specThe new E2E test uses the real page because the failure it guards against is a Promise that never settles, which a stub does not show.
🤖 Generated with Claude Code