DOMSubtreeModified event in dart:html

80 views
Skip to first unread message

Peter Ahé

unread,
May 3, 2012, 9:11:22 AM5/3/12
to General Dart Discussion
Hi,

I have some code like this:

#import('dart:html', prefix: 'html');

...

update(_) {
print('hello');
}
final code = html.document.query('#code');
code.$dom_addEventListener('DOMSubtreeModified', update);

This works. This doesn't:

code.on['DOMSubtreeModified'].add(update);

What am I doing wrong?

Cheers,
Peter

Peter Ahé

unread,
May 7, 2012, 1:57:37 AM5/7/12
to General Dart Discussion
I discovered that this event is deprecated according to MDN. So I'll have to do something else. Even if the event wasn't deprecated, I'm not sure this event can be used for was what I need.

Regardless, I'm still puzzled why the two versions aren't equivalent. 

Cheers,
Peter

Seth Ladd

unread,
May 7, 2012, 11:13:49 AM5/7/12
to Peter Ahé, General Dart Discussion
Hi Peter,

Not sure what you're specifically trying to do, but you might be interested in the new Mutation Observers (intended to replace the old mutation events) https://developer.mozilla.org/en/DOM/DOM_Mutation_Observers

Seth

Peter Ahé

unread,
May 7, 2012, 11:25:20 AM5/7/12
to Seth Ladd, General Dart Discussion
Hi Seth,

I'm playing around with content-editable. Which is also broken, I hear.

I want something like codemirror, but less hacky. I'll probably fail miserably, but at least I get to play around with dart:html. 

DOMSubtreeModified isn't really what I need, it just allowed me to prototype something. See samples/leap.

I'm still puzzled that the two versions aren't equivalent. 

Cheers,
Peter

Vijay Menon

unread,
May 7, 2012, 11:32:10 AM5/7/12
to Peter Ahé, Seth Ladd, General Dart Discussion, Jacob Richman
[+jacobr]

Peter,

It should work.  Can you file a bug?

The toLowerCase in _EventsImpl looks suspicious to me:

_EventListenerListImpl operator [](String type) => _get(type.toLowerCase());

Cheers,

Vijay

Peter Ahé

unread,
May 7, 2012, 11:45:35 AM5/7/12
to Vijay Menon, Seth Ladd, General Dart Discussion, Jacob Richman
Thank you, Vijay!

I'll file a bug when I'm at a desktop computer. 

Cheers,
Peter

Jacob Richman

unread,
May 7, 2012, 12:52:50 PM5/7/12
to Peter Ahé, Vijay Menon, Seth Ladd, General Dart Discussion
The type.toLowerCase() call is causing the problem. We have it so that we can use camel case event names (e.g. foo.on.mouseMove instead of foo.on.mousemove).  
We should revisit whether that is a big enough benefit to justify the pain it causes.  There are plenty of ways around this bug but they seem a bit ugly.

-Jacob

Peter Ahé

unread,
May 8, 2012, 6:53:30 AM5/8/12
to Jacob Richman, Vijay Menon, Seth Ladd, General Dart Discussion
Thank you. I filed http://code.google.com/p/dart/issues/detail?id=2937
with a small self-contained example to reproduce the problem.

Cheers,
Peter
Reply all
Reply to author
Forward
0 new messages