Skip to content

Commit

Permalink
Merge pull request #11510 from stefanpenner/deprecate-create-with-mixins
Browse files Browse the repository at this point in the history
[Bugfix Release] deprecate createWithMixins
  • Loading branch information
rwjblue committed Jun 19, 2015
2 parents 4b74503 + c54d887 commit bc7ec8d
Show file tree
Hide file tree
Showing 40 changed files with 522 additions and 644 deletions.
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

0 comments on commit bc7ec8d

Please sign in to comment.