Attributes: Trim whitespace from option text when returned as a value

Fixes #14858
Ref #14686
Closes gh-1531
(cherry picked from commit 9ec429cf6270e455aba4eba85f4db80e633806b6)

Conflicts:
	src/attributes/val.js