GithubHelp home page GithubHelp logo

swlws / clonenodedeep Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 13 KB

深度 clone Dom 节点,支持对 Web Compoent 的兼容处理(不会造成样式的全局污染)

TypeScript 100.00%
pico web-component dom-to-image html2canvas clone-node-deep gripeless-pico

clonenodedeep's Introduction

cloneNodeDeep

深度 clone Dom 节点,支持对 Web Compoent 的兼容处理(不会造成样式的全局污染)

Goal

目前主流的,将一个HTML页面转化为图片的方式,多利用 svg 的 foreignobject 特性。然后将生成的 svg 序列化后(XMLSerializer),丢到new Image 进行处理。

但存在一个问题,XMLSerializer 会造成 Web Component 的 shadowRoot 丢失

How It Work

遇到 WebComponent 节点时,将其转化为普通的 div 节点,同时为 shadowRoot 下的 style 的样式选择器添加名空间,防止造成全局的样式污染

API

export declare function cloneNodeDeep(node: HTMLElement): Node | null | undefined;

clonenodedeep's People

Contributors

swlws 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.