SteveSanderson/knockout — pull request #709 by AlexGalays (2012-11-13 09:44:09+00:00)
Title: Empty text node optimization

Some browsers (e.g Chrome 23) are very slow at rendering empty text nodes added by ko (They seem to always be present when reading the childNodes property). A foreach binding with an anonymous template with just one **li** ends up appending 3 nodes per item: text, li, text. Some browsers render this in about as much time as a single li, some others render it very slowly (About 3 times more than expected). The difference in speed is really noticeable when the number of items is moderate or high.

This commit ignores the empty text nodes so that foreach is constantly fast.

Note that there will usually be further empty text nodes nested in the template markup but it doesn't incur a performance penalty as these don't get explicitly appended to the DOM by ko.