Socket
Socket
Sign inDemoInstall

@emotion/snapshot-serializer

Package Overview
Dependencies
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@emotion/snapshot-serializer - npm Package Compare versions

Comparing version 0.6.3 to 0.6.4

70

dist/index.cjs.js

@@ -10,16 +10,12 @@ 'use strict';

function _ref(child) {
return getNodes(child, nodes);
}
if (node.children) {
node.children.forEach(_ref);
node.children.forEach(function (child) {
return getNodes(child, nodes);
});
}
function _ref2(child) {
return getNodes(child, nodes);
}
if (Array.isArray(node)) {
node.forEach(_ref2);
node.forEach(function (child) {
return getNodes(child, nodes);
});
} else if (typeof node === 'object') {

@@ -32,8 +28,6 @@ nodes.push(node);

function _ref3(node) {
node.withNewStyles = true;
}
function markNodes(nodes) {
nodes.forEach(_ref3);
nodes.forEach(function (node) {
node.withNewStyles = true;
});
}

@@ -61,17 +55,22 @@

var classMap = {};
nodes.forEach(function (node) {
if (node.type !== 'style') return;
var dataKey;
Object.keys(node.props).forEach(function (key) {
if (key.indexOf('data-emotion-') === 0) {
dataKey = key;
}
});
function _ref4(match, p1) {
if (classMap[p1] === undefined) {
classMap[p1] = "emotion-" + i++;
}
if (typeof node.props[dataKey] === 'string') {
try {
var replaced = node.props.dangerouslySetInnerHTML.__html.replace(clsPattern, function (match, p1) {
if (classMap[p1] === undefined) {
classMap[p1] = "emotion-" + i++;
}
return classMap[p1];
}
return classMap[p1];
}); // split the string by line to get correct indentation
nodes.forEach(function (node) {
if (typeof node.props['data-emotion-ssr'] === 'string') {
try {
var replaced = node.props.dangerouslySetInnerHTML.__html.replace(clsPattern, _ref4); // split the string by line to get correct indentation
node.children = css.stringify(css.parse(replaced)).split('\n');

@@ -82,18 +81,15 @@ } catch (e) {

delete node.props['data-emotion-ssr'];
delete node.props[dataKey];
delete node.props.dangerouslySetInnerHTML;
}
});
function _ref5(match, p1) {
if (classMap[p1] !== undefined) {
return classMap[p1];
}
return match;
}
nodes.forEach(function (node) {
if (typeof node.props.className === 'string') {
node.props.className = node.props.className.replace(clsPattern, _ref5);
node.props.className = node.props.className.replace(clsPattern, function (match, p1) {
if (classMap[p1] !== undefined) {
return classMap[p1];
}
return match;
});
}

@@ -100,0 +96,0 @@ });

@@ -8,16 +8,12 @@ import { parse, stringify } from 'css';

function _ref(child) {
return getNodes(child, nodes);
}
if (node.children) {
node.children.forEach(_ref);
node.children.forEach(function (child) {
return getNodes(child, nodes);
});
}
function _ref2(child) {
return getNodes(child, nodes);
}
if (Array.isArray(node)) {
node.forEach(_ref2);
node.forEach(function (child) {
return getNodes(child, nodes);
});
} else if (typeof node === 'object') {

@@ -30,8 +26,6 @@ nodes.push(node);

function _ref3(node) {
node.withNewStyles = true;
}
function markNodes(nodes) {
nodes.forEach(_ref3);
nodes.forEach(function (node) {
node.withNewStyles = true;
});
}

@@ -59,17 +53,22 @@

var classMap = {};
nodes.forEach(function (node) {
if (node.type !== 'style') return;
var dataKey;
Object.keys(node.props).forEach(function (key) {
if (key.indexOf('data-emotion-') === 0) {
dataKey = key;
}
});
function _ref4(match, p1) {
if (classMap[p1] === undefined) {
classMap[p1] = "emotion-" + i++;
}
if (typeof node.props[dataKey] === 'string') {
try {
var replaced = node.props.dangerouslySetInnerHTML.__html.replace(clsPattern, function (match, p1) {
if (classMap[p1] === undefined) {
classMap[p1] = "emotion-" + i++;
}
return classMap[p1];
}
return classMap[p1];
}); // split the string by line to get correct indentation
nodes.forEach(function (node) {
if (typeof node.props['data-emotion-ssr'] === 'string') {
try {
var replaced = node.props.dangerouslySetInnerHTML.__html.replace(clsPattern, _ref4); // split the string by line to get correct indentation
node.children = stringify(parse(replaced)).split('\n');

@@ -80,18 +79,15 @@ } catch (e) {

delete node.props['data-emotion-ssr'];
delete node.props[dataKey];
delete node.props.dangerouslySetInnerHTML;
}
});
function _ref5(match, p1) {
if (classMap[p1] !== undefined) {
return classMap[p1];
}
return match;
}
nodes.forEach(function (node) {
if (typeof node.props.className === 'string') {
node.props.className = node.props.className.replace(clsPattern, _ref5);
node.props.className = node.props.className.replace(clsPattern, function (match, p1) {
if (classMap[p1] !== undefined) {
return classMap[p1];
}
return match;
});
}

@@ -98,0 +94,0 @@ });

{
"name": "@emotion/snapshot-serializer",
"version": "0.6.3",
"version": "0.6.4",
"description": "A snapshot serializer for jest and emotion",

@@ -5,0 +5,0 @@ "main": "dist/index.cjs.js",

@@ -50,3 +50,10 @@ // @flow

nodes.forEach(node => {
if (typeof node.props['data-emotion-ssr'] === 'string') {
if (node.type !== 'style') return
let dataKey
Object.keys(node.props).forEach(key => {
if (key.indexOf('data-emotion-') === 0) {
dataKey = key
}
})
if (typeof node.props[dataKey] === 'string') {
try {

@@ -70,3 +77,3 @@ const replaced = node.props.dangerouslySetInnerHTML.__html.replace(

delete node.props['data-emotion-ssr']
delete node.props[dataKey]
delete node.props.dangerouslySetInnerHTML

@@ -73,0 +80,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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