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 toString to not add the property on the class #13333

Merged
merged 1 commit into from
Apr 14, 2016
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
1 change: 1 addition & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"throws",
"deepEqual",
"ok",
"notOk",
"strictEqual",
"expect",
"minispade",
Expand Down
5 changes: 0 additions & 5 deletions packages/ember-runtime/lib/system/core_object.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,17 +523,12 @@ CoreObject.PrototypeMixin = Mixin.create({
var extension = hasToStringExtension ? ':' + this.toStringExtension() : '';
var ret = '<' + this.constructor.toString() + ':' + guidFor(this) + extension + '>';

this.toString = makeToString(ret);
return ret;
}
});

CoreObject.PrototypeMixin.ownerConstructor = CoreObject;

function makeToString(ret) {
return function() { return ret; };
}

CoreObject.__super__ = null;

var ClassMixinProps = {
Expand Down
11 changes: 11 additions & 0 deletions packages/ember-runtime/tests/system/core_object_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,14 @@ QUnit.test('works with new (> 1 arg)', function() {

equal(obj.other, undefined); // doesn't support multiple pojo' to the constructor
});

QUnit.test('toString should be not be added as a property when calling toString()', function() {
var obj = new CoreObject({
firstName: 'Foo',
lastName: 'Bar'
});

obj.toString();

notOk(obj.hasOwnProperty('toString'), 'Calling toString() should not create a toString class property');
});