似乎我不了解javascript中的一些基础知识,
我有以下代码:
Raphael.fn.group = function() {
var out = Raphael._engine.group(this);
this.__set__ && this.__set__.push(out);
return out;
};
(window.Raphael.svg &&
function(e) {
e.group = function(svg) {
//Want this to be called $ function defined in Raphael._engine
// as var $=function(..){..}
// line 3780
var el = $("g");
svg.canvas && svg.canvas.appendChild(el);
var res = new Element(el, svg);
res.type = "group";
return res;
}
})(window.Raphael._engine);
var paper = Raphael("out", 800, 600);
//test with circle;
paper.circle(100, 100, 50);
//test with new method;
paper.group();
所以我发现 $ near 注释行来自全局范围,而不是来自 Raphael._engine 范围,这里有什么方法可以扩展 _engine,或者我应该修补 raphael 来做这些事情?