Skip to content

Commit

Permalink
EZP-32400: Fixed displaying anchors for tables (#1745)
Browse files Browse the repository at this point in the history
* EZP-32400: Fixed displaying anchors for tables

* additional check whether previous sibling is not null
  • Loading branch information
Konrad Oboza committed Apr 28, 2021
1 parent d90d6be commit 64052bd
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
(function(global) {
const eZ = (global.eZ = global.eZ || {});
const TABLE_TAG_NAME = 'table';
const SVG_TAG_NAME = 'svg';
const HTML_NODE = 1;
const TEXT_NODE = 3;
const notInitializeElements = ['strong', 'em', 'u', 'sup', 'sub', 's'];
Expand Down Expand Up @@ -170,8 +172,15 @@

clearAnchor(element) {
const icon = element.querySelector('.ez-icon--anchor');

if (icon) {
const elementPreviousSibling = element.previousSibling;
const isTableWithAnchor =
element.tagName.toLowerCase() === TABLE_TAG_NAME &&
elementPreviousSibling &&
elementPreviousSibling.tagName.toLowerCase() === SVG_TAG_NAME;

if (isTableWithAnchor) {
elementPreviousSibling.remove();
} else if (icon) {
icon.remove();
} else {
element.classList.remove('ez-has-anchor');
Expand Down

0 comments on commit 64052bd

Please sign in to comment.