Skip to content

Commit

Permalink
Add deprecation method to disconnectOutlet
Browse files Browse the repository at this point in the history
  • Loading branch information
patocallaghan committed Feb 12, 2021
1 parent 0fa78e0 commit f9da995
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 29 deletions.
Expand Up @@ -4,6 +4,8 @@ import {
moduleFor,
strip,
} from 'internal-test-helpers';
import { ExpectDeprecationFunc } from '../../../../../../internal-test-helpers/lib/ember-dev/deprecation';
declare let expectDeprecation: ExpectDeprecationFunc;

import { ENV } from '@ember/-internals/environment';
import { Component, setComponentManager } from '@ember/-internals/glimmer';
Expand Down Expand Up @@ -225,7 +227,10 @@ if (ENV._DEBUG_RENDER_TREE) {
if (showHeader) {
this.render('header', { outlet: 'header' });
} else {
this.disconnectOutlet('header');
expectDeprecation(
() => this.disconnectOutlet('header'),
'The usage of `disconnectOutlet` is deprecated.'
);
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions packages/@ember/-internals/routing/lib/system/route.ts
Expand Up @@ -1705,6 +1705,15 @@ class Route extends EmberObject implements IRoute {
@public
*/
disconnectOutlet(options: string | { outlet: string; parentView?: string }) {
deprecate('The usage of `disconnectOutlet` is deprecated.', false, {
id: 'route-disconnect-outlet',
until: '4.0.0',
url: 'https://deprecations.emberjs.com/v3.x/#toc_route-disconnect-outlet',
for: 'ember-source',
since: {
enabled: '3.27.0',
},
});
let outletName;
let parentView;
if (options) {
Expand Down
89 changes: 61 additions & 28 deletions packages/ember/tests/routing/template_rendering_test.js
Expand Up @@ -775,10 +775,14 @@ moduleFor(
});
},
hideModal() {
this.disconnectOutlet({
outlet: 'modal',
parentView: 'application',
});
expectDeprecation(
() =>
this.disconnectOutlet({
outlet: 'modal',
parentView: 'application',
}),
'The usage of `disconnectOutlet` is deprecated.'
);
},
},
})
Expand All @@ -794,7 +798,10 @@ moduleFor(
});
},
hideExtra() {
this.disconnectOutlet({ parentView: 'posts/index' });
expectDeprecation(
() => this.disconnectOutlet({ parentView: 'posts/index' }),
'The usage of `disconnectOutlet` is deprecated.'
);
},
},
})
Expand Down Expand Up @@ -898,7 +905,10 @@ moduleFor(
});
},
hideModal() {
this.disconnectOutlet('modal');
expectDeprecation(
() => this.disconnectOutlet('modal'),
'The usage of `disconnectOutlet` is deprecated.'
);
},
},
})
Expand Down Expand Up @@ -942,7 +952,7 @@ moduleFor(
}

['@test Route silently fails when cleaning an outlet from an inactive view'](assert) {
assert.expect(1); // handleURL
assert.expect(3); // handleURL

this.addTemplate('application', '{{outlet}}');
this.addTemplate('posts', "{{outlet 'modal'}}");
Expand All @@ -957,16 +967,23 @@ moduleFor(
Route.extend({
actions: {
hideSelf() {
this.disconnectOutlet({
outlet: 'main',
parentView: 'application',
});
expectDeprecation(
() =>
this.disconnectOutlet({
outlet: 'main',
parentView: 'application',
}),
'The usage of `disconnectOutlet` is deprecated.'
);
},
showModal() {
this.render('modal', { into: 'posts', outlet: 'modal' });
},
hideModal() {
this.disconnectOutlet({ outlet: 'modal', parentView: 'posts' });
expectDeprecation(
() => this.disconnectOutlet({ outlet: 'modal', parentView: 'posts' }),
'The usage of `disconnectOutlet` is deprecated.'
);
},
},
})
Expand Down Expand Up @@ -1080,10 +1097,14 @@ moduleFor(
},
actions: {
banish() {
this.disconnectOutlet({
parentView: 'application',
outlet: 'other',
});
expectDeprecation(
() =>
this.disconnectOutlet({
parentView: 'application',
outlet: 'other',
}),
'The usage of `disconnectOutlet` is deprecated.'
);
},
},
})
Expand Down Expand Up @@ -1249,10 +1270,14 @@ moduleFor(
});
},
close() {
this.disconnectOutlet({
outlet: 'modal',
parentView: 'application',
});
expectDeprecation(
() =>
this.disconnectOutlet({
outlet: 'modal',
parentView: 'application',
}),
'The usage of `disconnectOutlet` is deprecated.'
);
},
},
})
Expand Down Expand Up @@ -1329,10 +1354,14 @@ moduleFor(
Route.extend({
actions: {
close() {
this.disconnectOutlet({
parentView: 'application',
outlet: 'modal',
});
expectDeprecation(
() =>
this.disconnectOutlet({
parentView: 'application',
outlet: 'modal',
}),
'The usage of `disconnectOutlet` is deprecated.'
);
},
},
})
Expand Down Expand Up @@ -1438,10 +1467,14 @@ moduleFor(
});
},
hideModal() {
this.disconnectOutlet({
outlet: undefined,
parentView: 'application',
});
expectDeprecation(
() =>
this.disconnectOutlet({
outlet: undefined,
parentView: 'application',
}),
'The usage of `disconnectOutlet` is deprecated.'
);
},
},
})
Expand Down

0 comments on commit f9da995

Please sign in to comment.