shadow-dom: Fixed indent style and performance improvement

Reflects the comment of the review of PR #140 and #157.