From ebe87f2b8a2cdbca424bff613cd764f184eefc8a Mon Sep 17 00:00:00 2001 From: Allie <13716824+ChildishGiant@users.noreply.github.com> Date: Sat, 27 Mar 2021 22:59:41 +0000 Subject: [PATCH] feat: :wastebasket: add warning when using deprecated setting --- js/toasts.js | 13 ++++++++++--- js/tooltip.js | 8 ++++++-- test/html/tooltip.html | 13 +++++++++---- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/js/toasts.js b/js/toasts.js index 7500b285dd..1e505765b2 100644 --- a/js/toasts.js +++ b/js/toasts.js @@ -21,8 +21,13 @@ */ this.options = $.extend({}, Toast.defaults, options); this.htmlMessage = this.options.html; + // Warn when using html + if (!!this.options.html) + console.warn( + 'The html option is deprecated and will be removed in the future. See https://github.com/materializecss/materialize/pull/49' + ); // If the new unsafeHTML is used, prefer that - if (!!this.options.unsafeHTML){ + if (!!this.options.unsafeHTML) { this.htmlMessage = this.options.unsafeHTML; } this.message = this.options.text; @@ -205,9 +210,11 @@ this.htmlMessage !== null && this.htmlMessage.nodeType === 1 && typeof this.htmlMessage.nodeName === 'string' - ) { //if the htmlMessage is an HTML node, append it directly + ) { + //if the htmlMessage is an HTML node, append it directly toast.appendChild(this.htmlMessage); - } else if (!!this.htmlMessage.jquery) { // Check if it is jQuery object, append the node + } else if (!!this.htmlMessage.jquery) { + // Check if it is jQuery object, append the node $(toast).append(this.htmlMessage[0]); } else { // Append as unsanitized html; diff --git a/js/tooltip.js b/js/tooltip.js index a14e8f3f6b..7fddf319d9 100644 --- a/js/tooltip.js +++ b/js/tooltip.js @@ -78,10 +78,14 @@ _setTooltipContent(tooltipContentEl) { tooltipContentEl.textContent = this.options.text; - if (!!this.options.html){ + if (!!this.options.html) { + // Warn when using html + console.warn( + 'The html option is deprecated and will be removed in the future. See https://github.com/materializecss/materialize/pull/49' + ); $(tooltipContentEl).append(this.options.html); } - if (!!this.options.unsafeHTML){ + if (!!this.options.unsafeHTML) { $(tooltipContentEl).append(this.options.unsafeHTML); } } diff --git a/test/html/tooltip.html b/test/html/tooltip.html index 19767e7cba..d6eb3c6c0a 100644 --- a/test/html/tooltip.html +++ b/test/html/tooltip.html @@ -25,8 +25,10 @@
@@ -34,9 +36,12 @@ -