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


Groups > comp.lang.javascript > #25916

Re: eventDispath how that work

From Joao Rodrigues <groups_jr-1@yahoo.com.br>
Newsgroups comp.lang.javascript
Subject Re: eventDispath how that work
Date 2014-10-15 18:59 -0300
Organization Aioe.org NNTP Server
Message-ID <m1mqn3$jtd$1@speranza.aioe.org> (permalink)
References <m1jblb$4a7$1@shakotay.alphanet.ch> <16yzpmtikrwk0$.1schjt968gcx$.dlg@40tude.net> <1791221.7QuZn8ShVB@PointedEars.de> <14ignx5l3afjk.j09ycbpj6e7h.dlg@40tude.net> <1695306.Qhb0f9IOXP@PointedEars.de>

Show all headers | View raw


On 15/10/2014 18:02, Thomas 'PointedEars' Lahn wrote:
> Correction: The latter would be equivalent to
> 
> document.querySelectorAll(".foo")
> 
> Instead,
> 
> document.getElementsByClassName("foo")[0]
> 
> would be equivalent to the former, provided that the method returned
> a reference to an object implementing the NodeList or HTMLCollection
> interface (which would need to be tested before the “0” property read
> access).

Pardon me, but these methods are not equivalent because:

a) The getElementsByClassName() method returns a live NodeList whereas
querySelectorAll() returns a static NodeList;

b) The getElementsByClassName() method excludes any elements that are
not descendants of the HTMLElement object on which the method was
invoked. However, even though the querySelectorAll() method is invoked
on an element, selectors are still evaluated in the context of the
entire document. For instance, the querySelectorAll() method will still
match the div element's child p element, even though the body element is
not a descendant of the div element itself.

var div = document.getElementById("bar");
var p = div.querySelector("body p");


ref:
<http://www.w3.org/TR/2008/WD-html5-20080610/dom.html#getelementsbyclassname>
<http://www.w3.org/TR/selectors-api2/>

-- 
Joao Rodrigues

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


Thread

eventDispath how that work Une Bévue <unbewusst.sein@fai.invalid> - 2014-10-14 16:23 +0200
  Re: eventDispath how that work JJ <jj4public@vfemail.net> - 2014-10-15 03:24 +0700
    Re: eventDispath how that work Une Bévue <unbewusst.sein@fai.invalid> - 2014-10-15 10:49 +0200
    Re: eventDispath how that work Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-10-15 15:24 +0200
      Re: eventDispath how that work JJ <jj4public@vfemail.net> - 2014-10-16 02:10 +0700
        Re: eventDispath how that work Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-10-15 23:02 +0200
          Re: eventDispath how that work Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2014-10-15 18:59 -0300
            Re: eventDispath how that work Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-10-16 02:48 +0200
          Re: eventDispath how that work Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-10-16 18:11 +0200
      Re: eventDispath how that work Une Bévue <unbewusst.sein@fai.invalid> - 2014-10-15 22:06 +0200
        Re: eventDispath how that work Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-10-15 23:39 +0200
          Re: eventDispath how that work Une Bévue <unbewusst.sein@fai.invalid> - 2014-10-16 14:26 +0200
            Re: eventDispath how that work Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2014-10-16 14:39 -0300
              Re: eventDispath how that work Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2014-10-16 19:44 -0300
                Re: eventDispath how that work Une Bévue <unbewusst.sein@fai.invalid> - 2014-10-17 09:00 +0200
                Re: eventDispath how that work Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2014-10-17 10:16 -0300
                Re: eventDispath how that work Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-10-17 21:40 +0200
                Re: eventDispath how that work Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2014-10-17 17:03 -0300
                Re: eventDispath how that work Une Bévue <unbewusst.sein@fai.invalid> - 2014-10-18 15:46 +0200
              Re: eventDispath how that work Une Bévue <unbewusst.sein@fai.invalid> - 2014-10-17 08:26 +0200

csiph-web