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] deprecate createWithMixins #11510

Merged
merged 1 commit into from
Jun 19, 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
10 changes: 6 additions & 4 deletions packages/ember-htmlbars/tests/helpers/bind_attr_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,12 @@ QUnit.test('should be able to bind element attributes using {{bind-attr}}', func
equal(view.$('img').attr('alt'), 'The SproutCore Logo', 'updates alt attribute when content object is a hash');

run(function() {
set(view, 'content', EmberObject.createWithMixins({
url: 'http://www.emberjs.com/assets/images/logo.png',
set(view, 'content', EmberObject.extend({
title: computed(function() {
return 'Nanananana Ember!';
})
}).create({
url: 'http://www.emberjs.com/assets/images/logo.png'
}));
});

Expand Down Expand Up @@ -202,11 +203,12 @@ QUnit.test('should be able to bind use {{bind-attr}} more than once on an elemen
equal(view.$('img').attr('alt'), 'The SproutCore Logo', 'updates alt attribute when content object is a hash');

run(function() {
set(view, 'content', EmberObject.createWithMixins({
url: 'http://www.emberjs.com/assets/images/logo.png',
set(view, 'content', EmberObject.extend({
title: computed(function() {
return 'Nanananana Ember!';
})
}).create({
url: 'http://www.emberjs.com/assets/images/logo.png'
}));
});

Expand Down
5 changes: 3 additions & 2 deletions packages/ember-htmlbars/tests/helpers/view_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1260,11 +1260,12 @@ QUnit.test('should respect keywords', function() {
});

QUnit.test('should bind to the property if no registered helper found for a mustache without parameters', function() {
view = EmberView.createWithMixins({
template: compile('{{view.foobarProperty}}'),
view = EmberView.extend({
foobarProperty: computed(function() {
return 'foobarProperty';
})
}).create({
template: compile('{{view.foobarProperty}}')
});

runAppend(view);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ QUnit.test('should call a registered helper for mustache without parameters', fu
});

QUnit.test('should bind to the property if no registered helper found for a mustache without parameters', function() {
view = EmberView.createWithMixins({
template: compile('{{view.foobarProperty}}'),
view = EmberView.extend({
foobarProperty: computed(function() {
return 'foobarProperty';
})
}).create({
template: compile('{{view.foobarProperty}}')
});

runAppend(view);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ QUnit.test('{{render}} helper should not treat invocations with falsy contexts a

view = EmberView.create({
container: container,
controller: EmberController.createWithMixins({
controller: EmberController.create({
container: container,
zero: false
}),
Expand Down
4 changes: 2 additions & 2 deletions packages/ember-routing/tests/system/route_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ QUnit.test('modelFor doesn\'t require the router', function() {

QUnit.test('.send just calls an action if the router is absent', function() {
expect(7);
var route = EmberRoute.createWithMixins({
var route = EmberRoute.extend({
actions: {
returnsTrue(foo, bar) {
equal(foo, 1);
Expand All @@ -166,7 +166,7 @@ QUnit.test('.send just calls an action if the router is absent', function() {
return false;
}
}
});
}).create();

equal(true, route.send('returnsTrue', 1, 2));
equal(false, route.send('returnsFalse'));
Expand Down
7 changes: 4 additions & 3 deletions packages/ember-runtime/lib/computed/reduce_computed_macros.js
Original file line number Diff line number Diff line change
Expand Up @@ -454,10 +454,11 @@ export var union = uniq;
Example

```javascript
var obj = Ember.Object.createWithMixins({
adaFriends: ['Charles Babbage', 'John Hobhouse', 'William King', 'Mary Somerville'],
charlesFriends: ['William King', 'Mary Somerville', 'Ada Lovelace', 'George Peacock'],
var obj = Ember.Object.extend({
friendsInCommon: Ember.computed.intersect('adaFriends', 'charlesFriends')
}).create({
adaFriends: ['Charles Babbage', 'John Hobhouse', 'William King', 'Mary Somerville'],
charlesFriends: ['William King', 'Mary Somerville', 'Ada Lovelace', 'George Peacock']
});

obj.get('friendsInCommon'); // ['William King', 'Mary Somerville']
Expand Down
9 changes: 5 additions & 4 deletions packages/ember-runtime/lib/system/core_object.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function makeCtor() {
for (var i = 0, l = props.length; i < l; i++) {
var properties = props[i];

Ember.assert('Ember.Object.create no longer supports mixing in other definitions, use createWithMixins instead.', !(properties instanceof Mixin));
Ember.assert('Ember.Object.create no longer supports mixing in other definitions, use .extend & .create seperately instead.', !(properties instanceof Mixin));

if (typeof properties !== 'object' && properties !== undefined) {
throw new EmberError('Ember.Object.create only accepts objects.');
Expand Down Expand Up @@ -582,14 +582,15 @@ var ClassMixinProps = {
@static
@param [arguments]*
@private
@deprecated
*/
createWithMixins(...args) {
createWithMixins: Ember.deprecateFunc('.createWithMixins is deprecated, please use .create or .extend accordingly', function(...args) {
var C = this;
if (args.length > 0) {
this._initMixins(args);
}
return new C();
},
}),

/**
Creates an instance of a class. Accepts either no arguments, or an object
Expand Down Expand Up @@ -622,7 +623,7 @@ var ClassMixinProps = {

NOTE: For performance reasons, you cannot declare methods or computed
properties during `create`. You should instead declare methods and computed
properties when using `extend` or use the `createWithMixins` shorthand.
properties when using `extend`.

@method create
@static
Expand Down
Loading