Skip to content

Commit e4f8032

Browse files
committed
Merge pull request #11891 from martndemus/deprecate-collection-view
[BUGFIX release] Deprecate Ember.CollectionView
2 parents 7348ea1 + 79d53af commit e4f8032

File tree

3 files changed

+44
-3
lines changed

3 files changed

+44
-3
lines changed

packages/ember-views/lib/main.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import Renderer from 'ember-metal-views/renderer';
2121
import { DeprecatedCoreView } from 'ember-views/views/core_view';
2222
import { DeprecatedView } from 'ember-views/views/view';
2323
import { DeprecatedContainerView } from 'ember-views/views/container_view';
24-
import CollectionView from 'ember-views/views/collection_view';
24+
import { DeprecatedCollectionView } from 'ember-views/views/collection_view';
2525
import Component from 'ember-views/views/component';
2626

2727
import EventDispatcher from 'ember-views/system/event_dispatcher';
@@ -67,6 +67,7 @@ if (Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT) {
6767
Ember.View.cloneStates = cloneStates;
6868
Ember.View._Renderer = Renderer;
6969
Ember.ContainerView = DeprecatedContainerView;
70+
Ember.CollectionView = DeprecatedCollectionView;
7071
}
7172

7273
Ember._Renderer = Renderer;
@@ -84,7 +85,6 @@ Ember.SelectOptgroup = SelectOptgroup;
8485

8586
Ember.TextSupport = TextSupport;
8687
Ember.ComponentLookup = ComponentLookup;
87-
Ember.CollectionView = CollectionView;
8888
Ember.Component = Component;
8989
Ember.EventDispatcher = EventDispatcher;
9090

packages/ember-views/lib/views/collection_view.js

+25
Original file line numberDiff line numberDiff line change
@@ -450,4 +450,29 @@ function buildItemViewProps(template, attrs) {
450450
return props;
451451
}
452452

453+
function viewDeprecationMessage() {
454+
Ember.deprecate(`Ember.CollectionView is deprecated. Consult the Deprecations Guide for a migration strategy.`,
455+
!!Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT,
456+
{
457+
url: 'http://emberjs.com/deprecations/v1.x/#toc_ember-collectionview',
458+
id: 'ember-views.collection-view-deprecated',
459+
until: '2.4.0'
460+
});
461+
}
462+
463+
var DeprecatedCollectionView = CollectionView.extend({
464+
init() {
465+
viewDeprecationMessage();
466+
this._super(...arguments);
467+
}
468+
});
469+
470+
DeprecatedCollectionView.reopen = function() {
471+
viewDeprecationMessage();
472+
CollectionView.reopen(...arguments);
473+
return this;
474+
};
475+
453476
export default CollectionView;
477+
478+
export { DeprecatedCollectionView };

packages/ember-views/tests/views/collection_test.js

+17-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import run from 'ember-metal/run_loop';
44
import { Mixin } from 'ember-metal/mixin';
55
import { fmt } from 'ember-runtime/system/string';
66
import jQuery from 'ember-views/system/jquery';
7-
import CollectionView from 'ember-views/views/collection_view';
7+
import CollectionView, { DeprecatedCollectionView } from 'ember-views/views/collection_view';
88
import View from 'ember-views/views/view';
99
import Registry from 'container/registry';
1010
import compile from 'ember-template-compiler/system/compile';
@@ -670,3 +670,19 @@ QUnit.test('Collection with style attribute supports changing content', function
670670
view.get('content').pushObject('baz');
671671
});
672672
});
673+
674+
QUnit.module('DeprecatedCollectionView');
675+
676+
QUnit.test('calling reopen on DeprecatedCollectionView delegates to CollectionView', function() {
677+
expect(2);
678+
var originalReopen = CollectionView.reopen;
679+
var obj = {};
680+
681+
CollectionView.reopen = function(arg) { ok(arg === obj); };
682+
683+
expectDeprecation(() => {
684+
DeprecatedCollectionView.reopen(obj);
685+
}, /Ember.CollectionView is deprecated./);
686+
687+
CollectionView.reopen = originalReopen;
688+
});

0 commit comments

Comments
 (0)