Skip to content

Commit

Permalink
fix internal deserialize issue on wechat game
Browse files Browse the repository at this point in the history
  • Loading branch information
jareguo committed Mar 9, 2018
1 parent fad39fa commit 144bd9e
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions cocos2d/core/platform/deserialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ var _Deserializer = (function () {
}
return Function('s', 'o', 'd', 'k', 't', sources.join(''));
} : function (self, klass) {
var TYPE = Attr.DELIMETER + 'type';
var EDITOR_ONLY = Attr.DELIMETER + 'editorOnly';
var SERIALIZABLE = Attr.DELIMETER + 'serializable';
var DEFAULT = Attr.DELIMETER + 'default';
Expand Down Expand Up @@ -616,10 +617,21 @@ var _Deserializer = (function () {
// function undefined object(null) string boolean number
var defaultValue = CCClass.getDefault(attrs[propName + DEFAULT]);
if (fastMode) {
var defaultType = typeof defaultValue;
var isPrimitiveType = (defaultType === 'string' && !stillUseUrl) ||
defaultType === 'number' ||
defaultType === 'boolean';
var isPrimitiveType;
var userType = attrs[propName + TYPE];
if (defaultValue === undefined && userType) {
isPrimitiveType = userType === cc.String ||
userType === cc.Integer ||
userType === cc.Float ||
userType === cc.Boolean;
}
else {
var defaultType = typeof defaultValue;
isPrimitiveType = (defaultType === 'string' && !stillUseUrl) ||
defaultType === 'number' ||
defaultType === 'boolean';
}

if (isPrimitiveType) {
o[propName] = prop;
}
Expand Down

0 comments on commit 144bd9e

Please sign in to comment.