[Proto-Scripty] Re: Function expected err when doing instanceof in IE
On Dec 2, 12:11 am, yoshi <[EMAIL PROTECTED]> wrote: > but it is defined globally? cuz i open up the js debugger console in > IE8 beta, i type 'Element' and the debugger returns {...} so it is > defined? And y is only Element not globally defined and not the > Template or Hash object ? I think prototype define them on global > scope? > > what i m trying to do is write a function that loops through all > functions of an obj, do some AOP. But i m excluding Prototype defined > objects because it causes too much recursion; to do that i m manually > saying if obj is instance of Element, Hash and Array do nothing, and > Element is causing problem in IE. I might be missing something, but an object that is an `instanceof Element` is not necessarily "Prototype defined" object; It's the one that has `Element`'s [[Prototype]] somewhere in its prototype chain. Afaik IE<8 does not ensure such inheritance in most of its DOM elements. If you need to check whether an object is an element, this naive solution should do it most of the time: function isElement(o) { return (!!o && o.nodeType === 1) } Also, don't forget that `instanceof` is not cross-frame "safe", so you might want to use Prototype's `Object.isArray` and `Object.isHash`. > > things works in firefox of course > > thanks again for the help [...] -- kangax --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Function expected err when doing instanceof in IE
but it is defined globally? cuz i open up the js debugger console in IE8 beta, i type 'Element' and the debugger returns {...} so it is defined? And y is only Element not globally defined and not the Template or Hash object ? I think prototype define them on global scope? what i m trying to do is write a function that loops through all functions of an obj, do some AOP. But i m excluding Prototype defined objects because it causes too much recursion; to do that i m manually saying if obj is instance of Element, Hash and Array do nothing, and Element is causing problem in IE. things works in firefox of course thanks again for the help On Dec 1, 7:29 pm, kangax <[EMAIL PROTECTED]> wrote: > On Dec 1, 7:36 pm, yoshi <[EMAIL PROTECTED]> wrote: > > > hi all, > > > the fowllowing js is causing err on IE: > > $('someThing') instanceof Element > > > error: Function expected > > > it is fine on any other objects such as: > > $('someThing') instanceof Template --> return false > > $('someThing') instanceof Hase --> return false > > > any idea y Element is diff or how i can get around this problem? > > global `Element` is undefined in IE<8b, hence `instanceof` throws > TypeError (as it expects a function as a right-hand expression). What > exactly are you trying to accomplish with this "check"? > > > > > thanks in advance > > -- > kangax --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Function expected err when doing instanceof in IE
On Dec 1, 7:36 pm, yoshi <[EMAIL PROTECTED]> wrote: > hi all, > > the fowllowing js is causing err on IE: > $('someThing') instanceof Element > > error: Function expected > > it is fine on any other objects such as: > $('someThing') instanceof Template --> return false > $('someThing') instanceof Hase --> return false > > any idea y Element is diff or how i can get around this problem? global `Element` is undefined in IE<8b, hence `instanceof` throws TypeError (as it expects a function as a right-hand expression). What exactly are you trying to accomplish with this "check"? > > thanks in advance -- kangax --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---