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 20490 - [Custom]: Things that mutate the DOM tree should queue observer records
Summary: [Custom]: Things that mutate the DOM tree should queue observer records
Status: RESOLVED DUPLICATE of bug 21063
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: 17103 20684
  Show dependency treegraph
 
Reported: 2012-12-22 00:36 UTC by Boris Zbarsky
Modified: 2013-02-20 19:04 UTC (History)
2 users (show)

See Also:


Attachments

Description Boris Zbarsky 2012-12-22 00:36:43 UTC
"The element upgrade algorithm must not queue any observer records. "

This isn't a reasonable requirement, because it makes mutation observers unreliable.  The requirement should in fact be the other way: any DOM mutations MUST queue observer records.
Comment 1 Dimitri Glazkov 2013-01-16 17:52:17 UTC
There's been a similar discussion on bug 20397, starting with comment https://www.w3.org/Bugs/Public/show_bug.cgi?id=20397#c7
Comment 2 Dimitri Glazkov 2013-01-16 18:24:58 UTC
I honestly just hate the whole http://parkour.mtv/webcomponents/spec/custom/index.html#dfn-element-upgrade, because it's very disruptive and unintuitive to a developer. Even less intuitive if we don't suppress mutation observers. "WTF just happened? I didn't do that!" would be a very common reaction to capturing some of those records.

I wonder if the www-dom discussion (http://lists.w3.org/Archives/Public/www-dom/2013JanMar/0075.html) will result in a specified behavior where a wrapper is exchanged for another one. Maybe we could piggyback to that behavior and swap wrappers (well, and prototypes in this case) instead doing a whole-hog renameNode?
Comment 3 Olli Pettay 2013-01-16 18:34:28 UTC
MutationObservers must be reliable. One needs to be able to detect
all the changes to DOM just using an observer so that the current state of DOM
can be inspected using MutationRecords.
Otherwise the whole MutationObserver API is rather useless.
Comment 4 Boris Zbarsky 2013-01-16 18:37:47 UTC
Switching wrappers won't change your localName, right?  Does the current upgrade stuff do that?  The text at https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/custom/index.html#dfn-custom-element-instantiation is completely silent on the question of what the actual DOM node created is like (e.g. its namespace, localName, attributes, etc, etc)...

(As a side note, the first link in comment 2 is to some private network, looks like.)
Comment 5 Dimitri Glazkov 2013-01-16 18:46:28 UTC
(In reply to comment #4)
> Switching wrappers won't change your localName, right?  Does the current
> upgrade stuff do that?  The text at
> https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/custom/index.html#dfn-
> custom-element-instantiation is completely silent on the question of what
> the actual DOM node created is like (e.g. its namespace, localName,
> attributes, etc, etc)...

They will have identical localName. I need to firm the spec up on that (as you pointed out in bug 20489), but that's the intent.

And the algo does copy all of the attributes.

> 
> (As a side note, the first link in comment 2 is to some private network,
> looks like.)

Haha. That's my machine, sorry :)
Comment 6 Dimitri Glazkov 2013-01-16 18:48:44 UTC
(In reply to comment #3)
> MutationObservers must be reliable. One needs to be able to detect
> all the changes to DOM just using an observer so that the current state of
> DOM
> can be inspected using MutationRecords.
> Otherwise the whole MutationObserver API is rather useless.

The thing is, element upgrade is not something I _want_ the author to observe,   the whole point of the operation is to substitute one DOM node for another with as few side effects as possible.

That's why just switching wrappers seems better.
Comment 7 Olli Pettay 2013-01-16 19:01:27 UTC
I don't quite understand how wrapper switching would help.
well, I'm not sure what you mean with wrapper switching.
Just
tmp = NodeA->JSWrapper;
NodeA->JSWrapper = NodeB->JSWrapper;
NodeB->JSWrapper = tmp;
?
Comment 8 Dimitri Glazkov 2013-02-20 19:04:18 UTC
Pouring this over to bug 21063.

*** This bug has been marked as a duplicate of bug 21063 ***