[tidy] fetch document elements only once