Socket
Socket
Sign inDemoInstall

@wildpeaks/snapshot-dom

Package Overview
Dependencies
0
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.6.0 to 2.0.0-rc1

6

lib/browser.js
/* eslint-env browser */
"use strict";
(function() {
function snapshotToJson(node, skipEmpty) {
function snapshotToJson(node, options = {}) {
const serialized = {};

@@ -24,3 +24,3 @@ const isValid = typeof node === "object" && node !== null;

const attr = attrs[i];
const skip = skipEmpty && !attr.nodeValue;
const skip = options.skipEmptyValue && !attr.nodeValue;
if (!skip) {

@@ -40,3 +40,3 @@ aggregated[attr.nodeName] = attr.nodeValue;

for (let i = 0; i < l; i++) {
aggregated[i] = snapshotToJson(childNodes[i], skipEmpty);
aggregated[i] = snapshotToJson(childNodes[i], options);
}

@@ -43,0 +43,0 @@ serialized.childNodes = aggregated;

{
"name": "@wildpeaks/snapshot-dom",
"version": "1.6.0",
"version": "2.0.0-rc1",
"description": "Converts a DOM element to a JSON tree",

@@ -42,10 +42,10 @@ "author": "Cecile Muller",

"devDependencies": {
"@wildpeaks/eslint-config-commonjs": "8.0.0",
"@wildpeaks/eslint-config-commonjs": "8.1.0",
"eslint": "6.8.0",
"express": "4.17.1",
"jsdom": "15.2.1",
"mocha": "6.2.2",
"jsdom": "16.1.0",
"mocha": "7.0.1",
"prettier": "1.19.1",
"puppeteer": "2.0.0"
"puppeteer": "2.1.1"
}
}

@@ -60,3 +60,3 @@ # Snapshot

assert.deepStrictEqual(
snapshot.toJSON(document.body, false),
snapshot.toJSON(document.body, {skipEmptyValue: false}),
{

@@ -79,3 +79,3 @@ tagName: 'body',

assert.deepStrictEqual(
snapshot.toJSON(document.body, true),
snapshot.toJSON(document.body, {skipEmptyValue: true}),
{

@@ -95,3 +95,3 @@ tagName: 'body',

Note that strings containing only whitespace are not empty.
Note that strings containing only whitespace characters are not empty values.
"use strict";
/**
* @typedef {Object} Options
* @property {Boolean} skipEmptyValue - Skips node values that evaluate to false (undefined and zero-length strings)
*/
/**
* Convert a DOM element to a simpler JSON tree.
* @param {Node} node
* @param {Boolean} skipEmpty Skips node values that evaluate to false (undefined and empty strings)
* @param {Options} options
* @return {Object}
*/
function toJSON(node, skipEmpty) {
function toJSON(node, options = {}) {
const serialized = {};

@@ -31,3 +36,3 @@ const isValid = typeof node === "object" && node !== null;

const attr = attrs[i];
const skip = skipEmpty && !attr.nodeValue;
const skip = options.skipEmptyValue && !attr.nodeValue;
if (!skip) {

@@ -47,3 +52,3 @@ aggregated[attr.nodeName] = attr.nodeValue;

for (let i = 0; i < l; i++) {
aggregated[i] = toJSON(childNodes[i], skipEmpty);
aggregated[i] = toJSON(childNodes[i], options);
}

@@ -50,0 +55,0 @@ serialized.childNodes = aggregated;

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