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

Fix SC.Record.normalize: accept record attributes based on classes extending SC.RecordAttribute #1127

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 2 additions & 4 deletions frameworks/datastore/models/record.js
Expand Up @@ -626,16 +626,14 @@ SC.Record = SC.Object.extend(
*/

normalize: function(includeNull) {
var primaryKey = this.primaryKey,
recordId = this.get('id'),
var recordId = this.get('id'),
store = this.get('store'),
storeKey = this.get('storeKey'),
keysToKeep = {},
key, valueForKey, typeClass, recHash, attrValue, normChild, isRecord,
isChild, defaultVal, keyForDataHash, attr;

var dataHash = store.readEditableDataHash(storeKey) || {};
dataHash[primaryKey] = recordId;
recHash = store.readDataHash(storeKey);

for (key in this) {
Expand All @@ -658,7 +656,7 @@ SC.Record = SC.Object.extend(
if(attrValue!==undefined && (attrValue!==null || includeNull)) {
attr = this[key];
// if record attribute, make sure we transform with the fromType
if(SC.instanceOf(attr, SC.RecordAttribute)) {
if(SC.kindOf(attr, SC.RecordAttribute)) {
attrValue = attr.fromType(this, key, attrValue);
}
dataHash[keyForDataHash] = attrValue;
Expand Down