New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ultrahtml

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ultrahtml - npm Package Compare versions

Comparing version 0.0.5 to 0.1.0

6

CHANGELOG.md
# ultrahtml
## 0.1.0
### Minor Changes
- 517e24d: Fix edge cases with text node detection, refactor for compactness
## 0.0.5

@@ -4,0 +10,0 @@

42

dist/index.js

@@ -26,3 +26,3 @@ "use strict";

let str = typeof input === "string" ? input : input.value;
let doc, parent, prev, token, text, i, bStart, bText, bEnd, tag;
let doc, parent, token, text, i, bStart, bText, bEnd, tag;
const tags = [];

@@ -34,16 +34,11 @@ DOM_PARSER_RE.lastIndex = 0;

};
let lastIndex = 0;
function commitTextNode() {
if (parent && tags.length > 0) {
prev = tags[tags.length - 1];
i = (prev.loc[1] || prev.loc[0]).end;
if (prev.parent === parent && i && i < tag.loc[0].start) {
text = str.substring(i, tag.loc[0].start);
if (text) {
parent.children.push({
type: TEXT_NODE,
value: text,
parent
});
}
}
text = str.substring(lastIndex, DOM_PARSER_RE.lastIndex - token[0].length);
if (text) {
parent.children.push({
type: TEXT_NODE,
value: text,
parent
});
}

@@ -72,3 +67,2 @@ }

};
commitTextNode();
tags.push(tag);

@@ -93,6 +87,6 @@ tag.parent.children.push(tag);

};
commitTextNode();
tags.push(tag);
tag.parent.children.push(tag);
} else if (token[1] !== "/") {
commitTextNode();
tag = {

@@ -111,3 +105,2 @@ type: ELEMENT_NODE,

};
commitTextNode();
tags.push(tag);

@@ -122,2 +115,3 @@ tag.parent.children.push(tag);

} else {
commitTextNode();
if (token[2] + "" === parent.name) {

@@ -146,10 +140,10 @@ tag = parent;

}
lastIndex = DOM_PARSER_RE.lastIndex;
}
if (doc.children.length === 0) {
doc.children.push({
type: TEXT_NODE,
value: str,
parent
});
}
text = str.slice(lastIndex);
parent.children.push({
type: TEXT_NODE,
value: text,
parent
});
return doc;

@@ -156,0 +150,0 @@ }

{
"name": "ultrahtml",
"type": "module",
"version": "0.0.5",
"version": "0.1.0",
"types": "./dist/index.d.ts",

@@ -41,2 +41,3 @@ "repository": {

"esbuild": "^0.14.51",
"markdown-it": "^13.0.1",
"prettier": "^2.5.1",

@@ -43,0 +44,0 @@ "typescript": "^4.7.4",

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