Giter Site home page Giter Site logo

rrweb-snapshot's Introduction

rrweb-snapshot

Build Status Join the chat at https://gitter.im/rrweb-io/rrweb-snapshot

Snapshot the DOM into a stateful and serializable data structure. Also, provide the ability to rebuild the DOM via snapshot.

API

This module export following methods:

snapshot

snapshot will traverse the DOM and return a stateful and serializable data structure which can represent the current DOM view.

There are several things will be done during snapshot:

  1. Inline some DOM states into HTML attributes, e.g, HTMLInputElement's value.
  2. Turn script tags into noscript tags to avoid scripts being executed.
  3. Try to inline stylesheets to make sure local stylesheets can be used.
  4. Make relative paths in href, src, CSS to be absolute paths.
  5. Give an id to each Node, and return the id node map when snapshot finished.

rebuild

rebuild will build the DOM according to the taken snapshot.

There are several things will be done during rebuild:

  1. Add data-rrid attribute if the Node is an Element.
  2. Create some extra DOM node like text node to place inline CSS and some states.
  3. Add data-extra-child-index attribute if Node has some extra child DOM.

serializeNodeWithId

serializeNodeWithId can serialize a node into snapshot format with id.

buildNodeWithSN

buildNodeWithSN will build DOM from serialized node and store serialized information in __sn property.

rrweb-snapshot's People

Contributors

yuyz0112 avatar dvdgiessen avatar imfil avatar benoitzugmeyer avatar eoghanmurray avatar fizerkhan avatar jwbrew avatar mpstv avatar sammdec avatar gitter-badger avatar whalefreezer avatar dphuang2 avatar wuzekang 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.