function htmlAttributeEncodeValue(value) {
    return value.replace(/[<>"'&]/g, ch => {
        switch (ch) {
            case '<': return '&lt;';
            case '>': return '&gt;';
            case '"': return '&quot;';
            case '\'': return '&apos;';
            case '&': return '&amp;';
        }
        return ch;
    });
}
Encodes the given value so that it can be used as literal value in html attributes.

In other words, computes `$val`, such that `attr` in `<div attr="$val" />` has the runtime value `value`.
This prevents XSS injection.