Fix fit to content (#841)

* Fix: avoid to select defs or title as parentElement

* Fix: fix problem when nothing is drawing
master
cg-scorpio 2022-10-16 15:43:58 +02:00 committed by GitHub
parent aabd593123
commit cb2fe733dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 7 deletions

View File

@ -974,13 +974,15 @@ export const getVisibleElements = (parentElement) => {
}
const contentElems = []
const children = parentElement.children
// eslint-disable-next-line array-callback-return
Array.from(children, (elem) => {
if (elem.getBBox) {
contentElems.push(elem)
}
})
if (parentElement) {
const children = parentElement.children
// eslint-disable-next-line array-callback-return
Array.from(children, (elem) => {
if (elem.getBBox) {
contentElems.push(elem)
}
})
}
return contentElems.reverse()
}