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

@crystallize/content-chunk

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@crystallize/content-chunk - npm Package Compare versions

Comparing version 0.5.4 to 0.5.5

7

CHANGELOG.md

@@ -0,1 +1,8 @@

<a name="0.5.5"></a>
## <small>0.5.5 (2018-05-30)</small>
* Small tweak to not allow empty inline elements as children of certain elements ([2eae4ca](https://github.com/snowballdigital/crystallize-content-chunk/commit/2eae4ca))
<a name="0.5.4"></a>

@@ -2,0 +9,0 @@ ## <small>0.5.4 (2018-05-30)</small>

7

develop.js
const { fromHTML } = require('./src');
console.log(
fromHTML(`
<p>sasd</p>
<p>asd</p>@
`)
);
console.log(fromHTML(`<p>hello <i>you</i> <i>dude</i></p>`));
{
"name": "@crystallize/content-chunk",
"version": "0.5.4",
"version": "0.5.5",
"description": "Validation and parsing for CCC",

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

@@ -56,2 +56,19 @@ const parse5 = require('parse5');

const nodeTypesThatCannotHaveDirectTextChildren = 'ul ol table thead tbody tfoot tr th td img'.split(
' '
);
function nodeHasContent(node) {
if (node.nodeName === '#text') {
if (
nodeTypesThatCannotHaveDirectTextChildren.includes(
node.parentNode.nodeName
)
) {
return false;
}
}
return true;
}
function chunkHasContent(chunk) {

@@ -94,2 +111,3 @@ // Empty, inline chunks

chunk.children = Array.from(node.childNodes)
.filter(nodeHasContent)
.map(parseChunk)

@@ -96,0 +114,0 @@ .filter(chunkHasContent);

Sorry, the diff of this file is too big to display

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