Merge pull request #1425 from jareguo/v1.4

extract cc._RF to forward compatible with v1.5 editor
This commit is contained in:
Jare Guo
2017-01-12 15:18:00 +08:00
committed by GitHub
2 changed files with 38 additions and 31 deletions
+37 -30
View File
@@ -1,5 +1,5 @@
/****************************************************************************
Copyright (c) 2013-2016 Chukong Technologies Inc.
Copyright (c) 2013-2017 Chukong Technologies Inc.
http://www.cocos.com
@@ -25,41 +25,48 @@
var requiringFrames = []; // the requiring frame infos
cc._RFpush = function (module, uuid, script) {
if (arguments.length === 2) {
script = uuid;
uuid = '';
}
requiringFrames.push({
uuid: uuid,
script: script,
module: module,
exports: module.exports, // original exports
beh: null
});
};
cc._RFpop = function () {
var frameInfo = requiringFrames.pop();
// check exports
var module = frameInfo.module;
var exports = module.exports;
if (exports === frameInfo.exports) {
for (var anyKey in exports) {
// exported
return;
cc._RF = {
push: function (module, uuid, script) {
if (arguments.length === 2) {
script = uuid;
uuid = '';
}
// auto export component
requiringFrames.push({
uuid: uuid,
script: script,
module: module,
exports: module.exports, // original exports
beh: null
});
},
pop: function () {
var frameInfo = requiringFrames.pop();
// check exports
var module = frameInfo.module;
var exports = module.exports;
if (exports === frameInfo.exports) {
for (var anyKey in exports) {
// exported
return;
}
// auto export component
module.exports = exports = frameInfo.beh;
}
},
peek: function () {
return requiringFrames[requiringFrames.length - 1];
}
};
cc._RFpeek = function () {
return requiringFrames[requiringFrames.length - 1];
};
if (CC_EDITOR) {
cc._RFreset = function () {
cc._RF.reset = function () {
requiringFrames = [];
};
}
cc._RFpush = cc._RF.push;
cc._RFpop = cc._RF.pop;
cc._RFpeek = cc._RF.peek;
if (CC_EDITOR) {
cc._RFreset = cc._RF.reset;
}
+1 -1
View File
@@ -61,7 +61,7 @@ var idGenerater = new IdGenerater('Node');
* @extends Object
* @private
*/
var BaseNode = cc.Class(/** @lends cc.Node# */{
var BaseNode = cc.Class({
name: 'cc._BaseNode',
extends: cc.Object,
mixins: [cc.EventTarget],