backbone-relations
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -21,3 +21,3 @@ (function () { | ||
get: function (attr) { | ||
var rel = this.relations[attr]; | ||
var rel = this.relations && this.relations[attr]; | ||
if (!rel) return get.call(this, attr); | ||
@@ -58,15 +58,17 @@ var instance = rel.instance; | ||
} | ||
for (key in attrs) { | ||
var rel = this.relations[key]; | ||
if (!rel) continue; | ||
val = attrs[key]; | ||
delete attrs[key]; | ||
if (rel.hasOne) { | ||
var instance = this.get(key); | ||
var model = val instanceof rel.hasOne ? val.attributes : val; | ||
instance.set(model, options); | ||
if (this.get(rel.fk) !== instance.id) attrs[rel.fk] = instance.id; | ||
} else { | ||
var models = val instanceof rel.hasMany ? val.models : val; | ||
this.get(key).update(models, options); | ||
if (this.relations) { | ||
for (key in attrs) { | ||
var rel = this.relations[key]; | ||
if (!rel) continue; | ||
val = attrs[key]; | ||
delete attrs[key]; | ||
if (rel.hasOne) { | ||
var instance = this.get(key); | ||
var model = val instanceof rel.hasOne ? val.attributes : val; | ||
instance.set(model, options); | ||
if (this.get(rel.fk) !== instance.id) attrs[rel.fk] = instance.id; | ||
} else { | ||
var models = val instanceof rel.hasMany ? val.models : val; | ||
this.get(key).update(models, options); | ||
} | ||
} | ||
@@ -73,0 +75,0 @@ } |
{ | ||
"name": "backbone-relations", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"author": "Casey Foster <c@sey.me>", | ||
@@ -5,0 +5,0 @@ "licence": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4632
72