Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@wildpeaks/snapshot-dom

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wildpeaks/snapshot-dom - npm Package Compare versions

Comparing version 1.4.0 to 1.5.0

54

package.json
{
"name": "@wildpeaks/snapshot-dom",
"version": "1.4.0",
"version": "1.5.0",
"description": "Converts a DOM element to a JSON tree",
"author": "Cecile Muller",
"license": "MIT",
"keywords": [
"wildpeaks",
"assert",
"dom"
],
"homepage": "https://github.com/wildpeaks/package-snapshot-dom#readme",
"repository": "https://github.com/wildpeaks/package-snapshot-dom",
"bugs": {
"url": "https://github.com/wildpeaks/package-snapshot-dom/issues"
},
"eslintConfig": {
"extends": "@wildpeaks/commonjs"
},
"prettier": {
"printWidth": 120,
"tabWidth": 4,
"useTabs": true,
"bracketSpacing": false
},
"greenkeeper": {
"commitMessages": {
"dependencyUpdate": "feat: update ${dependency}",
"devDependencyUpdate": "chore: update ${dependency}"
}
},
"main": "src/snapshot.js",
"files": [
"src/snapshot.js",
"test/snapshot.tests.js"
"src"
],
"scripts": {
"test:lint": "eslint ./src/**/*.js",
"test:specs": "mocha",
"test": "npm run test:lint && npm run test:specs"
"lint": "eslint ./src/**/*.js",
"test": "mocha test/*.spec.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/wildpeaks/package-snapshot-dom.git"
},
"keywords": [
"wildpeaks",
"assert",
"dom"
],
"bugs": {
"url": "https://github.com/wildpeaks/package-snapshot-dom/issues"
},
"homepage": "https://github.com/wildpeaks/package-snapshot-dom#readme",
"devDependencies": {
"@wildpeaks/eslint-config-commonjs": "6.2.0",
"eslint": "6.1.0",
"jsdom": "15.1.1",
"mocha": "6.2.0"
"@wildpeaks/eslint-config-commonjs": "8.0.0",
"eslint": "6.8.0",
"jsdom": "15.2.1",
"mocha": "6.2.2",
"prettier": "1.19.1"
}
}
# Snapshot
[![Greenkeeper badge](https://badges.greenkeeper.io/wildpeaks/package-snapshot-dom.svg)](https://greenkeeper.io/)
Converts an HTMLElement to a JSON tree, useful for automated DOM tests.

@@ -4,0 +6,0 @@

@@ -1,4 +0,3 @@

'use strict';
"use strict";
/**

@@ -10,14 +9,14 @@ * Convert a DOM element to a simpler JSON tree.

*/
function toJSON(node, skipEmpty){
function toJSON(node, skipEmpty) {
const serialized = {};
const isValid = (typeof node === 'object') && (node !== null);
if (isValid){
const isValid = typeof node === "object" && node !== null;
if (isValid) {
// https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType#Node_type_constants
// serialized.nodeType = node.nodeType;
if (node.tagName){
if (node.tagName) {
serialized.tagName = node.tagName.toLowerCase();
} else if (node.nodeName){
} else if (node.nodeName) {
serialized.nodeName = node.nodeName;
}
if (node.nodeValue){
if (node.nodeValue) {
serialized.nodeValue = node.nodeValue;

@@ -27,10 +26,10 @@ }

const attrs = node.attributes;
if (attrs){
if (attrs) {
const l = attrs.length;
if (l > 0){
if (l > 0) {
const aggregated = {};
for (let i = 0; i < l; i++){
for (let i = 0; i < l; i++) {
const attr = attrs[i];
const skip = skipEmpty && !attr.nodeValue;
if (!skip){
if (!skip) {
aggregated[attr.nodeName] = attr.nodeValue;

@@ -44,7 +43,7 @@ }

const {childNodes} = node;
if (childNodes){
if (childNodes) {
const l = childNodes.length;
if (l > 0){
if (l > 0) {
const aggregated = new Array(l);
for (let i = 0; i < l; i++){
for (let i = 0; i < l; i++) {
aggregated[i] = toJSON(childNodes[i], skipEmpty);

@@ -59,4 +58,2 @@ }

module.exports.toJSON = toJSON;
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc