Implement missing JS implementation of _addAttributes.