I’ve seen this a lot, but most recently in the TinyMCE code, where the theme is in charge of outputting whatever the end user sees. Switching themes can be painful because some themes add functionality or styling that ties the content to it.
There are conventions that the theme "must call
wp_footer()" or some things won’t work.
I think the theme should be more limited.
There could be a filter for the type of output, that defaults to HTML. The core code would have the skeleton to output, filtering the attributes of
<body>, and firing actions for each section like we already have for
wp_footer, but add
wp_body_open where the template loader would be. That means template files would not include anything but body content. The filter for the attributes would be a core function to be used for all major content areas, or have a core function that the theme calls to get output filtered. (needs design)
Yes, I have already written a way this could work, and use the attribute filter function in my theme (which has been working for 3 years).