DEV: Remove 'htmlSafe' string prototype extensions (#140)

Context: https://deprecations.emberjs.com/v3.x/#toc_ember-string-prototype_extensions
This commit is contained in:
Isaac Janzen 2022-06-01 11:37:01 -05:00 committed by GitHub
parent b9ac5516bf
commit fb73dda584
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 18 deletions

View File

@ -1,6 +1,7 @@
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component"; import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
import discourseComputed from "discourse-common/utils/decorators"; import discourseComputed from "discourse-common/utils/decorators";
import { and } from "@ember/object/computed"; import { and } from "@ember/object/computed";
import { htmlSafe } from "@ember/template";
export default AdComponent.extend({ export default AdComponent.extend({
classNames: ["amazon-product-links"], classNames: ["amazon-product-links"],
@ -157,27 +158,27 @@ export default AdComponent.extend({
@discourseComputed("amazon_width", "amazon_height") @discourseComputed("amazon_width", "amazon_height")
adWrapperStyle(w, h) { adWrapperStyle(w, h) {
return `width: ${w}px; height: ${h}px;`.htmlSafe(); return htmlSafe(`width: ${w}px; height: ${h}px;`);
}, },
@discourseComputed("mobile_amazon_width", "mobile_amazon_height") @discourseComputed("mobile_amazon_width", "mobile_amazon_height")
adWrapperStyleMobile(w, h) { adWrapperStyleMobile(w, h) {
return `width: ${w}px; height: ${h}px;`.htmlSafe(); return htmlSafe(`width: ${w}px; height: ${h}px;`);
}, },
@discourseComputed("mobile_amazon_width") @discourseComputed("mobile_amazon_width")
adTitleStyleMobile(w) { adTitleStyleMobile(w) {
return `width: ${w}px;`.htmlSafe(); return htmlSafe(`width: ${w}px;`);
}, },
@discourseComputed("user_input") @discourseComputed("user_input")
userInput(userInput) { userInput(userInput) {
return `${userInput}`.htmlSafe(); return htmlSafe(`${userInput}`);
}, },
@discourseComputed("user_input_mobile") @discourseComputed("user_input_mobile")
userInputMobile(userInput) { userInputMobile(userInput) {
return `${userInput}`.htmlSafe(); return htmlSafe(`${userInput}`);
}, },
@discourseComputed("currentUser.trust_level") @discourseComputed("currentUser.trust_level")

View File

@ -1,5 +1,6 @@
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component"; import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
import discourseComputed from "discourse-common/utils/decorators"; import discourseComputed from "discourse-common/utils/decorators";
import { htmlSafe } from "@ember/template";
export default AdComponent.extend({ export default AdComponent.extend({
serve_id: null, serve_id: null,
@ -13,7 +14,9 @@ export default AdComponent.extend({
@discourseComputed("serve_id", "placement") @discourseComputed("serve_id", "placement")
url(serveId, placement) { url(serveId, placement) {
return `//cdn.carbonads.com/carbon.js?serve=${serveId}&placement=${placement}`.htmlSafe(); return htmlSafe(
`//cdn.carbonads.com/carbon.js?serve=${serveId}&placement=${placement}`
);
}, },
@discourseComputed("currentUser.trust_level") @discourseComputed("currentUser.trust_level")

View File

@ -4,6 +4,7 @@ import loadScript from "discourse/lib/load-script";
import RSVP from "rsvp"; import RSVP from "rsvp";
import { scheduleOnce } from "@ember/runloop"; import { scheduleOnce } from "@ember/runloop";
import { isTesting } from "discourse-common/config/environment"; import { isTesting } from "discourse-common/config/environment";
import { htmlSafe } from "@ember/template";
let _loaded = false, let _loaded = false,
_promise = null, _promise = null,
@ -191,28 +192,24 @@ export default AdComponent.extend({
@discourseComputed("placement", "showAd") @discourseComputed("placement", "showAd")
classForSlot(placement, showAd) { classForSlot(placement, showAd) {
return showAd ? `adsense-${placement}`.htmlSafe() : ""; return showAd ? htmlSafe(`adsense-${placement}`) : "";
}, },
@discourseComputed("isResponsive", "isFluid") @discourseComputed("isResponsive", "isFluid")
autoAdFormat(isResponsive, isFluid) { autoAdFormat(isResponsive, isFluid) {
return isResponsive return isResponsive ? htmlSafe(isFluid ? "fluid" : "auto") : false;
? isFluid
? "fluid".htmlSafe()
: "auto".htmlSafe()
: false;
}, },
@discourseComputed("ad_width", "ad_height", "isResponsive") @discourseComputed("ad_width", "ad_height", "isResponsive")
adWrapperStyle(w, h, isResponsive) { adWrapperStyle(w, h, isResponsive) {
return (isResponsive ? "" : `width: ${w}; height: ${h};`).htmlSafe(); return htmlSafe(isResponsive ? "" : `width: ${w}; height: ${h};`);
}, },
@discourseComputed("adWrapperStyle", "isResponsive") @discourseComputed("adWrapperStyle", "isResponsive")
adInsStyle(adWrapperStyle, isResponsive) { adInsStyle(adWrapperStyle, isResponsive) {
return `display: ${ return htmlSafe(
isResponsive ? "block" : "inline-block" `display: ${isResponsive ? "block" : "inline-block"}; ${adWrapperStyle}`
}; ${adWrapperStyle}`.htmlSafe(); );
}, },
@discourseComputed("currentUser.trust_level") @discourseComputed("currentUser.trust_level")

View File

@ -4,6 +4,7 @@ import loadScript from "discourse/lib/load-script";
import { alias } from "@ember/object/computed"; import { alias } from "@ember/object/computed";
import RSVP from "rsvp"; import RSVP from "rsvp";
import { isTesting } from "discourse-common/config/environment"; import { isTesting } from "discourse-common/config/environment";
import { htmlSafe } from "@ember/template";
let _loaded = false, let _loaded = false,
_promise = null, _promise = null,
@ -286,14 +287,14 @@ export default AdComponent.extend({
@discourseComputed("width", "height") @discourseComputed("width", "height")
adWrapperStyle(w, h) { adWrapperStyle(w, h) {
if (w !== "fluid") { if (w !== "fluid") {
return `width: ${w}px; height: ${h}px;`.htmlSafe(); return htmlSafe(`width: ${w}px; height: ${h}px;`);
} }
}, },
@discourseComputed("width") @discourseComputed("width")
adTitleStyleMobile(w) { adTitleStyleMobile(w) {
if (w !== "fluid") { if (w !== "fluid") {
return `width: ${w}px;`.htmlSafe(); return htmlSafe(`width: ${w}px;`);
} }
}, },