tracker: move domparser location inside observer
This commit is contained in:
parent
0ba1382c16
commit
2ee535f213
1 changed files with 7 additions and 3 deletions
|
|
@ -24,9 +24,12 @@ import {
|
||||||
|
|
||||||
const iconCache = {}
|
const iconCache = {}
|
||||||
const svgUrlCache = {}
|
const svgUrlCache = {}
|
||||||
const domParser = new DOMParser()
|
|
||||||
|
|
||||||
async function parseUseEl(useElement: SVGUseElement, mode: 'inline' | 'dataurl' | 'svgtext') {
|
async function parseUseEl(
|
||||||
|
useElement: SVGUseElement,
|
||||||
|
mode: 'inline' | 'dataurl' | 'svgtext',
|
||||||
|
domParser: DOMParser,
|
||||||
|
) {
|
||||||
try {
|
try {
|
||||||
const href = useElement.getAttribute('xlink:href') || useElement.getAttribute('href')
|
const href = useElement.getAttribute('xlink:href') || useElement.getAttribute('href')
|
||||||
if (!href) {
|
if (!href) {
|
||||||
|
|
@ -165,6 +168,7 @@ export default abstract class Observer {
|
||||||
private readonly attributesMap: Map<number, Set<string>> = new Map()
|
private readonly attributesMap: Map<number, Set<string>> = new Map()
|
||||||
private readonly textSet: Set<number> = new Set()
|
private readonly textSet: Set<number> = new Set()
|
||||||
private readonly disableSprites: boolean = false
|
private readonly disableSprites: boolean = false
|
||||||
|
private readonly domParser = new DOMParser()
|
||||||
constructor(
|
constructor(
|
||||||
protected readonly app: App,
|
protected readonly app: App,
|
||||||
protected readonly isTopContext = false,
|
protected readonly isTopContext = false,
|
||||||
|
|
@ -281,7 +285,7 @@ export default abstract class Observer {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isUseElement(node) && name === 'href' && !this.disableSprites) {
|
if (isUseElement(node) && name === 'href' && !this.disableSprites) {
|
||||||
parseUseEl(node, 'svgtext')
|
parseUseEl(node, 'svgtext', this.domParser)
|
||||||
.then((svgData) => {
|
.then((svgData) => {
|
||||||
if (svgData) {
|
if (svgData) {
|
||||||
this.app.send(SetNodeAttribute(id, name, `_$OPENREPLAY_SPRITE$_${svgData}`))
|
this.app.send(SetNodeAttribute(id, name, `_$OPENREPLAY_SPRITE$_${svgData}`))
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue