Skip to content
Snippets Groups Projects
Commit f145ceb3 authored by Christos's avatar Christos
Browse files

Merge branch 'fix-sibling-figcaption' into 'master'

fix(services): check if image exists before getting siblings

See merge request !589
parents 6eb4c565 556041a4
No related branches found
No related tags found
1 merge request!589fix(services): check if image exists before getting siblings
Pipeline #61240 passed with stages
in 2 minutes and 27 seconds
......@@ -50,10 +50,12 @@ export default ({ setPosition, position }) => {
`[data-fileid='${selection.node.attrs.fileid}']`,
);
if (!image) return;
const siblings = [...image.parentElement.children];
const figCaption = siblings.find(s => s.localName === 'figcaption');
const figCaption = siblings.find(s => s.tagName === 'FIGCAPTION');
if (!image || !figCaption) return;
if (!figCaption) return;
const imagePosition = image.getBoundingClientRect();
const figCaptionPosition = figCaption.getBoundingClientRect().height - 5;
const left = imagePosition.left - WaxSurface.left;
......
......@@ -53,10 +53,12 @@ export default ({ setPosition, position }) => {
`[data-fileid='${selection.node.attrs.fileid}']`,
);
if (!image) return;
const siblings = [...image.parentElement.children];
const figCaption = siblings.find(s => s.localName === 'figcaption');
const figCaption = siblings.find(s => s.tagName === 'FIGCAPTION');
if (!image || !figCaption) return;
if (!figCaption) return;
const imagePosition = image.getBoundingClientRect();
const figCaptionPosition = figCaption.getBoundingClientRect().height + 10;
const left = imagePosition.left - WaxSurface.left;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment