# ignorenonframetext option breaks frame background color option?

I'm trying to change the background color of a frame in Beamer and have been following the example in this question. The example version works fine, but if you introduce the ignorenonframetext argument to the \documentclass declaration, all of the frames get a white background.

This changes the background color, but produces a frame with the non-frame text.

\documentclass{beamer}

\begin{document}

Some non-frame text.

\begin{frame}{Test}
white
\end{frame}

\setbeamercolor{background canvas}{bg=black}
\begin{frame}{Test}
\textcolor{white}{black}
\end{frame}

\end{document}


And this hides the non-frame text but doesn't change the background color. The only difference is the first line.

\documentclass[ignorenonframetext]{beamer}

\begin{document}

Some non-frame text.

\begin{frame}{Test}
white
\end{frame}

\setbeamercolor{background canvas}{bg=black}
\begin{frame}{Test}
\textcolor{white}{black}
\end{frame}

\end{document}


Is this a bug? What's going on here?

EDIT

It just occurred to me that this isn't a bug: of course it's ignoring the background color command, it's nonframe text. In which case the question is how to set the background color with the ignorenonframetext option in place?

Figured it out. There may be a more elegant way to do this but the following works.

The trick is to temporarily disable ignorenonframetext and re-enable it after the frame in question with \mode*:

\documentclass[ignorenonframetext]{beamer}

\begin{document}

Some non-frame text.

\begin{frame}{Test}
white
\end{frame}

% Turn off ignorenonframetext and change the color
\mode<all>
{\setbeamercolor{background canvas}{bg=black}
\begin{frame}{Test}
\textcolor{white}{black}
\end{frame}
}
\mode*