Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #19257

Re: trying to call onclick with document.getElement() - document.getElement() returns null

Message-ID <1693880.XzSgBGLykG@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Organization PointedEars Software (PES)
Date 2013-04-13 13:26 +0200
Subject Re: trying to call onclick with document.getElement() - document.getElement() returns null
Newsgroups comp.lang.javascript
References (1 earlier) <87fvyv1r7q.fsf@gmail.com> <7902669.URqpOMyR7R@PointedEars.de> <kkb7dq$ggn$1@portraits.wsisiz.edu.pl> <2061545.QaVc4i2NtW@PointedEars.de> <kkbe2r$ioc$1@portraits.wsisiz.edu.pl>

Show all headers | View raw


Cezary Tomczyk wrote:

> W dniu 2013-04-13 11:45, Thomas 'PointedEars' Lahn pisze:
>> Cezary Tomczyk wrote:
>>> W dniu 2013-04-13 10:29, Thomas 'PointedEars' Lahn pisze:
>>>> Mikael Andersson wrote:
>>> [...]
>>>>>>           if (window.XMLHttpRequest) {
>>>>
>>>> Insufficient and error-prone, see isHostMethod().
>>> [...]
>>>
>>> Just our of curiosity: in which environment / scenario this will not be
>>> properly evaluated?
>>
>> Where “XMLHttpRequest” is not a property of the object referred to by
>> “window”, but of another object in the scope chain.
> 
> Even then isHostMethod will return true,

No, it will return “false”.  The point is _not_ that you should call
  
  isHostMethod(window, "XMLHttpRequest")

or

  jsx.object.isHostMethod(jsx.global, "window", "XMLHttpRequest")

instead – that would be equally wrong –, but that isHostMethod() implements 
the *algorithm* to detect host methods *safely*, without implicit type 
conversion.

> […]
> By testing window.XMLHttpRequest I assume that there is really
> "XMLHttpRequest" object.

No, you are assuming that there is an object in the scope chain that has a 
“window” property, which is storing a reference to an object that has an 
“XMLHttpRequest” property that is storing a reference to an object that, 
when [[Constructed]], returns a reference to an object that implements the 
“XMLHttpRequest” interface.

> So, changing this is asking for trouble.
 
Doing it like this is asking for trouble, because “With host objects, all 
bets are off.“ (Lasse Reichstein Nielsen in cljs)

>> Where the host object referred to by “window.XMLHttpRequest” does not
>> take kindly (read: throws unrecoverable exceptions) on being subjected to
>> a type-converting test.
> 
> You referring to 'unknown' type returned by typeof operator in Internet
> Explorer, right?

I am referring to any host object.
 
-- 
PointedEars

Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

trying to call onclick with document.getElement() - document.getElement() returns null jorythompson@gmail.com - 2013-04-12 10:45 -0700
  Re: trying to call onclick with document.getElement() - document.getElement() returns null Jordan Thompson <jorythompson@gmail.com> - 2013-04-12 11:01 -0700
  Re: trying to call onclick with document.getElement() - document.getElement() returns null Mikael Andersson <qubex2@gmail.com> - 2013-04-12 21:31 +0200
    Re: trying to call onclick with document.getElement() - document.getElement() returns null Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-04-13 10:29 +0200
      Re: trying to call onclick with document.getElement() - document.getElement() returns null Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2013-04-13 11:10 +0200
        Re: trying to call onclick with document.getElement() - document.getElement() returns null Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-04-13 11:45 +0200
          Re: trying to call onclick with document.getElement() - document.getElement() returns null Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2013-04-13 13:04 +0200
            Re: trying to call onclick with document.getElement() - document.getElement() returns null Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-04-13 13:26 +0200
              Re: trying to call onclick with document.getElement() - document.getElement() returns null Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2013-04-13 21:12 +0200
                Re: trying to call onclick with document.getElement() - document.getElement() returns null Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-04-13 21:31 +0200
                Re: trying to call onclick with document.getElement() - document.getElement() returns null Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2013-04-16 20:01 +0200
                Re: trying to call onclick with document.getElement() - document.getElement() returns null Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-04-16 23:13 +0200
      Re: trying to call onclick with document.getElement() - document.getElement() returns null Mikael Andersson <qubex2@gmail.com> - 2013-04-13 18:35 +0200

csiph-web