Fixing issue where empty html elements were being treated as text nodes