I just learned something very basic about a limitation of Firebug -- so
basic that I suspect almost everyone here already knew this. I'm only
posting it here (at the risk of seeming rather ignorant) because I want to
make sure I don't misunderstand the situation.

I have a method that, depending on where it's called from, sometimes
reports a meaningful caller and stack trace, and sometimes not. I
originally put this into my JavaScript file:

console.info(
   if( arguments.callee.caller.name ) {
         " layout.adjust has been called by: " +
arguments.callee.caller.name
      } else {
        " layout.adjust caller is unclear, so here's a stack trace: "
            console.trace() }
)    // end console.info

The above didn't work; the console just reported a syntax error (with no
further explanation) as soon as it hit the 'if' clause. I experimented with
a far simpler console call ( something like: if(1==1) "FOO" ) and got the
same error. I tried googling this but couldn't find anything, so... do I
understand correctly that you just can't put conditional logic into a
Firebug console call?

Instead, I used this code:

 if( arguments.callee.caller.name ) {
        console.info( " layout.adjust has been called by: " +
arguments.callee.caller.name )
            } else {
        console.info( " layout.adjust has been called, but the caller is
unclear, so here's a stack trace: " ); console.trace();
        } // end else

That works, but seems messy to me because the only purpose of the
conditionals is for the Firebug feedback; they have no purpose in the page
code itself. Also the stack trace in this case is extremely uninformative.
Oh well.

BTW, I also discovered while googling around that 'arguments.callee.caller'
is frowned upon (which I didn't know); you're supposed to give a name to
your anonymous function expression so it ain't really anonymous and you can
refer to it that way. But they seem to be talking about function recursion,
which I'm not doing, and also my "functions" are really methods of my
custom objects -- in this case  layout.adjust = function() { blah
blah...     not a function expression in the way I usually think of it. I
think I'm going to try an end-run around all this in my code by simply
passing the calling context as an argument somehow.

In the case of a function or method that can be called from various places
in various contexts, how do most Firebug users find out where it was called
from? I mean especially in cases where there's no reported caller or where
a stack trace is vague or uninformative.

-- 
You received this message because you are subscribed to the Google Groups 
"Firebug" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/firebug.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/firebug/CAMoMLKj3SR%3DLTMibphaqWDPuE9i5hXAesLiF0xY29_68XfVroQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to