DEV: Unsilence and resolve setting-on-hash deprecation (#20611)
Select-kit was mutating a passed-in options hash to apply its own deprecations. This commit updates it to apply deprecated changes to the downstream `this.selectKit.options` object instead.
This commit is contained in:
parent
3c4bfb6a9f
commit
059ac3d31a
|
@ -10,7 +10,6 @@ globalThis.deprecationWorkflow.config = {
|
||||||
{ handler: "silence", matchId: "route-render-template" },
|
{ handler: "silence", matchId: "route-render-template" },
|
||||||
{ handler: "silence", matchId: "routing.transition-methods" },
|
{ handler: "silence", matchId: "routing.transition-methods" },
|
||||||
{ handler: "silence", matchId: "route-disconnect-outlet" },
|
{ handler: "silence", matchId: "route-disconnect-outlet" },
|
||||||
{ handler: "silence", matchId: "setting-on-hash" },
|
|
||||||
{ handler: "silence", matchId: "this-property-fallback" },
|
{ handler: "silence", matchId: "this-property-fallback" },
|
||||||
{ handler: "silence", matchId: "ember.globals-resolver" },
|
{ handler: "silence", matchId: "ember.globals-resolver" },
|
||||||
{ handler: "silence", matchId: "globals-resolver" },
|
{ handler: "silence", matchId: "globals-resolver" },
|
||||||
|
|
|
@ -215,6 +215,7 @@ export default Component.extend(
|
||||||
didReceiveAttrs() {
|
didReceiveAttrs() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
|
const deprecatedOptions = this._resolveDeprecatedOptions();
|
||||||
const mergedOptions = Object.assign({}, ...this.selectKitOptions);
|
const mergedOptions = Object.assign({}, ...this.selectKitOptions);
|
||||||
Object.keys(mergedOptions).forEach((key) => {
|
Object.keys(mergedOptions).forEach((key) => {
|
||||||
if (isPresent(this.options[key])) {
|
if (isPresent(this.options[key])) {
|
||||||
|
@ -222,6 +223,11 @@ export default Component.extend(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isPresent(deprecatedOptions[`options.${key}`])) {
|
||||||
|
this.selectKit.options.set(key, deprecatedOptions[`options.${key}`]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const value = mergedOptions[key];
|
const value = mergedOptions[key];
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
@ -1055,7 +1061,7 @@ export default Component.extend(
|
||||||
handleDeprecations() {
|
handleDeprecations() {
|
||||||
this._deprecateValueAttribute();
|
this._deprecateValueAttribute();
|
||||||
this._deprecateMutations();
|
this._deprecateMutations();
|
||||||
this._deprecateOptions();
|
this._handleDeprecatdArgs();
|
||||||
},
|
},
|
||||||
|
|
||||||
_computePlacementStrategy() {
|
_computePlacementStrategy() {
|
||||||
|
@ -1116,11 +1122,8 @@ export default Component.extend(
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_deprecateOptions() {
|
_resolveDeprecatedOptions() {
|
||||||
const migrations = {
|
const migrations = {
|
||||||
headerIcon: "icon",
|
|
||||||
onExpand: "onOpen",
|
|
||||||
onCollapse: "onClose",
|
|
||||||
allowAny: "options.allowAny",
|
allowAny: "options.allowAny",
|
||||||
allowCreate: "options.allowAny",
|
allowCreate: "options.allowAny",
|
||||||
filterable: "options.filterable",
|
filterable: "options.filterable",
|
||||||
|
@ -1141,6 +1144,29 @@ export default Component.extend(
|
||||||
castInteger: "options.castInteger",
|
castInteger: "options.castInteger",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const resolvedDeprecations = {};
|
||||||
|
|
||||||
|
Object.keys(migrations).forEach((from) => {
|
||||||
|
const to = migrations[from];
|
||||||
|
if (this.get(from) && !this.get(to)) {
|
||||||
|
this._deprecated(
|
||||||
|
`The \`${from}\` attribute is deprecated. Use \`${to}\` instead`
|
||||||
|
);
|
||||||
|
|
||||||
|
resolvedDeprecations[(to, this.get(from))];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return resolvedDeprecations;
|
||||||
|
},
|
||||||
|
|
||||||
|
_handleDeprecatdArgs() {
|
||||||
|
const migrations = {
|
||||||
|
headerIcon: "icon",
|
||||||
|
onExpand: "onOpen",
|
||||||
|
onCollapse: "onClose",
|
||||||
|
};
|
||||||
|
|
||||||
Object.keys(migrations).forEach((from) => {
|
Object.keys(migrations).forEach((from) => {
|
||||||
const to = migrations[from];
|
const to = migrations[from];
|
||||||
if (this.get(from) && !this.get(to)) {
|
if (this.get(from) && !this.get(to)) {
|
||||||
|
|
Loading…
Reference in New Issue