Seems I not understand some fundamental in javascript,
I have the following code:
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();
So I found that $ near commented line got from global scope, not from Raphael._engine scope, is here any way to extend _engine, or I should to patch raphael to do such things ?
Ah, one last edit.
No, you can’t get
var $defined inside an object constructor without altering that source code to expose $ somehow. That’s the JavaScript equivalent of a private property.