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 19763 - [Custom]: Consider copying event listeners when upgrading elements
Summary: [Custom]: Consider copying event listeners when upgrading elements
Status: RESOLVED WONTFIX
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: 18511
  Show dependency treegraph
 
Reported: 2012-10-29 21:28 UTC by Dimitri Glazkov
Modified: 2013-05-29 19:22 UTC (History)
3 users (show)

See Also:


Attachments

Description Dimitri Glazkov 2012-10-29 21:28:50 UTC
Split off of bug 18732.
Comment 1 Daniel Buchner 2012-10-29 22:45:24 UTC
I would be against copying event listeners for a few reasons, here's why:



- there are a number of things set by user JS after the page is parsed that cloning a node does not copy, to only do a subset would be confusing.

- by copying event listeners, which will likely contain calls to the custom element's unique prototype methods, we create a situation where events may be able to be invoked by the interface end-user *before the element it upgraded*. This means that the refs to anything custom about the element would fail. It is better to say to the developer "assign all user-defined JS events not part of the component's operation itself, inside of the upgrade event (as opposed to DOMContentLoaded,Load, etc)"

- I cannot be sure of this, but I would bet performance would be impacted negatively if we allowed this (though I am unsure to what extent)

Bottom Line: push developers to do all such operations within the upgrade event loop, it is a more cohesive and expected position than hopscotching on what we will copy and what we won't (child elements and originally-specified HTML source attributes withstanding, for obvious reasons)
Comment 2 Olli Pettay 2012-10-30 08:45:43 UTC
I'm also against automatic copying.

onfoo="" handlers will be copied anyway, and
other listeners may easily keep the old element alive if not being
careful with js scopes etc.
Comment 3 Dimitri Glazkov 2013-05-29 19:22:13 UTC
We took a different approach. There's no more cloning/replacing, just switching out the prototype.