canjs / can-util

Essential utilities used by lots of CanJS's projects.
https://canjs.com/doc/can-util.html
MIT License
10 stars 8 forks source link

Break out can-util/dom/mutate #283

Open andrejewski opened 7 years ago

andrejewski commented 7 years ago

I'd like to break out can-util/dom/mutate and can-util/dom/mutation-observer into their own package can-dom-mutate which will provide:

By "depending on concerns" I mean to decide if logically these events do in fact belong inside the package instead of their own. Moving forward with implementation, this will become more clear.

As far as structure goes, I'm currently thinking:

Discussion is welcome and I'm happy to address concerns regarding my grand vision.

andrejewski commented 7 years ago

See can-dom-mutate for the API and implementation.

andrejewski commented 7 years ago

The API is:

can-dom-mutate

Note: the optional callback to the dispatch methods are called right after the mutation is actually broadcast (all mutations are batched). This eliminates the need for a hack like afterMutation() in our tests.

Note: all the listener events return remove functions which unbind the listener.

can-dom-mutate/observer

This API provides everything a can-global package would provide, but this is only for the one shared MutationObserver.

can-dom-mutate/node

can-dom-mutate/events/{attributes|inserted|removed}

These are can-dom-events events; they did make sense to include in can-dom-mutate as they all can be derived from a single make-mutation-event generator.