Fix JS style issues

This commit is contained in:
Raymond Feng 2015-02-20 14:57:48 -08:00
parent 4c99fbabba
commit e659e2f603
1 changed files with 11 additions and 8 deletions

View File

@ -189,10 +189,11 @@ RelationDefinition.prototype.applyScope = function(modelInstance, filter) {
filter.where[discriminator] = this.modelFrom.modelName;
}
}
var scope;
if (typeof this.scope === 'function') {
var scope = this.scope.call(this, modelInstance, filter);
scope = this.scope.call(this, modelInstance, filter);
} else {
var scope = this.scope;
scope = this.scope;
}
if (typeof scope === 'object') {
mergeQuery(filter, scope);
@ -207,25 +208,27 @@ RelationDefinition.prototype.applyScope = function(modelInstance, filter) {
RelationDefinition.prototype.applyProperties = function(modelInstance, obj) {
var source = modelInstance, target = obj;
if (this.options.invertProperties) {
source = obj, target = modelInstance;
source = obj;
target = modelInstance;
}
if (this.options.embedsProperties) {
target = target.__data[this.name] = {};
target[this.keyTo] = source[this.keyTo];
}
var k, key;
if (typeof this.properties === 'function') {
var data = this.properties.call(this, source, target);
for(var k in data) {
for(k in data) {
target[k] = data[k];
}
} else if (Array.isArray(this.properties)) {
for(var k = 0; k < this.properties.length; k++) {
var key = this.properties[k];
for(k = 0; k < this.properties.length; k++) {
key = this.properties[k];
target[key] = source[key];
}
} else if (typeof this.properties === 'object') {
for(var k in this.properties) {
var key = this.properties[k];
for(k in this.properties) {
key = this.properties[k];
target[key] = source[k];
}
}