just thought that bug 939971 was happening because I was adding a text node for empty strings. If I prevent adding a text node for empty strings it would not have triggered bug 939971.