generators inside DOM events
What? That would just cause the event handler function to return a generator object, which the browser would not use or do anything with. It would have no effect.
What? That would just cause the event handler function to return a generator object, which the browser would not use or do anything with. It would have no effect. ________________________________ From: es-discuss <es-discuss-bounces at mozilla.org> on behalf of Andrea Giammarchi <andrea.giammarchi at gmail.com> Sent: Wednesday, January 08, 2014 15:50 To: es-discuss at mozilla.org Subject: generators inside DOM events I am not sure this has been discussed already but I wonder what would happen if `yield` is used inside an event such 'beforeunload', 'unload', or even 'click' and others DOM related events. Main concerns: 1. it's a UA trap potentially making impossible to leave a page or complete a user meant action 2. not even transpilers can solve cases like this (i.e. a still valid event eventually stopped after some generator logic where if simulated the event would be expired at the time the function will be invoked) Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140108/d02b60f2/attachment.html>
Sorry, I explained it badly ... let me try again:
what if a DOM event handler uses/creates/invokes inside its function body a generator?
Will the event pause until this will be satisfied?
a.addEventListener('click', function(e){ if(methodThatInvokesGenerator()) e.stopPropagation(); });
Is this a concern?
Sorry, I explained it badly ... let me try again:
what if a DOM event handler uses/creates/invokes inside its function body a
generator?
Will the event pause until this will be satisfied?
`a.addEventListener('click', function(e){ if(methodThatInvokesGenerator())
e.stopPropagation(); });`
Is this a concern?
Thanks
On Wed, Jan 8, 2014 at 12:53 PM, Domenic Denicola <
domenic at domenicdenicola.com> wrote:
> What? That would just cause the event handler function to return a
> generator object, which the browser would not use or do anything with. It
> would have no effect.
>
>
> ------------------------------
> *From:* es-discuss <es-discuss-bounces at mozilla.org> on behalf of Andrea
> Giammarchi <andrea.giammarchi at gmail.com>
> *Sent:* Wednesday, January 08, 2014 15:50
> *To:* es-discuss at mozilla.org
> *Subject:* generators inside DOM events
>
> I am not sure this has been discussed already but I wonder what would
> happen if `yield` is used inside an event such 'beforeunload', 'unload', or
> even 'click' and others DOM related events.
>
> Main concerns:
>
> 1. it's a UA trap potentially making impossible to leave a page or
> complete a user meant action
> 2. not even transpilers can solve cases like this (i.e. a still valid
> event eventually stopped after some generator logic where if simulated the
> event would be expired at the time the function will be invoked)
>
> Thanks
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140108/90304980/attachment.html>Calling a generator function just creates a paused generator. Generators
can't pause callers, just themselves (via yield).
On 1/8/2014 1:05 PM, Andrea Giammarchi wrote:
> Sorry, I explained it badly ... let me try again:
>
> what if a DOM event handler uses/creates/invokes inside its function
> body a generator?
>
> Will the event pause until this will be satisfied?
>
> `a.addEventListener('click', function(e){
> if(methodThatInvokesGenerator()) e.stopPropagation(); });`
Calling a generator function just creates a paused generator. Generators
can't pause callers, just themselves (via yield).OK, I have overlooked at this ... so the following code won't have any side effect, correct?
addEventListener('beforeunload', function (e) {
(function*() {
while (true) yield null;
}());
});
OK, I have overlooked at this ... so the following code won't have any side
effect, correct?
```javascript
addEventListener('beforeunload', function (e) {
(function*() {
while (true) yield null;
}());
});
```
Thanks
On Wed, Jan 8, 2014 at 1:12 PM, Brandon Benvie <bbenvie at mozilla.com> wrote:
> On 1/8/2014 1:05 PM, Andrea Giammarchi wrote:
>
>> Sorry, I explained it badly ... let me try again:
>>
>> what if a DOM event handler uses/creates/invokes inside its function body
>> a generator?
>>
>> Will the event pause until this will be satisfied?
>>
>> `a.addEventListener('click', function(e){ if(methodThatInvokesGenerator())
>> e.stopPropagation(); });`
>>
>
> Calling a generator function just creates a paused generator. Generators
> can't pause callers, just themselves (via yield).
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140108/140b19bd/attachment.html>sorry, actually the right example was with while (true) yield evt; but
that's the same of async callback, the event is gone.
Well, everything good then ^_^
Thanks again
sorry, actually the right example was with `while (true) yield evt;` but
that's the same of async callback, the event is gone.
Well, everything good then ^_^
Thanks again
On Wed, Jan 8, 2014 at 1:19 PM, Andrea Giammarchi <
andrea.giammarchi at gmail.com> wrote:
> OK, I have overlooked at this ... so the following code won't have any
> side effect, correct?
>
> ```javascript
> addEventListener('beforeunload', function (e) {
> (function*() {
> while (true) yield null;
> }());
> });
> ```
>
> Thanks
>
>
> On Wed, Jan 8, 2014 at 1:12 PM, Brandon Benvie <bbenvie at mozilla.com>wrote:
>
>> On 1/8/2014 1:05 PM, Andrea Giammarchi wrote:
>>
>>> Sorry, I explained it badly ... let me try again:
>>>
>>> what if a DOM event handler uses/creates/invokes inside its function
>>> body a generator?
>>>
>>> Will the event pause until this will be satisfied?
>>>
>>> `a.addEventListener('click', function(e){ if(methodThatInvokesGenerator())
>>> e.stopPropagation(); });`
>>>
>>
>> Calling a generator function just creates a paused generator. Generators
>> can't pause callers, just themselves (via yield).
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140108/18946e31/attachment-0001.html>'yield' in an HTML event attribute value should be a free variable reference, since the attribute value is taken as the source of a function body, not of a function* body.
'yield' in an HTML event attribute value should be a free variable
reference, since the attribute value is taken as the source of a
function body, not of a function* body.
/be
> Andrea Giammarchi <mailto:andrea.giammarchi at gmail.com>
> January 8, 2014 1:21 PM
> sorry, actually the right example was with `while (true) yield evt;`
> but that's the same of async callback, the event is gone.
>
> Well, everything good then ^_^
>
> Thanks again
>
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
> Andrea Giammarchi <mailto:andrea.giammarchi at gmail.com>
> January 8, 2014 1:19 PM
> OK, I have overlooked at this ... so the following code won't have any
> side effect, correct?
>
> ```javascript
> addEventListener('beforeunload', function (e) {
> (function*() {
> while (true) yield null;
> }());
> });
> ```
>
> Thanks
>
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
> Brandon Benvie <mailto:bbenvie at mozilla.com>
> January 8, 2014 1:12 PM
>
>
> Calling a generator function just creates a paused generator.
> Generators can't pause callers, just themselves (via yield).
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
> Andrea Giammarchi <mailto:andrea.giammarchi at gmail.com>
> January 8, 2014 1:05 PM
> Sorry, I explained it badly ... let me try again:
>
> what if a DOM event handler uses/creates/invokes inside its function
> body a generator?
>
> Will the event pause until this will be satisfied?
>
> `a.addEventListener('click', function(e){
> if(methodThatInvokesGenerator()) e.stopPropagation(); });`
>
> Is this a concern?
>
> Thanks
>
>
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
> Domenic Denicola <mailto:domenic at domenicdenicola.com>
> January 8, 2014 12:53 PM
> What? That would just cause the event handler function to return a
> generator object, which the browser would not use or do anything with.
> It would have no effect.
>
>
> ------------------------------------------------------------------------
> *From:* es-discuss <es-discuss-bounces at mozilla.org> on behalf of
> Andrea Giammarchi <andrea.giammarchi at gmail.com>
> *Sent:* Wednesday, January 08, 2014 15:50
> *To:* es-discuss at mozilla.org
> *Subject:* generators inside DOM events
> I am not sure this has been discussed already but I wonder what would
> happen if `yield` is used inside an event such 'beforeunload',
> 'unload', or even 'click' and others DOM related events.
>
> Main concerns:
>
> 1. it's a UA trap potentially making impossible to leave a page or
> complete a user meant action
> 2. not even transpilers can solve cases like this (i.e. a still valid
> event eventually stopped after some generator logic where if
> simulated the event would be expired at the time the function will
> be invoked)
>
> Thanks
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
I am not sure this has been discussed already but I wonder what would happen if
yieldis used inside an event such 'beforeunload', 'unload', or even 'click' and others DOM related events.Main concerns: