Handle undefined theme the right way

Sorry for the confusion.
This is the right way to do #10236.