This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 22966 - [Custom]: Don't invoke callbacks while the createdCallback is running
Summary: [Custom]: Don't invoke callbacks while the createdCallback is running
Status: RESOLVED FIXED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: HISTORICAL - Component Model (show other bugs)
Version: unspecified
Hardware: PC Linux
: P2 normal
Target Milestone: ---
Assignee: Dimitri Glazkov
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 14968
  Show dependency treegraph
 
Reported: 2013-08-15 02:47 UTC by Dominic Cooney
Modified: 2013-08-26 21:58 UTC (History)
1 user (show)

See Also:


Attachments

Description Dominic Cooney 2013-08-15 02:47:10 UTC
The rationale is that the createdCallback is like a constructor and should run to completion before callbacks start firing.

However the callbacks should still be queued (not dropped) while the createdCallback is running, because that is past the point where the prototype has been updated.

For example:

proto.createdCallback = function() {
  console.log('created start');
  this.remove();
  this.setAttribute('foo', 'bar');
  console.log('created end');
};
... (other callbacks which log) ...

should log

created start
created end
entered
left
attribute changed

Maybe the relationship between enqueuing a callback in a callback queue, and moving the callback queue to the top-of-processing stack element queue needs to change. Maybe the spec should model this with an explicit flag (
("created-callback-ran"). If the flag is not set when enqueuing a callback (other than the created callback and the special-case first entered callback), then the callback queue should not be moved to the top-of-processing-stack. (Of course no callbacks are queued until the created callback has started running, as usual.)
Comment 1 Scott Miles 2013-08-15 04:22:37 UTC
Thank you for taking this on. You are appreciated for working on rationalizing some of these feature requests!

Seems better to achieve by changing the nature of the queue relationships and not with a flag, but that's just $0.02 worth.
Comment 2 Dimitri Glazkov 2013-08-15 15:20:18 UTC
Ok. I've been trying to think of a solution that doesn't involve special treatment of the created callback, but haven't come up with one.
Comment 3 Dominic Cooney 2013-08-16 01:54:31 UTC
FWIW Blink implements it this way now, we can get feedback from developers. Anecdotally, the developer of Chrome apps' <webview> thought this was an improvement.
Comment 4 Dimitri Glazkov 2013-08-26 18:51:39 UTC
Also (from bug 22991):

> - With the exception of the created callback and the magic entered callback,
> callbacks should not be queued until the created callback starts to run.
Comment 5 Dimitri Glazkov 2013-08-26 21:58:23 UTC
(In reply to comment #4)
> Also (from bug 22991):
> 
> > - With the exception of the created callback and the magic entered callback,
> > callbacks should not be queued until the created callback starts to run.

https://dvcs.w3.org/hg/webcomponents/rev/348757462b1f
Comment 6 Dimitri Glazkov 2013-08-26 21:58:31 UTC
https://dvcs.w3.org/hg/webcomponents/rev/4f25aa1b9a4b