commit
279bdc778b
|
@ -104,10 +104,7 @@ export function getClosest(elem, selector) {
|
||||||
*/
|
*/
|
||||||
export function getParents(elem, selector) {
|
export function getParents(elem, selector) {
|
||||||
const parents = [];
|
const parents = [];
|
||||||
let firstChar;
|
const firstChar = selector?.charAt(0);
|
||||||
if ( selector ) {
|
|
||||||
firstChar = selector.charAt(0);
|
|
||||||
}
|
|
||||||
// Get matches
|
// Get matches
|
||||||
for ( ; elem && elem !== document; elem = elem.parentNode ) {
|
for ( ; elem && elem !== document; elem = elem.parentNode ) {
|
||||||
if ( selector ) {
|
if ( selector ) {
|
||||||
|
@ -138,23 +135,13 @@ export function getParents(elem, selector) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Return parents if any exist
|
// Return parents if any exist
|
||||||
if ( parents.length === 0 ) {
|
return parents.length? parents : null;
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
return parents;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getParentsUntil(elem, parent, selector) {
|
export function getParentsUntil(elem, parent, selector) {
|
||||||
const parents = [];
|
const parents = [];
|
||||||
let parentType;
|
const parentType = parent?.charAt(0);
|
||||||
let selectorType;
|
const selectorType = selector?.selector.charAt(0);
|
||||||
if ( parent ) {
|
|
||||||
parentType = parent.charAt(0);
|
|
||||||
}
|
|
||||||
if ( selector ) {
|
|
||||||
selectorType = selector.charAt(0);
|
|
||||||
}
|
|
||||||
// Get matches
|
// Get matches
|
||||||
for ( ; elem && elem !== document; elem = elem.parentNode ) {
|
for ( ; elem && elem !== document; elem = elem.parentNode ) {
|
||||||
// Check if parent has been reached
|
// Check if parent has been reached
|
||||||
|
@ -210,9 +197,5 @@ export function getParentsUntil(elem, parent, selector) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Return parents if any exist
|
// Return parents if any exist
|
||||||
if ( parents.length === 0 ) {
|
return parents.length? parents : null;
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
return parents;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -529,7 +529,7 @@ export const importSvgString = function (xmlString) {
|
||||||
// Look for symbol and make sure symbol exists in image
|
// Look for symbol and make sure symbol exists in image
|
||||||
if (svgContext_.getImportIds(uid) && svgContext_.getImportIds(uid).symbol) {
|
if (svgContext_.getImportIds(uid) && svgContext_.getImportIds(uid).symbol) {
|
||||||
const parents = getParents(svgContext_.getImportIds(uid).symbol, '#svgroot');
|
const parents = getParents(svgContext_.getImportIds(uid).symbol, '#svgroot');
|
||||||
if (parents.length) {
|
if (parents?.length) {
|
||||||
useExisting = true;
|
useExisting = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue