Skip to content

Commit c951f71

Browse files
committed
fix typos, set global options
1 parent 1474fd2 commit c951f71

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

knockout.viewmodel.js

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
/*ko.viewmodel.js - version 2.0.3
1+
/*ko.viewmodel.js - version 2.0.3
22
* Copyright 2013, Dave Herren http://coderenaissance.github.com/knockout.viewmodel/
33
* License: MIT (http://www.opensource.org/licenses/mit-license.php)*/
44
/*jshint eqnull:true, boss:true, loopfunc:true, evil:true, laxbreak:true, undef:true, unused:true, browser:true, immed:true, devel:true, sub: true, maxerr:50 */
55
/*global ko:false */
66

77
(function () {
88
//Module declarations. For increased compression with simple settings on the closure compiler,
9-
//the ko functions are stored in variables. These variable names will be shortened by the compiler,
9+
//the ko functions are stored in variables. These variable names will be shortened by the compiler,
1010
//whereas references to ko would not be. There is also a performance savings from this.
1111
var unwrap = ko.utils.unwrapObservable,
1212
isObservable = ko.isObservable,
@@ -70,7 +70,7 @@
7070

7171
//while dates aren't part of the JSON spec it doesn't hurt to support them as it's not unreasonable to think they might be added to the model manually.
7272
//undefined is also not part of the spec, but it's currently be supported to be more in line with ko.mapping and probably doesn't hurt.
73-
function isPrimativeOrDate(obj) {
73+
function isPrimitiveOrDate(obj) {
7474
return obj === null || obj === undefined || obj.constructor === String || obj.constructor === Number || obj.constructor === Boolean || obj instanceof Date;
7575
}
7676

@@ -81,7 +81,7 @@
8181

8282
if (customPathSettings = pathSettings.custom) {
8383
optionProcessed = true;
84-
//custom can either be specified as a single map function or as an
84+
//custom can either be specified as a single map function or as an
8585
//object with map and unmap properties
8686
if (typeof customPathSettings === "function") {
8787
result = customPathSettings(modelObj);
@@ -107,8 +107,8 @@
107107
optionProcessed = true;
108108
return badResult;
109109
}
110-
else if (isPrimativeOrDate(modelObj)) {
111-
//primative and date children of arrays aren't mapped... all others are
110+
else if (isPrimitiveOrDate(modelObj)) {
111+
//primitive and date children of arrays aren't mapped... all others are
112112
result = context.parentIsArray ? modelObj : makeObservable(modelObj);
113113
}
114114
else if (modelObj instanceof Array) {
@@ -161,10 +161,10 @@
161161
full: context.full + "." + p
162162
};
163163
childObj = modelObj[p];
164-
childPathSettings = isPrimativeOrDate(childObj) ? getPathSettings(settings, newContext) : undefined;
164+
childPathSettings = isPrimitiveOrDate(childObj) ? getPathSettings(settings, newContext) : undefined;
165165

166166
if (childPathSettings && childPathSettings.custom) {//primativish value w/ custom maping
167-
//since primative children cannot store their own custom functions, handle processing here and store them in the parent
167+
//since primitive children cannot store their own custom functions, handle processing here and store them in the parent
168168
result.___$customChildren = result.___$customChildren || {};
169169
result.___$customChildren[p] = childPathSettings.custom;
170170

@@ -219,7 +219,7 @@
219219
else if (viewModelObj && viewModelObj.___$unmapCustom) {//Defer to customUnmapping where specified
220220
result = viewModelObj.___$unmapCustom(viewModelObj);
221221
}
222-
else if ((wasWrapped && isPrimativeOrDate(unwrapped)) || isNullOrUndefined(unwrapped)) {
222+
else if ((wasWrapped && isPrimitiveOrDate(unwrapped)) || isNullOrUndefined(unwrapped)) {
223223
//return null, undefined, values, and wrapped primativish values as is
224224
result = unwrapped;
225225
}
@@ -271,7 +271,7 @@
271271
return result;
272272
}
273273

274-
function recursiveUpdate(modelObj, viewModelObj, context, parentObj, noncontiguousObjectUpdateCount) {
274+
function recursiveUpdate(modelObj, viewModelObj, context, parentObj, nonContiguousObjectUpdateCount) {
275275
var p, q, foundModels, foundViewmodels, modelId, viewmodelId, idName, length, unwrapped = unwrap(viewModelObj),
276276
wasWrapped = (viewModelObj !== unwrapped), child, map, tempArray, childTemp, childMap, unwrappedChild, tempChild;
277277

@@ -280,7 +280,7 @@
280280
}
281281

282282
if (wasWrapped && (isNullOrUndefined(unwrapped) ^ isNullOrUndefined(modelObj))) {
283-
//if you have an observable to update and either the new or old value is
283+
//if you have an observable to update and either the new or old value is
284284
//null or undefined then update the observable
285285
viewModelObj(modelObj);
286286
}
@@ -294,7 +294,7 @@
294294
else {
295295
child = unwrapped[p];
296296

297-
if (!wasWrapped && unwrapped.hasOwnProperty(p) && (isPrimativeOrDate(child) || (child && child.constructor === Array))) {
297+
if (!wasWrapped && unwrapped.hasOwnProperty(p) && (isPrimitiveOrDate(child) || (child && child.constructor === Array))) {
298298
unwrapped[p] = modelObj[p];
299299
}
300300
else if (child && typeof child.___$mapCustom === "function") {
@@ -314,18 +314,18 @@
314314
unwrapped[p] = modelObj[p];
315315
}
316316
else {//Recursive update everything else
317-
if (!!noncontiguousObjectUpdateCount) {
317+
if (!!nonContiguousObjectUpdateCount) {
318318
var fnRecursivePropertyObjectUpdate = (function (modelObj, viewModelObj, p) {
319319
return function () {//keep in sync with else below
320320
recursiveUpdate(modelObj[p], unwrapped[p], {
321321
name: p,
322322
parent: (context.name === "[i]" ? context.parent : context.name) + "." + p,
323323
full: context.full + "." + p
324-
}, unwrapped, noncontiguousObjectUpdateCount);
325-
noncontiguousObjectUpdateCount(noncontiguousObjectUpdateCount() - 1);
324+
}, unwrapped, nonContiguousObjectUpdateCount);
325+
nonContiguousObjectUpdateCount(nonContiguousObjectUpdateCount() - 1);
326326
};
327327
}(modelObj, viewModelObj, p));
328-
noncontiguousObjectUpdateCount(noncontiguousObjectUpdateCount() + 1);
328+
nonContiguousObjectUpdateCount(nonContiguousObjectUpdateCount() + 1);
329329
setTimeout(fnRecursivePropertyObjectUpdate, 0);
330330
}
331331
else {//keep in sync with if above
@@ -358,25 +358,25 @@
358358
child(unwrap(tempChild));
359359
}
360360
//else custom mapping returned previous observable;
361-
//if it's smart enough to do that, assume it updated it correctly
361+
//if it's smart enough to do that, assume it updated it correctly
362362
}
363363
else {
364364
unwrapped[q] = child.___$mapCustom(modelObj[p], child);
365365
}
366366
}
367367
else {
368-
369-
if (!!noncontiguousObjectUpdateCount) {//keep in sync with else block below
368+
369+
if (!!nonContiguousObjectUpdateCount) {//keep in sync with else block below
370370
var fnRecursiveArrayChildObjectUpdate = (function (modelObj, viewModelObj, p, q) {
371371
return function () {
372372
recursiveUpdate(modelObj[p], unwrapped[q], {
373373
name: "[i]", parent: context.name + "[i]", full: context.full + "[i]"
374-
}, undefined, noncontiguousObjectUpdateCount);
374+
}, undefined, nonContiguousObjectUpdateCount);
375375

376-
noncontiguousObjectUpdateCount(noncontiguousObjectUpdateCount() - 1);
376+
nonContiguousObjectUpdateCount(nonContiguousObjectUpdateCount() - 1);
377377
};
378378
}(modelObj, viewModelObj, p, q));
379-
noncontiguousObjectUpdateCount(noncontiguousObjectUpdateCount() + 1);
379+
nonContiguousObjectUpdateCount(nonContiguousObjectUpdateCount() + 1);
380380
setTimeout(fnRecursiveArrayChildObjectUpdate, 0);
381381
}
382382
else {//keep in sync with if block above
@@ -423,13 +423,13 @@
423423
viewModelObj(modelObj);
424424
}
425425

426-
if (context.name === "{root}" && !!noncontiguousObjectUpdateCount) {
426+
if (context.name === "{root}" && !!nonContiguousObjectUpdateCount) {
427427
return {
428428
onComplete:function (fnOnComplete) {
429429
if(fnOnComplete && typeof fnOnComplete == "function"){
430-
if (!!noncontiguousObjectUpdateCount) {
430+
if (!!nonContiguousObjectUpdateCount) {
431431
ko.computed(function () {
432-
if (fnOnComplete && noncontiguousObjectUpdateCount() === 0) {
432+
if (fnOnComplete && nonContiguousObjectUpdateCount() === 0) {
433433
fnOnComplete();
434434
fnOnComplete = undefined;
435435
}
@@ -487,10 +487,10 @@
487487
initInternals(this.options, "Mapping To Model");
488488
return recursiveTo(viewmodel, rootContext);
489489
},
490-
updateFromModel: function fnUpdateFromModel(viewmodel, model, makeNoncontiguousObjectUpdates) {
491-
var noncontiguousObjectUpdateCount = makeNoncontiguousObjectUpdates ? ko.observable(0) : undefined;
490+
updateFromModel: function fnUpdateFromModel(viewmodel, model, makeNonContiguousObjectUpdates) {
491+
var nonContiguousObjectUpdateCount = makeNonContiguousObjectUpdates ? ko.observable(0) : undefined;
492492
initInternals(this.options, "Update From Model");
493-
return recursiveUpdate(model, viewmodel, rootContext, undefined, noncontiguousObjectUpdateCount);
493+
return recursiveUpdate(model, viewmodel, rootContext, undefined, nonContiguousObjectUpdateCount);
494494
}
495495
};
496496
}());

0 commit comments

Comments
 (0)