According to the signature of Ext.ClassManager.create function, It seems that developer can pass in postprocessors in configuration data. However, I think the postprocessors in configuration data will overwrite ClassManager's default postProcessors.
I put sample code to show what happen once we apply "||" operator to two JavaScript arrays. I cited the source code as below and add several lines comments there. Similar things happen to preprocessors in Class.js .
code snippet to show || operator on JavaScript arrays
The output of above code is:
Array is: 0 1 Another array is: 2 3 4Now, let's see what happens in ClassManager.js: Code snippet cited from ClassManager.js
return new Class(data, function() {
//If I pass in data having postprocessors,
//all default postprocessors is going to ignored?
var postprocessorStack = data.postprocessors || manager.defaultPostprocessors,
registeredPostprocessors = manager.postprocessors,
index = 0,
postprocessors = [],
postprocessor, postprocessors, process, i, ln;
delete data.postprocessors;
//if my data has just one postprocessor,
//doesn't postprocessorStack.length only equal to 1?
for (i = 0, ln = postprocessorStack.length; i < ln; i++) {
postprocessor = postprocessorStack[i];
if (typeof postprocessor === 'string') {
postprocessor = registeredPostprocessors[postprocessor];
if (!postprocessor.always) {
if (data[postprocessor.name] !== undefined) {
postprocessors.push(postprocessor.fn);
}
}
else {
postprocessors.push(postprocessor.fn);
}
}
else {
postprocessors.push(postprocessor);
}
}
process = function(clsName, cls, clsData) {
postprocessor = postprocessors[index++];
if (!postprocessor) {
manager.set(className, cls);
Ext.Loader.historyPush(className);
if (createdFn) {
createdFn.call(cls, cls);
}
return;
}
if (postprocessor.call(this, clsName, cls, clsData, process) !== false) {
process.apply(this, arguments);
}
};
process.call(manager, className, this, data);
}
I reported a bug here to see if I am right or it is just because I do not understand the code. Please feel free to make comments below if I am wrong.
No comments:
Post a Comment