difference in item colorization behavior between latex and beamer documents

Several posts describe the coloration of single items (text and item label); however, these solutions do not work in beamer documents. For instance, following this post, expected results are obtained for articles but not beamer frames:

article:

\documentclass{article}
\usepackage{xcolor}

\newcommand\itemcolor[2]{%
\begingroup%
\color{#1}%
\item #2%
\endgroup}

\begin{document}
\begin{enumerate}
\item first
\itemcolor{red}{second}
\item third
\begingroup
\color{red}
\item fourth
\endgroup
\item fifth
\end{enumerate}
\end{document}


beamer:

\documentclass{beamer}
\usepackage{xcolor}

\setbeamercolor{structure}{fg=black}

\newcommand\itemcolor[2]{%
\begingroup%
\color{#1}%
\item #2%
\endgroup}

\begin{document}
\begin{frame}
\begin{enumerate}
\item first
\itemcolor{red}{second}
\item third
\begingroup
\color{red}
\item fourth
\endgroup
\item fifth
\end{enumerate}
\end{frame}
\end{document}


Note that \setbeamercolor{structure}{fg=black} was used to avoid having the default purple color for the item number, but the effect is the same if that line is omitted (the color of the item number being uniformly purple instead of the designated color).

How can the result for \documentclass{article} be realized for \documentclass{beamer} (i.e., coloration of the item label in addition to the item text)? And what is the reason for the discrepancy in behavior between the two document classes?

• You don't need \usepackage{xcolor} in your presentation, beamer already load this for you. – samcarter_is_at_topanswers.xyz Aug 25 '18 at 12:43

Using a combination of this answer and that answer one may do

\documentclass{beamer}

\setbeamercolor{structure}{fg=black}
\newcommand\itemcolor[2]{%
\setbeamercolor{enumerate item}{fg=#1}\item \textcolor{#1}{#2}
\setbeamercolor{enumerate item}{fg=black}}

\begin{document}
\begin{frame}
\begin{enumerate}
\item first
\itemcolor{red}{second}
\item third
\begingroup
\color{red}
\item fourth
\endgroup
\item fifth
\end{enumerate}
\end{frame}
\end{document}