Skip to content

Commit f97d5cd

Browse files
timtuckercrissdev
authored andcommitted
Use intermediate vars to decrease minified size
Closure compiler applied to exports.visitModel shows a decrease from 1005 bytes down to 930 bytes.
1 parent 57a0b56 commit f97d5cd

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

dist/knockout.mapping.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -780,10 +780,15 @@
780780
if (ko.utils.arrayIndexOf(options.include, indexer) === -1) {
781781
// The mapped properties object contains all the properties that were part of the original object.
782782
// If a property does not exist, and it is not because it is part of an array (e.g. "myProp[3]"), then it should not be unmapped.
783-
if (unwrappedRootObject[mappingProperty] &&
784-
unwrappedRootObject[mappingProperty].mappedProperties && !unwrappedRootObject[mappingProperty].mappedProperties[indexer] &&
785-
unwrappedRootObject[mappingProperty].copiedProperties && !unwrappedRootObject[mappingProperty].copiedProperties[indexer] && (exports.getType(unwrappedRootObject) !== "array")) {
786-
return;
783+
var unwrappedRootMappingProperty = unwrappedRootObject[mappingProperty];
784+
if (unwrappedRootMappingProperty) {
785+
var mappedProperties = unwrappedRootMappingProperty.mappedProperties;
786+
if (mappedProperties && !mappedProperties[indexer]) {
787+
var copiedProperties = unwrappedRootMappingProperty.copiedProperties;
788+
if (copiedProperties && !copiedProperties[indexer] && (exports.getType(unwrappedRootObject) !== "array")) {
789+
return;
790+
}
791+
}
787792
}
788793
}
789794
}

0 commit comments

Comments
 (0)