The view method returns a Mithril virtual DOM tree, which is a simple JavaScript object. For example, the following JSX:
return (
<div className="foo">
<span id="bar">
Hello <strong>World</strong>!
</span>
</div>
);
Becomes:
{tag: 'div', attrs: {className: 'foo'}, children: [
{tag: 'span', attrs: {id: 'bar'}, children: [
'Hello ', {tag: 'strong', children: 'World'}, '!'
]}
]}
Thus, if you extend the view method of a component, you can selectively manipulate the virtual DOM tree to apply your changes. As long as you do it in a safe way (by checking that all of the objects you want to change actually exist), you don't have to worry too much about BC breaks:
extend(IndexPage.prototype, 'view', function(vdom) {
if (vdom.children && vdom.children.splice) {
const insert = <div className="whatever">Hello!</div>;
vdom.children.splice(1, 0, insert);
}
});