target">Predictable event target</h3>
<p>The <code>m.withAttr()</code> helper reads the value of the element to which the event handler is bound, which is not necessarily the same as the element where the event originated.</p>
<pre><code class="lang-javascript">var state = {
    url: &quot;&quot;,
    setURL: function(url) {state.url = url}
}

var MyComponent = {
    view: function() {
        return m(&quot;a[href=&#39;/foo&#39;]&quot;, {onclick: m.withAttr(&quot;href&quot;, state.setURL)}, [
            m