How ShortSingh's pinned page comments stay attached to the right element across deploys
A developer describes a method for keeping client comments pinned to the correct element on a live website, even after deployments change its code. An early version relied on a single CSS selector per comment, which failed when build tools hashed class names, when layouts shifted, when lists re-rendered in a new order, and when scripts toggled state classes. The revised approach stores several independent identifiers for each pin, including a custom data attribute, a text fragment, a class-free path, and the click point as a fraction of the element's size. The lookup tries these identifiers in a fixed order, and each survives a different kind of change. The selector-building logic stops early at stable anchors such as element ids and test attributes, and it filters out classes that page scripts toggle dynamically.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in