tracker: 16.0.3, fix local spritemap parsing

This commit is contained in:
nick-delirium 2025-03-21 15:10:00 +01:00
parent 1e2dde09b4
commit 7e065ab02f
No known key found for this signature in database
GPG key ID: 93ABD695DF5FDBA0
5 changed files with 28 additions and 4 deletions

View file

@ -1,3 +1,7 @@
## 16.0.3
- better handling for local svg spritemaps
## 16.0.2 ## 16.0.2
- fix attributeSender key generation to prevent calling native methods on objects - fix attributeSender key generation to prevent calling native methods on objects

View file

@ -1,7 +1,7 @@
{ {
"name": "@openreplay/tracker", "name": "@openreplay/tracker",
"description": "The OpenReplay tracker main package", "description": "The OpenReplay tracker main package",
"version": "16.0.2", "version": "16.0.3",
"keywords": [ "keywords": [
"logging", "logging",
"replay" "replay"

View file

@ -37,9 +37,29 @@ async function parseUseEl(
return return
} }
const [url, symbolId] = href.split('#') let [url, symbolId] = href.split('#')
if (!url || !symbolId) {
console.debug('Openreplay: Invalid xlink:href or href found on <use>.') // happens if svg spritemap is local, fastest case for us
if (!url && symbolId) {
const symbol = document.querySelector(href)
if (symbol) {
const inlineSvg = `
<svg xmlns="http://www.w3.org/2000/svg" viewBox="${symbol.getAttribute('viewBox') || '0 0 24 24'}">
${symbol.innerHTML}
</svg>
`.trim()
iconCache[symbolId] = inlineSvg
return inlineSvg
} else {
console.warn('Openreplay: Sprite symbol not found in the document.')
return
}
}
if (!url && !symbolId) {
console.warn('Openreplay: Invalid xlink:href or href found on <use>.')
return return
} }