The mootools relevance of this question is:
(a) am I reinventing a cow here? If yes, can anyone please point me at the
one hiding in the bushes because my grep and google fu are failing 100% on
this one.
(b) am I (still) a total and utter JavaScript n00b?  (it's my second
prog.language for which I didn't start out by reading the
reference/programmers manual. I'm becoming more lazy with age. I guess today
is payback day for that behaviour adjustment.)

Here's the situation:

the offending JS was this (snippet ripped from a bigger work):

diag:
{
verbose: false,
log: function(/* ... */)
{
if (!this.verbose) return;

if (typeof console !== 'undefined')
{
if (console.info)
{
console.info.apply(console, arguments);
}
else if (console.log)
{
console.log.apply(console, arguments);
}
}
}
}

and it croaked at the console.info.apply line in IE9 with
 "Object doesn't support property or method 'apply'"


to see it happen:
- open IE9 (from the vague noises I ran into on the Net, I suspect it does
the same in IE8; not tested there yet, though)
- in the F12 Console type:

  function testlog() { console.log.apply(console, arguments); }
  testlog('WTF?');

and don't see 'WTF?' but go WTF? anyway:
error "Object doesn't support property or method 'apply'"

I fixed it by augmenting the checks in the above snippet to

if (console.info && console.info.apply)
{
console.info.apply(console, arguments);
}
else if (console.log && console.log.apply)
{
console.log.apply(console, arguments);
}
else if (console.info || console.log)
{
// the MSIE downgrade
...

but while doing this I've been wondering all the time whether I'm not seeing
the cow that's gone before me here and dumped fertilizer to signal all us
cows this here is some pretty heavy grass, right there. Because it's one of
those 'I can't be the bloody first one to run into this!' things.

I don't know whether to be happy or sad when the answer turns out to be 'no
previous cow / no bushes'.



Apart from pointers at cows and stuff, also highly appreciated: pointers at
actually informative MS docs or JS spec chapters saying I'm wrong in
expecting console.log, when it exists, to be like the other functions out
there. ('we here at MS, we do /different/ functions, you know. Us, we have
ourselves objekkts that you can call! Cool, huh!' [*])

Thanks,

Ger



[*] because in F12/Console, this:

  typeof console.log
prints this:
  "object"

*CLUNK*
...

  function test() {}
  typeof test
-->
  "function"

...
rrrright...

Still, /this/ 'console.log object' lets me do this:
  console.log('duh!')
so I'm crossing the edge of sanity with the speedometer trembling in the
red.

-- 
Met vriendelijke groeten / Best regards,

Ger Hobbelt

--------------------------------------------------
web:    http://www.hobbelt.com/
        http://www.hebbut.net/
mail:   [email protected]
mobile: +31-6-11 120 978
--------------------------------------------------

Reply via email to