FIX: Allow safe html in poll options (#27741)
This commit is contained in:
parent
6022cc2af8
commit
f86a95d282
|
@ -3,6 +3,7 @@ import { fn } from "@ember/helper";
|
||||||
import { on } from "@ember/modifier";
|
import { on } from "@ember/modifier";
|
||||||
import { action } from "@ember/object";
|
import { action } from "@ember/object";
|
||||||
import { inject as service } from "@ember/service";
|
import { inject as service } from "@ember/service";
|
||||||
|
import { htmlSafe } from "@ember/template";
|
||||||
import routeAction from "discourse/helpers/route-action";
|
import routeAction from "discourse/helpers/route-action";
|
||||||
import icon from "discourse-common/helpers/d-icon";
|
import icon from "discourse-common/helpers/d-icon";
|
||||||
|
|
||||||
|
@ -37,7 +38,7 @@ export default class PollOptionsComponent extends Component {
|
||||||
{{icon "far-circle"}}
|
{{icon "far-circle"}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<span class="option-text">{{option.html}}</span>
|
<span class="option-text">{{htmlSafe option.html}}</span>
|
||||||
</button>
|
</button>
|
||||||
{{else}}
|
{{else}}
|
||||||
<button onclick={{routeAction "showLogin"}}>
|
<button onclick={{routeAction "showLogin"}}>
|
||||||
|
@ -54,7 +55,7 @@ export default class PollOptionsComponent extends Component {
|
||||||
{{icon "far-circle"}}
|
{{icon "far-circle"}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<span class="option-text">{{option.html}}</span>
|
<span class="option-text">{{htmlSafe option.html}}</span>
|
||||||
</button>
|
</button>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -74,7 +74,7 @@ export default class PollResultsStandardComponent extends Component {
|
||||||
"number.percent"
|
"number.percent"
|
||||||
count=option.percentage
|
count=option.percentage
|
||||||
}}</span>
|
}}</span>
|
||||||
<span class="option-text">{{option.html}}</span>
|
<span class="option-text">{{htmlSafe option.html}}</span>
|
||||||
</p>
|
</p>
|
||||||
<div class="bar-back">
|
<div class="bar-back">
|
||||||
<div
|
<div
|
||||||
|
|
|
@ -10,6 +10,21 @@ const OPTIONS = [
|
||||||
{ id: "6c986ebcde3d5822a6e91a695c388094", html: "Other", votes: 0, rank: 0 },
|
{ id: "6c986ebcde3d5822a6e91a695c388094", html: "Other", votes: 0, rank: 0 },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const IMAGE_OPTIONS = [
|
||||||
|
{
|
||||||
|
id: "1ddc47be0d2315b9711ee8526ca9d83f",
|
||||||
|
html: "<img src='upload://tpbXHFLPCTLWjyGvtyekmXQN49A.jpeg'></img>",
|
||||||
|
votes: 0,
|
||||||
|
rank: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "70e743697dac09483d7b824eaadb91e1",
|
||||||
|
html: "<img src='upload://eurierXHFETLWjHsdfLKKJDFLKJ.jpeg'></img>",
|
||||||
|
votes: 0,
|
||||||
|
rank: 0,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
module("Poll | Component | poll-options", function (hooks) {
|
module("Poll | Component | poll-options", function (hooks) {
|
||||||
setupRenderingTest(hooks);
|
setupRenderingTest(hooks);
|
||||||
|
|
||||||
|
@ -80,4 +95,21 @@ module("Poll | Component | poll-options", function (hooks) {
|
||||||
|
|
||||||
assert.strictEqual(count("li .d-icon-far-check-square:nth-of-type(1)"), 1);
|
assert.strictEqual(count("li .d-icon-far-check-square:nth-of-type(1)"), 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("single with images", async function (assert) {
|
||||||
|
this.setProperties({
|
||||||
|
isCheckbox: false,
|
||||||
|
options: IMAGE_OPTIONS,
|
||||||
|
votes: [],
|
||||||
|
});
|
||||||
|
|
||||||
|
await render(hbs`<PollOptions
|
||||||
|
@isCheckbox={{this.isCheckbox}}
|
||||||
|
@options={{this.options}}
|
||||||
|
@votes={{this.votes}}
|
||||||
|
@sendRadioClick={{this.toggleOption}}
|
||||||
|
/>`);
|
||||||
|
|
||||||
|
assert.strictEqual(count("li img"), 2);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue