Layout performance improvements
Fix check for text nodes