OLD | NEW |
1 this.foo = this.foo + 1; // OK - outside of function. | 1 this.foo = this.foo + 1; // OK - outside of function. |
2 | 2 |
3 function f() { | 3 function f() { |
4 this.foo = this.foo + 1; // OK - global |this|. | 4 this.foo = this.foo + 1; // OK - global |this|. |
5 } | 5 } |
6 | 6 |
7 /** | 7 /** |
8 * @constructor | 8 * @constructor |
9 */ | 9 */ |
10 function TypeOne() { | 10 function TypeOne() { |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 callbackWithThis.apply(null); // ERROR - No receiver. | 221 callbackWithThis.apply(null); // ERROR - No receiver. |
222 callbackNoThis.call(this); // ERROR - Function has no @this annotation. | 222 callbackNoThis.call(this); // ERROR - Function has no @this annotation. |
223 callbackNoThis.call(foo); // ERROR - Function has no @this annotation. | 223 callbackNoThis.call(foo); // ERROR - Function has no @this annotation. |
224 callbackNoThis.apply(this); // ERROR - Function has no @this annotation. | 224 callbackNoThis.apply(this); // ERROR - Function has no @this annotation. |
225 callbackNoThis.bind(this); // ERROR - Function has no @this annotation. | 225 callbackNoThis.bind(this); // ERROR - Function has no @this annotation. |
226 | 226 |
227 this.memberTwo(callbackWithThis); // ERROR - Used as argument with no bo
und receiver. | 227 this.memberTwo(callbackWithThis); // ERROR - Used as argument with no bo
und receiver. |
228 this.memberTwo(callbackWithThis.bind(null, 2)); // ERROR - Used as argum
ent with no bound receiver (null means "no receiver"). | 228 this.memberTwo(callbackWithThis.bind(null, 2)); // ERROR - Used as argum
ent with no bound receiver (null means "no receiver"). |
229 this.memberTwo(callbackNoThis.bind(this)); // ERROR - Bound to a receive
r but has no @this annotation. | 229 this.memberTwo(callbackNoThis.bind(this)); // ERROR - Bound to a receive
r but has no @this annotation. |
230 this.memberTwo(callbackNoThis.bind(foo)); // ERROR - Bound to a receiver
but has no @this annotation. | 230 this.memberTwo(callbackNoThis.bind(foo)); // ERROR - Bound to a receiver
but has no @this annotation. |
| 231 |
| 232 // Callback receivers specified as arguments. |
| 233 |
| 234 array.forEach(callbackWithThis, this); |
| 235 array.forEach(callbackNoThis); |
| 236 |
| 237 array.forEach(callbackWithThis); // ERROR - No receiver. |
| 238 array.forEach(callbackNoThis, this); // ERROR - Receiver for callback wi
th no @this annotation. |
| 239 |
| 240 var isMultiline = false; |
| 241 |
| 242 element.addEventListener("click", callbackNoThis); |
| 243 element.addEventListener("click", callbackNoThis, true); |
| 244 element.addEventListener("click", callbackNoThis, false); |
| 245 element.addEventListener("click", callbackNoThis, isMultiline); // OK -
ignored. |
| 246 |
| 247 element.addEventListener("click", callbackNoThis, this); // ERROR. |
| 248 |
| 249 element.addEventListener("click", callbackWithThis, this); |
| 250 element.addEventListener("click", callbackWithThis, foo); // OK - ignore
d. |
| 251 element.addEventListener("click", callbackWithThis, isMultiline); // OK
- ignored. |
| 252 |
| 253 element.addEventListener("click", callbackWithThis, true); // ERROR. |
| 254 element.addEventListener("click", callbackWithThis, false); // ERROR. |
| 255 |
| 256 // DevTools-specific. |
| 257 |
| 258 /** |
| 259 * @suppressReceiverCheck |
| 260 * @this {Object} |
| 261 */ |
| 262 function ignoredCallbackWithThis() |
| 263 { |
| 264 this.foo = 1; |
| 265 } |
| 266 object.callFunction(func, [], ignoredCallbackWithThis); // OK - ignored. |
231 }, | 267 }, |
232 | 268 |
233 memberTwo: function(arg) {} | 269 memberTwo: function(arg) {} |
234 } | 270 } |
OLD | NEW |