From 318f45a2dc91696e4f676d43c38d804fe256bb27 Mon Sep 17 00:00:00 2001 From: littlesaya Date: Tue, 26 Jan 2021 12:30:07 +0800 Subject: [PATCH] 'action.icon' can be a function when set iconPack to 'callback' --- src/js/show.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/js/show.js b/src/js/show.js index 1466bef..b669943 100644 --- a/src/js/show.js +++ b/src/js/show.js @@ -314,7 +314,11 @@ const createAction = (action, toastObject) => { el.classList.add('ripple'); if (action.text) { - el.text = action.text + if (el.tagName === 'A') { + el.text = action.text + } else { + el.innerText = action.text; + } } if (action.href) { @@ -370,6 +374,14 @@ const createAction = (action, toastObject) => { }) } + break; + case 'callback': + let callback = (action.icon && action.icon instanceof Function) ? action.icon : null; + + if(callback) { + iel = callback(iel); + } + break; default: iel.classList.add('material-icons');