Core: Improve elementValue method

Do not rewrap several times. Call .val() only when required.

Closes #1055