diff --git a/cocos2d/core/node-activator.js b/cocos2d/core/node-activator.js index adf5a7e7c4..23987801f5 100644 --- a/cocos2d/core/node-activator.js +++ b/cocos2d/core/node-activator.js @@ -47,7 +47,7 @@ var supportJit = cc.supportJit; var callPreload = supportJit ? 'c.__preload();' : function (c) { c.__preload(); } var callOnLoad = supportJit ? ('c.onLoad();c._objFlags|=' + IsOnLoadCalled) : function (c) { c.onLoad(); - c._objFlags|= IsOnLoadCalled; + c._objFlags |= IsOnLoadCalled; } // for __preload: use internally, no sort diff --git a/cocos2d/core/platform/CCClass.js b/cocos2d/core/platform/CCClass.js index 4d7674d1a7..1f7d159a96 100644 --- a/cocos2d/core/platform/CCClass.js +++ b/cocos2d/core/platform/CCClass.js @@ -622,34 +622,35 @@ var _createCtor = cc.supportJit ? function (ctors, baseClass, className, options this.__initProps__(CCClass); - var args = arguments; - var self = this; - function init () { - if (ctorLen === 1) { - CCClass.__ctors__[0].apply(self, args); - } - else { - var cs = CCClass.__ctors__; - for (var i = 0; i < ctorLen; i++) { - cs[i].apply(self, args);; - } - } - } - // call user constructors var ctorLen = ctors.length; + var cs = CCClass.__ctors__; if (ctorLen > 0) { var useTryCatch = ! (className && className.startsWith('cc.')); if (useTryCatch) { try { - init(); + if (ctorLen === 1) { + cs[0].apply(this, arguments); + } + else { + for (var i = 0; i < ctorLen; i++) { + cs[i].apply(this, arguments);; + } + } } catch(e) { cc._throw(e); } } else { - init(); + if (ctorLen === 1) { + cs[0].apply(this, arguments); + } + else { + for (var i = 0; i < ctorLen; i++) { + cs[i].apply(this, arguments);; + } + } } } }; diff --git a/index.js b/index.js index 5bca974237..47cb5d2e27 100644 --- a/index.js +++ b/index.js @@ -139,7 +139,7 @@ defineMacro('CC_BUILD', false); cc = {}; // check whether support jit -cc.supportJit = Function('') !== undefined; +cc.supportJit = typeof Function('') === 'function'; // The namespace for original nodes rendering in scene graph. _ccsg = {}; diff --git a/jsb/index.js b/jsb/index.js index ead122e2c2..a1712c471a 100644 --- a/jsb/index.js +++ b/jsb/index.js @@ -26,7 +26,7 @@ 'use strict'; // check whether support jit -cc.supportJit = Function('') !== undefined; +cc.supportJit = typeof Function('') === 'function'; function defineMacro (name, defaultValue) { // if "global_defs" not preprocessed by uglify, just declare them globally,