Socket
Socket
Sign inDemoInstall

lesca-dom2json

Package Overview
Dependencies
1
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    lesca-dom2json

convert DOM element to JSON format.


Version published
Weekly downloads
0
Maintainers
1
Created
Weekly downloads
 

Readme

Source

dev by JamesHsu made in Taiwan

Installation

$ npm install lesca-dom2json --save

Usage

convert DOM element to JSON before react-dom render;

in html

type A

<div class="app">
	<!--- { title:"Lorem Ipsum is simply" } -->

	<div class="title">Lorem Ipsum is simply</div>
</div>
<script src="./boundle.js"></script>

type B

<div class="app">
	<!-- { img:'./img/1/png' } -->

	<div class="img">
		<img src="./img/1/png" />
	</div>
</div>
<script src="./boundle.js"></script>

type C

<div class="app">
	<!-- { img_link:[ { url:'https://www.asus-buy.com', img:'./update/img0.jpg' }, ... ]} -->

	<div class="img_link">
		<a href="https://www.asus-buy.com">
			<img src="./update/img0.jpg" />
		</a>
		<a href="https://www.asus.com">
			<img src="./update/img1.jpg" />
		</a>
	</div>
</div>
<script src="./boundle.js"></script>

type D

<div class="app">
	<!--- { list:[ 'Lorem Ipsum...', ... ] }  -->
	<div class="list">
		<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>
		<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>
		<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>
		<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>
	</div>
</div>
<script src="./boundle.js"></script>

type E

<div class="app">
	<!-- { "buy-now": [ { name:'www.liverpool.com', url:'#liverpool' } , ... ] } -->

	<div class="buy-now">
		<a href="#liverpool">www.liverpool.com</a>
		<a href="#momoshop">momoshop</a>
		<a href="#pchome">pchome</a>
		<a href="#Costco">Costco</a>
		<a href="#pchome">pchome</a>
		<a href="#Costco">Costco</a>
	</div>
</div>
<script src="./boundle.js"></script>

in react

import React from 'react';
import ReactDOM from 'react-dom';
import Apps from './app.js';
import Dom2json from 'lesca-dom2json';

const data = Dom2Json(document.querySelector('.app'));
ReactDOM.render(<Apps data='{data}' />, document.querySelector('.app'));

Keywords

FAQs

Last updated on 29 Dec 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc