Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Should MutationObserver ensure HTML file nodes are run through it before they're injected in DOM?

37 views
Skip to first unread message

Zibi Braniecki

unread,
Apr 18, 2014, 6:29:17 PM4/18/14
to
I'm trying to use MutationObserver to do runtime localization of the nodes that are provided by an HTML file.

I register the mutation observer on document at it's readyState=loading and in result all nodes that are in HTML files are reported to my callback. That's cool.

Now, usually, firstPaint happen after this, so if I translate those nodes, all I see on firstPaint is a stable screen with properly translated nodes.

The order seems to be:

1) observer registered
2) nodes injected into DOM
3) observer's callback translates the nodes
4) firstPaint

But when I test this on a slow device (Keon) and on a rather complex app (Settings), every now and then I see a flash of untranslated content before the nodes are being translated by the mutation observer's callback.

It just seems that in those cases the order is:

1) observer registered
2) nodes injected into DOM
3) firstPaint
4) obsever's callback translates the nodes

Question: should mutationobserver's callback be run on those nodes before firstPaint?

Or

Question 2: should mutationobserver's callback be run on those nodes before they are injected into DOM?

Thanks,
zb.

Jonas Sicking

unread,
Apr 18, 2014, 8:55:45 PM4/18/14
to Zibi Braniecki, dev-platform
On Fri, Apr 18, 2014 at 3:29 PM, Zibi Braniecki
<zbigniew....@gmail.com> wrote:

> Question: should mutationobserver's callback be run on those nodes before firstPaint?

Yes

> Question 2: should mutationobserver's callback be run on those nodes before they are injected into DOM?

No. That would require them to fire synchronously and bring back a lot
of the problems that we had (and still have) with MutationEvents.

/ Jonas
0 new messages