Description
web-vitals/src/lib/getSelector.ts
Line 34 in 0a87ab0
We picked up a scenario where getSelector() created an invalid selector:
class="layout-block product-layout-block "
The key thing is the space after the class names. This results in an extra dot being added to the selector:
'layout-block.product-layout-block.'
A simple fix would be to trim the class first:
? '.' + el.className.trim().replace(/\s+/g, '.')
It's probably also with checking for class names with just a space and IDs with leading or trailing spaces.
Is there any reason to limit the selector to 99 characters at this point? I know GA4 has a limit, but I split the selector in two to get around it, and now that will not work because of this limit.