Currently we use this function to generate a mini HTML tree for a button that was clicked. In our Replay breadcrumbs, this isn't too useful to know its ancestors as we cannot search on it. It also bypasses our PII masking on attributes (e.g. it will serialize aria-label in plaintext).
With getsentry/sentry-javascript#7395 we will have additional data attribute node with the follow properties:
{
attributes: {
id: 'drop',
},
id: expect.any(Number),
tagName: 'button',
textContent: '***** ***** *** **** **',
},
We can provide a better "message" on the UI using these attributes. e.g. button#drop.className with text "Text Content" or <button id="drop" class="className"> with text "TextContent -- though masking will prevent useful text.