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

hyperx-to-snabbdom

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hyperx-to-snabbdom - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

196

index.js

@@ -1,70 +0,154 @@

module.exports = function (h) {
return function (tagName, attrs, children) {
var data = {
"class": {},
props: {},
style: {},
attrs: {},
hook: {},
on: {}
}
module.exports = function(h) {
return function(tagName, attrs, children) {
var data = {
class: {},
props: {},
style: {},
attrs: {},
hook: {},
on: {}
}
for (var key in attrs) {
if (key === undefined || !attrs.hasOwnProperty(key)) {
continue
}
var value = attrs[key]
if (children && !isTextTag(tagName) && !isCodeTag(tagName)) {
children = children.filter(function(child) {
return typeof child !== "string" || child.trim() !== ""
})
}
if (key === "className") {
var cls = value.split(" ")
for (var i = 0; i < cls.length; i++) {
data["class"][cls[i]] = true
}
} else if (key === "style") {
data.style = value
for (var key in attrs) {
if (key === undefined || !attrs.hasOwnProperty(key)) {
continue
}
var value = attrs[key]
} else if ("on" === key.substr(0, 2)) {
data.on[key.substr(2)] = value
if (key === "className") {
var cls = value.split(" ")
for (var i = 0; i < cls.length; i++) {
data["class"][cls[i]] = true
}
} else if (key === "style") {
data.style = value
} else if (key.substr(0, 2) === "on") {
data.on[key.substr(2)] = value
} else if (key.substr(0, 10) === "data-hook-") {
data.hook[key.substr(10)] = value
} else {
if (isSVG(tagName)) {
data.attrs[key] = parseBool(value)
continue
}
data.props[key] = data.attrs[key] = parseBool(value)
}
}
} else if ("data-hook-" === key.substr(0, 10)) {
data.hook[key.substr(10)] = value
return h(tagName, data, children ? [].concat.apply([], children) : children)
}
}
} else {
if (isSVG(tagName)) {
data.attrs[key] = parseBool(value)
continue
}
data.props[key] = data.attrs[key] = parseBool(value)
}
}
function isTextTag(tagName) {
var TEXT_TAGS = [
"a",
"abbr",
"b",
"bdi",
"bdo",
"br",
"cite",
"data",
"dfn",
"em",
"i",
"kbd",
"mark",
"q",
"rp",
"rt",
"rtc",
"ruby",
"s",
"amp",
"small",
"span",
"strong",
"sub",
"sup",
"time",
"u",
"var",
"wbr"
]
return h(tagName, data, children ? [].concat.apply([], children) : children)
}
return TEXT_TAGS.indexOf(tagName) !== -1
}
function parseBool(value) {
return value === "true" ? true : value === "false" ? false : value
function isCodeTag(tagName) {
var CODE_TAGS = ["code", "pre"]
return CODE_TAGS.indexOf(tagName) !== -1
}
function isSVG(tagName) {
var svgTags = [
"svg", "animate", "animateTransform", "circle", "cursor", "desc", "ellipse",
"feBlend", "feColorMatrix", "feComposite",
"feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap",
"feDistantLight", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR",
"feGaussianBlur", "feImage", "feMergeNode", "feMorphology",
"feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile",
"feTurbulence", "font-face-format", "font-face-name", "font-face-uri",
"glyph", "glyphRef", "hkern", "image", "line", "missing-glyph", "mpath",
"path", "polygon", "polyline", "rect", "set", "stop", "tref", "use", "view",
"vkern"
]
var svgTags = [
"svg",
"animate",
"animateTransform",
"circle",
"cursor",
"desc",
"ellipse",
"feBlend",
"feColorMatrix",
"feComposite",
"feConvolveMatrix",
"feDiffuseLighting",
"feDisplacementMap",
"feDistantLight",
"feFlood",
"feFuncA",
"feFuncB",
"feFuncG",
"feFuncR",
"feGaussianBlur",
"feImage",
"feMergeNode",
"feMorphology",
"feOffset",
"fePointLight",
"feSpecularLighting",
"feSpotLight",
"feTile",
"feTurbulence",
"font-face-format",
"font-face-name",
"font-face-uri",
"glyph",
"glyphRef",
"hkern",
"image",
"line",
"missing-glyph",
"mpath",
"path",
"polygon",
"polyline",
"rect",
"set",
"stop",
"tref",
"use",
"view",
"vkern"
]
for (var i = 0; i < svgTags.length; i++) {
if (tagName === svgTags[i]) {
return true
}
for (var i = 0; i < svgTags.length; i++) {
if (tagName === svgTags[i]) {
return true
}
}
return false
}
return false
}
function parseBool(value) {
return value === "true" ? true : value === "false" ? false : value
}
{
"name": "hyperx-to-snabbdom",
"version": "1.0.0",
"description": "Use snabbdom with hyperx.",
"version": "1.1.0",
"description": "Use Snabbdom with Hyperx.",
"main": "index.js",

@@ -6,0 +6,0 @@ "scripts": {

# hyperx-to-snabbdom
Use [snabbdom](https://github.com/snabbdom/snabbdom) with [hyperx](https://github.com/substack/hyperx).
Use [Snabbdom](https://github.com/snabbdom/snabbdom) with [Hyperx](https://github.com/substack/hyperx).

@@ -5,0 +5,0 @@ ## Installation

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