diff --git a/dataRender/anchor.js b/dataRender/anchor.js index a3659a9..42b7384 100644 --- a/dataRender/anchor.js +++ b/dataRender/anchor.js @@ -45,32 +45,28 @@ jQuery.fn.dataTable.render.anchor = function ( innerText = data; } - if (attributes typeof 'function') { - var tagAttributes = attributes(data, row, meta); - } else { - var tagAttributes = attributes; - } + var attributes = attributes typeof 'function' ? attributes(data, row, meta) : attributes; - if (!tagAttributes.href) { + if (!attributes.href) { switch (type) { case 'mail': - tagAttributes.href = 'mailto:' + data; + attributes.href = 'mailto:' + data; break; case 'phone': - tagAttributes.href = 'tel:' + data.replace(/[^+\d]+/g, ''); + attributes.href = 'tel:' + data.replace(/[^+\d]+/g, ''); break; case 'link': case default: try { - tagAttributes.href = new URL(data); + attributes.href = new URL(data); } catch (e) { - tagAttributes.href = data; + attributes.href = data; } } } var anchorEl = jQuery(''); - anchorEl.attr(tagAttributes).text(innerText === null ? data : innerText); + anchorEl.attr(attributes).text(innerText); return anchorEl[0].outerText; };