From b2eacaade15804ff2eca53ef9724d43dd62721d7 Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 13 Sep 2022 19:37:33 +0300 Subject: [PATCH] Update anchor.js --- dataRender/anchor.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/dataRender/anchor.js b/dataRender/anchor.js index 42b7384..b0c0ad5 100644 --- a/dataRender/anchor.js +++ b/dataRender/anchor.js @@ -45,29 +45,28 @@ jQuery.fn.dataTable.render.anchor = function ( innerText = data; } - var attributes = attributes typeof 'function' ? attributes(data, row, meta) : attributes; + var attrs = attributes typeof 'function' ? attributes(data, row, meta) : attributes; - if (!attributes.href) { + if (!attrs.href) { switch (type) { case 'mail': - attributes.href = 'mailto:' + data; + attrs.href = 'mailto:' + data; break; case 'phone': - attributes.href = 'tel:' + data.replace(/[^+\d]+/g, ''); + attrs.href = 'tel:' + data.replace(/[^+\d]+/g, ''); break; case 'link': case default: try { - attributes.href = new URL(data); + attrs.href = new URL(data); } catch (e) { - attributes.href = data; + attrs.href = data; } } } - var anchorEl = jQuery(''); - anchorEl.attr(attributes).text(innerText); + var anchorEl = jQuery(''); - return anchorEl[0].outerText; + return anchorEl.attr(attrs).text(innerText)[0].outerText; }; };