Giter Club home page Giter Club logo

mutation-observer-applier's Introduction

Mutation Observer Applier

Apply MutationObserver mutations to a DOM.

This library takes mutations consumed by a Mutation Observer and applies them to a DOM successively to get a sequence of DOMs. It is like diff-patch-match, but for DOMs.

How it works

The API consists of a single class, MutationObserverApplier, with two main functions:

  • serializeMutations(mutations: MutationRecord[]): IMutationRecord[]; - serialize a list of mutations emitted by the DOM.
  • applyMutations(serializedMutations: IMutationRecord[]): void; - apply serialized mutations. The resulting DOM is present on this.DOM.

For examples of these two functions in use, please see the tests.

The library is written in typescript and uses the standard Web API types defined in lib.dom.d. For example, MutationRecord is defined here.

How it is used

At Meeshkan, we use this library to create videos of interactions with a DOM. Since it was incorporated into our stack, it has reduced the CPU usage of our recording script by ~70%.

License

MIT © Meeshkan

mutation-observer-applier's People

Contributors

k4m4 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.