tag:blogger.com,1999:blog-34454975.post323975706399739457..comments2023-06-28T16:58:41.189+02:00Comments on Web Reflection: One Function To Trap Them AllAndrea Giammarchihttp://www.blogger.com/profile/16277820774810688474noreply@blogger.comBlogger13125tag:blogger.com,1999:blog-34454975.post-49534274072377494272010-04-21T14:13:05.633+02:002010-04-21T14:13:05.633+02:00Sorry to post again after 4 months...
Yes, childNo...Sorry to post again after 4 months...<br />Yes, childNodes is indeed a live NodeList, but ret is just an Array. And we're just adding the matching elements to that array. So, the returned object is not a live list.<br /><br />That's what I wanted to say.<br />IE8 still doesn't implement getElementsByClassName but implements querySelectorAll, so if you want to replicate getElementsByClassName you can use querySelectorAll instead, which return a non-live node collection.<br /><br />I understand that's not the point of your idea, which is to create a scope where you can define every function you want that can make a good use of the live NodeList of all the elements.<br />So defining getElementsByClassName was just an example, I guess.MaxArthttps://www.blogger.com/profile/08858346973743121828noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-46165786543205193482009-12-22T16:16:03.351+01:002009-12-22T16:16:03.351+01:00you are missing the childNodes variables ... pleas...you are missing the childNodes variables ... please read again, test, understand, and ask more if necessary. RegardsAndrea Giammarchihttps://www.blogger.com/profile/16277820774810688474noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-63505803921860852532009-12-22T15:39:31.834+01:002009-12-22T15:39:31.834+01:00It doesn't behave like a live collection... At...It doesn't behave like a live collection... At least on IE8 SM. And it seems obvious to me, since ret is nothing more than an array.<br />Am I missing something?<br /><br />If you want something like a static node list, you can check for querySelectorAll, which is provided by IE8 and should be a lot faster.<br /><br />MassimoAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-34454975.post-71731056945767636592009-09-22T23:25:05.201+02:002009-09-22T23:25:05.201+02:00I like your approach very much, thanks for sharing...I like your approach very much, thanks for sharing :)Nicolashttp://thejit.orgnoreply@blogger.comtag:blogger.com,1999:blog-34454975.post-47890993046568080492009-09-22T21:47:10.243+02:002009-09-22T21:47:10.243+02:00J% I am taking the classic W3C page used in Tasksp...J% I am taking the classic W3C page used in Taskspeed and others tests.<br /><br />I put the function on the top, zero differences.<br /><br />Then I perform a couple of searches, and I take time for each search.<br /><br />Under windows, timers are almost useless, cause the result for a call that took 8 ms, for example, will always e 15 or 16, and never 8. This problem has been explained in John Resig blog few months (years?) ago :)Andrea Giammarchihttps://www.blogger.com/profile/16277820774810688474noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-48622259225465177012009-09-22T21:15:34.102+02:002009-09-22T21:15:34.102+02:00Can you elaborate on the tests you're doing? ...Can you elaborate on the tests you're doing? I don't understand what you mean by "The problem is that I am basing my tests with wrong timers, so it's 0 or it's 15/16"J5https://www.blogger.com/profile/11773185885253302158noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-51133435484154455172009-09-22T11:35:45.987+02:002009-09-22T11:35:45.987+02:00OK, no slowdown at all, and actually no benefits a...OK, no slowdown at all, and actually no benefits as well. The problem is that I am basing my tests with wrong timers, so it's 0 or it's 15/16, I cannot truly understand if I it is worth it. In any case, as document.getElementsByClassName, it's really fast :DAndrea Giammarchihttps://www.blogger.com/profile/16277820774810688474noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-34088877722592715592009-09-22T08:45:57.403+02:002009-09-22T08:45:57.403+02:00Samer, that means look for a space or it starts wi...Samer, that means look for a space or it starts with and look for a space after or it ends with.<br />The question mark is to avoid RegExp result cache.<br /><br />Aaraon, not yet, what I expect is better loop performances, what I need to test, is if a wrapped live collection, the biggest one, slows down somehow the angine a la DOMNodeInserted. I think no, but I am not sure yet.<br /><br />RegardsAndrea Giammarchihttps://www.blogger.com/profile/16277820774810688474noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-21724268201381785922009-09-22T02:26:32.733+02:002009-09-22T02:26:32.733+02:00Any benchmarks yet?Any benchmarks yet?Aaron Heckmannhttps://www.blogger.com/profile/16593937728891710208noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-72490497025884485082009-09-22T00:58:05.991+02:002009-09-22T00:58:05.991+02:00Hey I don't understand the regex
(?:\\s|^) do...Hey I don't understand the regex<br /><br />(?:\\s|^) doesn't that mean you're checking for character before the beg. of the line?Samer Ziadehhttps://www.blogger.com/profile/10396335413969420484noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-58027583205083493772009-09-21T23:55:34.363+02:002009-09-21T23:55:34.363+02:00@fearphage thanks again for the nodeType suggestio...@fearphage thanks again for the nodeType suggestion (and the silly typo for the className) :D<br /><br />Cheers guysAndrea Giammarchihttps://www.blogger.com/profile/16277820774810688474noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-37897961143844997732009-09-21T23:00:42.674+02:002009-09-21T23:00:42.674+02:00I like the thought process here. Good idea.I like the thought process here. Good idea.fearphagehttps://www.blogger.com/profile/17859362971425712481noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-36164279451492024652009-09-21T22:42:18.465+02:002009-09-21T22:42:18.465+02:00Nice approach. Cool way to write your for loop als...Nice approach. Cool way to write your for loop also.Anonymousnoreply@blogger.com