View Single Post
Old 01-30-2013, 11:02 PM   PM User | #15
rnd me
Senior Coder

 
rnd me's Avatar
 
Join Date: Jun 2007
Location: Urbana
Posts: 3,469
Thanks: 9
Thanked 466 Times in 450 Posts
rnd me is a jewel in the roughrnd me is a jewel in the roughrnd me is a jewel in the rough
Quote:
Originally Posted by Old Pedant View Post
Well, I *did* say "for example" about createDocumentFragment.

Okay, okay...I'll show my scheme. It's not clever. It's not better. It's just simple. Back later.

But I just noticed this in your code:
Code:
		 // grab 3 different items:
		for (var $i = 0; $i < 3; $i++) {
			frag.appendChild(items[Math.floor(Math.random() * items.length)]);
		}
??? How does that answer my prior objection that you might get the same <li> all 3 times? And you will surely get the same item twice more often than would make the user happy. What am I missing?
when you append an element to the fragment, it disappears from the nodeList...

remember, unlike arrays of elements, nodeLists from element.getXXXbyXXX() methods are live.

the other routines i imagined were much more complex, which is why i was curious about what you had in mind.
__________________
my site (updated 5/13)
STATS (2013/5) HTML5:90.2% MOB:14% IE7:0.5% IE8:8.6% IE9:9.8% IE10:10%

Last edited by rnd me; 01-30-2013 at 11:06 PM..
rnd me is offline   Reply With Quote