W3C home > Mailing lists > Public > public-webapps-bugzilla@w3.org > August 2012

[Bug 18732] [Custom]: element upgrade algorithm does not preserve attributes, event listeners, references

From: <bugzilla@jessica.w3.org>
Date: Wed, 29 Aug 2012 17:14:03 +0000
Message-Id: <E1T6lq7-0007GG-Iv@jessica.w3.org>
To: public-webapps-bugzilla@w3.org
https://www.w3.org/Bugs/Public/show_bug.cgi?id=18732

--- Comment #3 from Scott Miles <sjmiles@chromium.org> 2012-08-29 17:14:03 UTC ---
My understanding is that, If my document looks like this:

  <x-element important="important"><span>important goodies</span></x-element>

and my code does:

  x = document.querySelector("x-element");
  x.addEventListener("onclick", clickAction);

if the upgrade algorithm runs after the above code, the following effects
occur:

- the original x-element is replaced in DOM
- the new x-element has no onclick
- the new x-element has no 'important' attribute
- x-element's original children are lost (not in DOM)
- the x reference refers to a node that's no longer in DOM

The 'onclick' is lost (the old element is not in DOM, the new element doesn't
have that event). Any attempt to use the x reference to work with DOM will
simply not work (that node is not in DOM). Any query for 'important' x-elements
will not include the new element.

It's true that 'x' still references a node, but I don't see how it's useful.
That node is dangling and really should be GC'd asap.

I believe the alternative Steve mentions is to upgrade the element 'in place'
my modifying it's prototype and performing the rest of the upgrade steps on
this original element. In this case, the attributes, listeners, and references
are intact. This solution is also not ideal because we lose whatever the native
constructor would have done to the replacement element.

In any case, if the upgrade event is migrated to the new object, can't the
event simply be fired on the new object?

-- 
Configure bugmail: https://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
Received on Wednesday, 29 August 2012 17:14:04 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 29 August 2012 17:14:07 GMT