e><code class="language-javascript">var state = {
    term: &quot;&quot;,
    search: function() {
        // save the state for this route
        // this is equivalent to `history.replaceState({term: state.term}, null, location.href)`
        m.route.set(m.route.get(), null, {replace: true, state: {term: state.term}})

        // navigate away
        location.href = &quot;https://google.com/?q=&quot; + state.term
    }
}

var Form = {
    oninit: function(vnode) {
        state.term = vnode.attrs.term ||