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 18533 - [Custom]: When to fire upgrade events
Summary: [Custom]: When to fire upgrade events
Status: RESOLVED FIXED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: HISTORICAL - Component Model (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Dimitri Glazkov
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 18720
  Show dependency treegraph
 
Reported: 2012-08-10 22:57 UTC by Dimitri Glazkov
Modified: 2012-08-28 20:08 UTC (History)
2 users (show)

See Also:


Attachments

Description Dimitri Glazkov 2012-08-10 22:57:09 UTC
When an element definition is upgraded, should we fire an event for:

a) each specific instance upgrade -- seems like too much
b) when upgrade of all elements to a specific definition is complete
c) when all upgrades of all known definitions are complete?
Comment 1 Dimitri Glazkov 2012-08-10 23:23:35 UTC
From sorvell@:

What about doing it like the - o so cool - mutation observers?

You get a single event containing a list of upgraded component definitions. Then perhaps if we end up supporting lazy loading component definitions, you'd get the same event with the new list of upgraded components.
Comment 2 Dominic Cooney 2012-08-13 03:31:02 UTC
(In reply to comment #0)
> When an element definition is upgraded, should we fire an event for:
> 
> a) each specific instance upgrade -- seems like too much

In theory the component itself could provide hooks in its constructor to provide a callback, or dispatch a custom event on itself.

> b) when upgrade of all elements to a specific definition is complete

I can’t really think of the use case for this. When would you want to do this?

> c) when all upgrades of all known definitions are complete?

This would be useful because at that point you can detect errors, if any elements you expected to be upgraded have not been upgraded. Does it make sense to expose a nodelist of elements needing upgrade?

(In reply to comment #1)
> From sorvell@:
> 
> What about doing it like the - o so cool - mutation observers?
> 
> You get a single event containing a list of upgraded component definitions.
> Then perhaps if we end up supporting lazy loading component definitions, you'd
> get the same event with the new list of upgraded components.

I think the crucial datum in the proposed event is relating the old element with the upgraded replacement. So I think one of the mutations (removal or insertion) would need an extra property indicating the replacement/replaced element.

I think a new kind of mutation isn’t desirable because it would be nice if something using Mutation Observers to look for any kind of change doesn’t need to map an "upgrade" mutation to a removal and insertion.
Comment 3 Dimitri Glazkov 2012-08-28 19:51:53 UTC
(In reply to comment #2)

> > b) when upgrade of all elements to a specific definition is complete
> 
> I can’t really think of the use case for this. When would you want to do this?

To know when you can use an element of this type.

> 
> > c) when all upgrades of all known definitions are complete?
> 
> This would be useful because at that point you can detect errors, if any
> elements you expected to be upgraded have not been upgraded. Does it make sense
> to expose a nodelist of elements needing upgrade?

To detect errors, hook b to track each definition, then look in c to ensure all are good. Right?

> 
> (In reply to comment #1)
> > From sorvell@:
> > 
> > What about doing it like the - o so cool - mutation observers?
> > 
> > You get a single event containing a list of upgraded component definitions.
> > Then perhaps if we end up supporting lazy loading component definitions, you'd
> > get the same event with the new list of upgraded components.
> 
> I think the crucial datum in the proposed event is relating the old element
> with the upgraded replacement. So I think one of the mutations (removal or
> insertion) would need an extra property indicating the replacement/replaced
> element.
> 
> I think a new kind of mutation isn’t desirable because it would be nice if
> something using Mutation Observers to look for any kind of change doesn’t need
> to map an "upgrade" mutation to a removal and insertion.

it sounds like you're saying "is" desirable, not "isn't". Can you explain this a bit more?

For now, I am just wiring two simple events for b and c. We can revisit when we have actual stuff to play with in Mozilla and WebKit.
Comment 4 Dimitri Glazkov 2012-08-28 20:08:42 UTC
Filed bug 18721 to track c. B is already spec'd as elementupgrade event.