FIX: Correctly render title-less poll widgets (#10837)

FIX: Correctly render title-less poll widgets (#10837)

RawHtml does not like receiving undefined values as html.

diff --git a/plugins/poll/assets/javascripts/widgets/discourse-poll.js.es6 b/plugins/poll/assets/javascripts/widgets/discourse-poll.js.es6
index 241bbb7..5ec3850 100644
--- a/plugins/poll/assets/javascripts/widgets/discourse-poll.js.es6
+++ b/plugins/poll/assets/javascripts/widgets/discourse-poll.js.es6
@@ -356,7 +356,9 @@ createWidget("discourse-poll-container", {
     } else if (options) {
       const contents = [];
 
-      contents.push(new RawHtml({ html: attrs.titleHTML }));
+      if (attrs.titleHTML) {
+        contents.push(new RawHtml({ html: attrs.titleHTML }));
+      }
 
       if (!checkUserGroups(this.currentUser, poll)) {
         contents.push(
diff --git a/plugins/poll/test/javascripts/widgets/discourse-poll-test.js.es6 b/plugins/poll/test/javascripts/widgets/discourse-poll-test.js.es6
index de1fe97..8978ee7 100644
--- a/plugins/poll/test/javascripts/widgets/discourse-poll-test.js.es6
+++ b/plugins/poll/test/javascripts/widgets/discourse-poll-test.js.es6
@@ -1,6 +1,9 @@
 import I18n from "I18n";
 import EmberObject from "@ember/object";
-import { moduleForWidget, widgetTest } from "discourse/tests/helpers/widget-test";
+import {
+  moduleForWidget,
+  widgetTest,
+} from "discourse/tests/helpers/widget-test";
 
 moduleForWidget("discourse-poll");
 
@@ -71,6 +74,14 @@ widgetTest("can vote", {
     assert.equal(requests, 1);
     assert.equal(find(".chosen").length, 1);
     assert.equal(find(".chosen").text(), "100%yes");
+    assert.equal(find(".toggle-results").text(), "Show vote");
+
+    await click(".toggle-results");
+    assert.equal(
+      find("li[data-poll-option-id='1f972d1df351de3ce35a787c89faad29']").length,
+      1
+    );
+    assert.equal(find(".toggle-results").text(), "Show results");
   },
 });
 

GitHub sha: 34c99da2

This commit appears in #10837 which was approved by pmusaraj. It was merged by CvX.