A platform for community discussion. Free, open, simple.
DEV: Don't use `attrs` (#24323)
Jarek Radoszb1e43425bfef
diff --git a/app/assets/javascripts/admin/addon/components/ace-editor.js b/app/assets/javascripts/admin/addon/components/ace-editor.jsindex 838bf21506d..0b862546b41 100644--- a/app/assets/javascripts/admin/addon/components/ace-editor.js+++ b/app/assets/javascripts/admin/addon/components/ace-editor.js@@ -116,11 +116,11 @@ export default class AceEditor extends Component {this._skipContentChangeEvent = true;this.set("content", editor.getSession().getValue());});- if (this.attrs.save) {+ if (this.save) {editor.commands.addCommand({name: "save",exec: () => {- this.attrs.save();+ this.save();},bindKey: { mac: "cmd-s", win: "ctrl-s" },});diff --git a/app/assets/javascripts/admin/addon/components/admin-report.js b/app/assets/javascripts/admin/addon/components/admin-report.jsindex c6bcbc748a1..602f0cb6035 100644--- a/app/assets/javascripts/admin/addon/components/admin-report.js+++ b/app/assets/javascripts/admin/addon/components/admin-report.js@@ -220,11 +220,11 @@ export default class AdminReport extends Component {@actionrefreshReport(options = {}) {- if (!this.attrs.onRefresh) {+ if (!this.onRefresh) {return;}- this.attrs.onRefresh({+ this.onRefresh({type: this.get("model.type"),mode: this.currentMode,chartGrouping: options.chartGrouping,diff --git a/app/assets/javascripts/admin/addon/components/color-input.js b/app/assets/javascripts/admin/addon/components/color-input.jsindex b44123d0f0b..8067c6b156f 100644--- a/app/assets/javascripts/admin/addon/components/color-input.js+++ b/app/assets/javascripts/admin/addon/components/color-input.js@@ -45,8 +45,8 @@ export default class ColorInput extends Component {@actiononHexInput(event) {- if (this.attrs.onChangeColor) {- this.attrs.onChangeColor(this.normalize(event.target.value || ""));+ if (this.onChangeColor) {+ this.onChangeColor(this.normalize(event.target.value || ""));}}@@ -59,8 +59,8 @@ export default class ColorInput extends Component {hexValueChanged() {const hex = this.hexValue;- if (this.attrs.onChangeColor) {- this.attrs.onChangeColor(this.normalize(hex));+ if (this.onChangeColor) {+ this.onChangeColor(this.normalize(hex));}if (this._valid()) {diff --git a/app/assets/javascripts/discourse/app/components/directory-table.js b/app/assets/javascripts/discourse/app/components/directory-table.jsindex cf031759516..ee2b416f0c1 100644--- a/app/assets/javascripts/discourse/app/components/directory-table.js+++ b/app/assets/javascripts/discourse/app/components/directory-table.js@@ -9,8 +9,8 @@ export default Component.extend({this.setProperties({_table: this.element.querySelector(".directory-table"),_columnCount: this.showTimeRead- ? this.attrs.columns.value.length + 1- : this.attrs.columns.value.length,+ ? this.columns.length + 1+ : this.columns.length,});this._table.style.gridTemplateColumns = `minmax(13em, 3fr) repeat(${this._columnCount}, minmax(max-content, 1fr))`;diff --git a/app/assets/javascripts/discourse/app/components/reviewable-item.js b/app/assets/javascripts/discourse/app/components/reviewable-item.jsindex 7ba9249be7c..13ffe494399 100644--- a/app/assets/javascripts/discourse/app/components/reviewable-item.js+++ b/app/assets/javascripts/discourse/app/components/reviewable-item.js@@ -190,8 +190,8 @@ export default Component.extend({);}- if (this.attrs.remove) {- this.attrs.remove(performResult.remove_reviewable_ids);+ if (this.remove) {+ this.remove(performResult.remove_reviewable_ids);} else {return this.store.find("reviewable", reviewable.id);}diff --git a/app/assets/javascripts/discourse/app/components/time-input.js b/app/assets/javascripts/discourse/app/components/time-input.jsindex 1bd7de0d995..76c9870d591 100644--- a/app/assets/javascripts/discourse/app/components/time-input.js+++ b/app/assets/javascripts/discourse/app/components/time-input.js@@ -53,8 +53,8 @@ export default Component.extend({if (!isPresent(this.date) &&- !isPresent(this.attrs.hours) &&- !isPresent(this.attrs.minutes)+ !isPresent(this.hours) &&+ !isPresent(this.minutes)) {this.setProperties({hours: null,diff --git a/app/assets/javascripts/discourse/app/components/topic-navigation.js b/app/assets/javascripts/discourse/app/components/topic-navigation.jsindex 567fadcb37e..fd85156c242 100644--- a/app/assets/javascripts/discourse/app/components/topic-navigation.js+++ b/app/assets/javascripts/discourse/app/components/topic-navigation.js@@ -127,8 +127,8 @@ export default Component.extend({this.modal.show(JumpToPost, {model: {topic: this.topic,- jumpToIndex: this.attrs.jumpToIndex,- jumpToDate: this.attrs.jumpToDate,+ jumpToIndex: this.jumpToIndex,+ jumpToDate: this.jumpToDate,},});}diff --git a/app/assets/javascripts/discourse/app/components/topic-progress.js b/app/assets/javascripts/discourse/app/components/topic-progress.jsindex f6f311b923c..4630675b2ca 100644--- a/app/assets/javascripts/discourse/app/components/topic-progress.js+++ b/app/assets/javascripts/discourse/app/components/topic-progress.js@@ -177,6 +177,6 @@ export default Component.extend({@actiongoBack() {- this.attrs.jumpToPost(this.get("topic.last_read_post_number"));+ this.jumpToPost(this.get("topic.last_read_post_number"));},});diff --git a/app/assets/javascripts/select-kit/addon/components/categories-admin-dropdown.js b/app/assets/javascripts/select-kit/addon/components/categories-admin-dropdown.jsindex 834e016bf88..a0509083251 100644--- a/app/assets/javascripts/select-kit/addon/components/categories-admin-dropdown.js+++ b/app/assets/javascripts/select-kit/addon/components/categories-admin-dropdown.js@@ -41,8 +41,8 @@ export default DropdownSelectBoxComponent.extend({_onChange(value, item) {if (item.onChange) {item.onChange(value, item);- } else if (this.attrs.onChange) {- this.attrs.onChange(value, item);+ } else if (this.onChange) {+ this.onChange(value, item);}},});diff --git a/app/assets/javascripts/select-kit/addon/components/category-selector.js b/app/assets/javascripts/select-kit/addon/components/category-selector.jsindex ede830289f4..9f3f5221c4d 100644--- a/app/assets/javascripts/select-kit/addon/components/category-selector.js+++ b/app/assets/javascripts/select-kit/addon/components/category-selector.js@@ -33,8 +33,8 @@ export default MultiSelectComponent.extend({const blockedCategories = makeArray(this.blockedCategories);return Category.list().filter((category) => {if (category.isUncategorizedCategory) {- if (this.attrs.options?.allowUncategorized !== undefined) {- return this.attrs.options.allowUncategorized;+ if (this.options?.allowUncategorized !== undefined) {+ return this.options.allowUncategorized;}return this.selectKit.options.allowUncategorized;@@ -70,8 +70,8 @@ export default MultiSelectComponent.extend({return await Category.asyncSearch(filter, {includeUncategorized:- this.attrs.options?.allowUncategorized !== undefined- ? this.attrs.options.allowUncategorized+ this.options?.allowUncategorized !== undefined+ ? this.options.allowUncategorized: this.selectKit.options.allowUncategorized,rejectCategoryIds: Array.from(rejectCategoryIds),});diff --git a/app/assets/javascripts/select-kit/addon/components/future-date-input-selector.js b/app/assets/javascripts/select-kit/addon/components/future-date-input-selector.jsindex 26dc96aeb6e..664e4b67c29 100644--- a/app/assets/javascripts/select-kit/addon/components/future-date-input-selector.js+++ b/app/assets/javascripts/select-kit/addon/components/future-date-input-selector.js@@ -30,12 +30,11 @@ export default ComboBoxComponent.extend({if (value !== "custom" && !isEmpty(value)) {const { time } = this.content.find((x) => x.id === value);if (time) {- this.attrs.onChangeInput &&- this.attrs.onChangeInput(time.locale("en").format(FORMAT));+ this.onChangeInput?.(time.locale("en").format(FORMAT));}}- this.attrs.onChange && this.attrs.onChange(value);+ this.onChange?.(value);},},});diff --git a/app/assets/javascripts/select-kit/addon/components/icon-picker.js b/app/assets/javascripts/select-kit/addon/components/icon-picker.jsindex c2d8236e258..06794b3e9b1 100644--- a/app/assets/javascripts/select-kit/addon/components/icon-picker.js+++ b/app/assets/javascripts/select-kit/addon/components/icon-picker.js@@ -97,7 +97,7 @@ export default MultiSelectComponent.extend({item = item.length ? item[0] : null;}- this.attrs.onChange && this.attrs.onChange(value, item);+ this.onChange?.(value, item);},},});diff --git a/app/assets/javascripts/select-kit/addon/components/period-chooser.js b/app/assets/javascripts/select-kit/addon/components/period-chooser.jsindex bf50699065b..13804ec0ab4 100644--- a/app/assets/javascripts/select-kit/addon/components/period-chooser.js+++ b/app/assets/javascripts/select-kit/addon/components/period-chooser.js@@ -29,7 +29,7 @@ export default DropdownSelectBoxComponent.extend({if (this.action) {this.action(value);} else {- this.attrs.onChange && this.attrs.onChange(value);+ this.onChange?.(value);}},},diff --git a/app/assets/javascripts/select-kit/addon/components/select-kit.js b/app/assets/javascripts/select-kit/addon/components/select-kit.jsindex 9025d0403f9..c973b17fc48 100644--- a/app/assets/javascripts/select-kit/addon/components/select-kit.js+++ b/app/assets/javascripts/select-kit/addon/components/select-kit.js@@ -75,7 +75,7 @@ export default Component.extend(this.set("selectKit",EmberObject.create({- uniqueID: this.attrs?.id?.value || this.attrs?.id || guidFor(this),+ uniqueID: this.id || guidFor(this),valueProperty: this.valueProperty,nameProperty: this.nameProperty,labelProperty: this.labelProperty,@@ -1128,15 +1128,14 @@ export default Component.extend(_deprecateMutations() {this.actions ??= {};- this.attrs ??= {};- if (!this.attrs.onChange && !this.actions.onChange) {+ if (!this.onChange && !this.actions.onChange) {this._deprecated("Implicit mutation has been deprecated, please use `onChange` handler");this.actions.onChange =- this.attrs.onSelect ||+ this.onSelect ||this.actions.onSelect ||((value) => this.set("value", value));}