fgnass / domino

Server-side DOM implementation based on Mozilla's dom.js
BSD 2-Clause "Simplified" License
767 stars 120 forks source link

MutationObserver #80

Open pimterry opened 8 years ago

pimterry commented 8 years ago

Any enthusiasm for adding support for MutationObserver? In the Living Standard, part of the full W3C Recommendation for DOM4, and implemented in almost every browser already.

Also, I'd find pretty useful.

I'd be happy to help out and try to work on this myself, but I haven't dug into the Domino source much, so some pointers in the right direction (assuming you'd be happy to include this) would be helpful.

cscott commented 8 years ago

I certainly wouldn't object to its implementation! I'm unlikely to tackle this myself, simply because none of the projects I'm responsible for (primarily Parsoid) would use it. But it should be straightforward. The first step would be just to mechanically include the proper APIs, then you could actually hook it up to the node mutation mechanics in a second step. I suspect most of the node mutation happens in methods of Node, so it should be pretty obvious where to add new code.

Finding a good test suite would be key to ensure we actually are firing all the right events and not missing corner cases. Having 90% complete functionality could be worse than not having it at all for some users, as code with feature tests would break. Does the official W3C test suite cover this? It would also be good to ensure that third-party libraries like MutationSummary work correctly with domino's implementation. Hopefully we could plumb those two things into domino's test harness to convince ourselves that our implementation was sound.

pimterry commented 8 years ago

Awesome, good to hear. I'll look at tackling this sometime soon.

MurhafSousli commented 7 years ago

Hey guys, any updates on this?

pimterry commented 6 years ago

@MurhafSousli I'm no longer working on it, it stopped being relevant to me, but feel free to take a look yourself.

The first step was getting the relevant web platform tests working - the work to get those tests usefully running in general is now there, but I think with most of them ignored because they fail. If you want to look at this the next step is to get the mutation observer tests working (and sensibly failing) and then to find a nice way to add a polyfill that makes them actually pass. The polyfill bit shouldn't be too hard in principle, there's existing polyfills for MutationObserver, it's just a matter of working out how to integrate them.

There's some unmerged work on getting tests that need to load resources (other scripts etc I think) at https://github.com/fgnass/domino/compare/master...pimterry:load-resources-in-tests, which I think was part of getting the rest of the tests working, so might be helpful. It's been a long time though, so I can't tell you a lot more about the status of that.

pimterry commented 6 years ago

The details in this commit particularly may be of interest: https://github.com/fgnass/domino/commit/c6f89d0cb4782653757a18cb48fa583dafc74cef