On Oct 9, 3:41 pm, Andrew R <[email protected]> wrote:
> Okay, this is really odd.
>
> After adding the logging in both lib.$ and chrome.$ in the firebug
> code, I found something really odd. When firebug is inside firefox,
> everything is cool and the global "$" as seen by chrome.$ is the same
> as FBL.$, but when I open firebug in a window, I get a different "$"
> in chrome.js.
>
> I changed the $ function in chrome.$ to this:
> $: function(id)
> {
> FBTrace.sysout("chrome.$ document: "+(document.location) + " for ID: "
> + id + " and $ is: " + $ + " FBL.$ = " + FBL.$);
> return $(id);
> },
>
> And $ in lib.js to this:
> this.$ = function(id, doc)
> {
> FBTrace.sysout("lib.$ document: "+(doc?
> doc.location:document.location) + " for ID: " + id);
>
> if (doc)
> return doc.getElementById(id);
> else
> return document.getElementById(id);
>
> };
>
> But when I have firebug in its own window I see this output in the
> console:
>
> FTS0: chrome.$ document: chrome://firebug/content/firebug.xul for ID:
> fbAdfvTypeMenu and $ is: function $(id, doc) {
> if (doc) {
> return doc.getElementById(id);
> } else {
> return document.getElementById(id);
> }} FBL.$ = function (id, doc) {
>
> FBTrace.sysout("lib.$ document: " + (doc ? doc.location :
> document.location) + " for ID: " + id);
> if (doc) {
> return doc.getElementById(id);
> } else {
> return document.getElementById(id);
> }
>
> }
>
> As you can see, the global "$" function is different than "FBL.$"
> function. I tried disabling all my extensions except for firebug and
> mine, and so far I do not see who is overwriting the "$" in chrome's
> namespace or window object. Quite odd. Don't suppose you know what is
> going on?
I think these are the same function being accessed two different ways.
At the top of chrome.js you will see
(function() { with (fbXPCOMUtils) {
and at the top of lib.js:
var FBL = fbXPCOMUtils;
So all of the functions defined in lib.js are global functions in
chrome.js. This is generally true through out firebug source. The
only reason we use FBL.foo() is if we are in an event handler called
by something in Firefox that does not include our lib.js scope.
So "$" in chrome.js resolves to a global from the with(fbXPCOMUtils)
and FBL.$ resolves to the same method as a property of FBL.
jjb
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Firebug" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/firebug?hl=en
-~----------~----~----~----~------~----~------~--~---