Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>Edit</strong>: I've been reading Closure: The Definitive Guide, and I just realized that you can simply add the <a href="http://code.google.com/closure/compiler/docs/js-for-compiler.html#tag-this" rel="nofollow noreferrer"><code>/** @this {Element} */</code> annotation</a> before your event handler to make Closure Compiler stop complaining.</p> <p>See the <a href="https://developers.google.com/closure/compiler/docs/error-ref#warn" rel="nofollow noreferrer">Closure Compiler warning reference</a>. The Closure Compiler gives this warning when you use <code>this</code> within a function that is not either annotated <code>/** @constructor */</code> or is within the <code>prototype</code> of a class. The compiler assumes that you'll never use <code>this</code> when a function is called in the context of another object (which is what event callbacks do).</p> <p>Some places that you might have to change to make Closure Compiler stop complaining with this warning:</p> <ul> <li>Don't use <code>link.onclick = ...</code> directly, because you have to mess with <code>this</code> and <code>e || window.event</code>. Instead, use jQuery to wrap the event handler, since <a href="http://api.jquery.com/category/events/event-object/" rel="nofollow noreferrer">jQuery's event object has <code>e.currentTarget</code></a>.</li> <li>If you're using <code>this</code> within a <code>jQuery.each</code>, replace <code>this</code> with the second parameter of your function. E.g., <code>jQuery.each([1, 2, 3], function(i, val) { ... val ... };</code>.</li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload