Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX release] Fix DeprecatedView (and friends) reopen function to delegate to original #11866

Merged
merged 1 commit into from Jul 24, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions packages/ember-views/lib/views/container_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,17 +306,27 @@ var ContainerView = View.extend(MutableArray, {
})
});

function containerViewDeprecationMessage() {
Ember.deprecate('Ember.ContainerView is deprecated.',
!!Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT,
{
url: 'http://emberjs.com/deprecations/v1.x/#toc_ember-containerview',
id: 'ember-views.container-view',
until: '2.4.0'
});
}

export var DeprecatedContainerView = ContainerView.extend({
init() {
Ember.deprecate('Ember.ContainerView is deprecated.',
!!Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT,
{
url: 'http://emberjs.com/deprecations/v1.x/#toc_ember-containerview',
id: 'ember-views.container-view',
until: '2.4.0'
});
containerViewDeprecationMessage();
this._super.apply(this, arguments);
}
});

DeprecatedContainerView.reopen = function() {
containerViewDeprecationMessage();
ContainerView.reopen(...arguments);
return this;
};

export default ContainerView;
23 changes: 16 additions & 7 deletions packages/ember-views/lib/views/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -669,19 +669,28 @@ var Select = View.extend({
}
});

function selectViewDeprecationMessage() {
Ember.deprecate(`Ember.Select is deprecated. Consult the Deprecations Guide for a migration strategy.`,
!!Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT,
{
url: 'http://emberjs.com/deprecations/v1.x/#toc_ember-select',
id: 'ember-views.select-deprecated',
until: '2.4.0'
});
}

var DeprecatedSelect = Select.extend({
init() {
selectViewDeprecationMessage();
this._super(...arguments);
Ember.deprecate(`Ember.Select is deprecated. Consult the Deprecations Guide for a migration strategy.`,
!!Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT,
{
url: 'http://emberjs.com/deprecations/v1.x/#toc_ember-select',
id: 'ember-views.select-deprecated',
until: '2.4.0'
});
}
});

DeprecatedSelect.reopen = function() {
selectViewDeprecationMessage();
Select.reopen(...arguments);
return this;
};

function indexesOf(iterable, elements) {
return elements === undefined ? [] : elements.map((item) => iterable.indexOf(item));
Expand Down
24 changes: 17 additions & 7 deletions packages/ember-views/lib/views/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -1530,19 +1530,29 @@ View.views = {};
// method.
View.childViewsProperty = childViewsProperty;

function viewDeprecationMessage() {
Ember.deprecate(`Ember.View is deprecated. Consult the Deprecations Guide for a migration strategy.`,
!!Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT,
{
url: 'http://emberjs.com/deprecations/v1.x/#toc_ember-view',
id: 'ember-views.view-deprecated',
until: '2.4.0'
});
}

var DeprecatedView = View.extend({
init() {
viewDeprecationMessage();
this._super(...arguments);
Ember.deprecate(`Ember.View is deprecated. Consult the Deprecations Guide for a migration strategy.`,
!!Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT,
{
url: 'http://emberjs.com/deprecations/v1.x/#toc_ember-view',
id: 'ember-views.view-deprecated',
until: '2.4.0'
});
}
});

DeprecatedView.reopen = function() {
viewDeprecationMessage();
View.reopen(...arguments);
return this;
};

export default View;

export { ViewContextSupport, ViewChildViewsSupport, ViewStateSupport, TemplateRenderingSupport, ClassNamesSupport, DeprecatedView };
18 changes: 17 additions & 1 deletion packages/ember-views/tests/views/container_view_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { computed } from 'ember-metal/computed';
import Controller from 'ember-runtime/controllers/controller';
import jQuery from 'ember-views/system/jquery';
import View from 'ember-views/views/view';
import ContainerView from 'ember-views/views/container_view';
import ContainerView, { DeprecatedContainerView } from 'ember-views/views/container_view';
import Registry from 'container/registry';
import compile from 'ember-template-compiler/system/compile';
import getElementStyle from 'ember-views/tests/test-helpers/get-element-style';
Expand Down Expand Up @@ -796,3 +796,19 @@ QUnit.test('renders contained view with omitted start tag and parent view contex
equal(view.element.tagName, 'TABLE', 'container view is table');
equal(view.element.childNodes[2].tagName, 'TR', 'inner view is tr');
});

QUnit.module('DeprecatedContainerView');

QUnit.test('calling reopen on DeprecatedContainerView delegates to ContainerView', function() {
expect(2);
var originalReopen = ContainerView.reopen;
var obj = {};

ContainerView.reopen = function(arg) { ok(arg === obj); };

expectDeprecation(() => {
DeprecatedContainerView.reopen(obj);
}, /Ember.ContainerView is deprecated./);

ContainerView.reopen = originalReopen;
});
18 changes: 17 additions & 1 deletion packages/ember-views/tests/views/select_test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Ember from 'ember-metal/core';
import run from 'ember-metal/run_loop';
import EmberObject from 'ember-runtime/system/object';
import EmberSelect from 'ember-views/views/select';
import EmberSelect, { DeprecatedSelect } from 'ember-views/views/select';
import jQuery from 'ember-views/system/jquery';
import EventDispatcher from 'ember-views/system/event_dispatcher';
import SafeString from 'htmlbars-util/safe-string';
Expand Down Expand Up @@ -804,3 +804,19 @@ QUnit.test('should be able to set the current selection by value', function() {
equal(select.get('value'), 'ebryn');
equal(select.get('selection'), ebryn);
});

QUnit.module('DeprecatedSelect');

QUnit.test('calling reopen on DeprecatedSelect delegates to Select', function() {
expect(2);
var originalReopen = EmberSelect.reopen;
var obj = {};

EmberSelect.reopen = function(arg) { ok(arg === obj); };

expectDeprecation(() => {
DeprecatedSelect.reopen(obj);
}, /Ember.Select is deprecated./);

EmberSelect.reopen = originalReopen;
});
18 changes: 17 additions & 1 deletion packages/ember-views/tests/views/view_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Ember from 'ember-metal/core';
import { computed } from 'ember-metal/computed';
import run from 'ember-metal/run_loop';
import jQuery from 'ember-views/system/jquery';
import EmberView from 'ember-views/views/view';
import EmberView, { DeprecatedView } from 'ember-views/views/view';
import { compile } from 'ember-template-compiler';

import { registerKeyword, resetKeyword } from 'ember-htmlbars/tests/utils';
Expand Down Expand Up @@ -159,3 +159,19 @@ QUnit.test('propagates dependent-key invalidated bindings upstream', function()
equal(childView.get('childProp'), 'new-value', 'pre-cond - new value is propagated to CP');
equal(view.get('parentProp'), 'new-value', 'new value is propagated across template');
});

QUnit.module('DeprecatedView');

QUnit.test('calling reopen on DeprecatedView delegates to View', function() {
expect(2);
var originalReopen = EmberView.reopen;
var obj = {};

EmberView.reopen = function(arg) { ok(arg === obj); };

expectDeprecation(() => {
DeprecatedView.reopen(obj);
}, /Ember.View is deprecated./);

EmberView.reopen = originalReopen;
});