Socket
Socket
Sign inDemoInstall

@thi.ng/hiccup

Package Overview
Dependencies
Maintainers
1
Versions
254
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thi.ng/hiccup - npm Package Compare versions

Comparing version 5.0.9 to 5.1.0

21

attribs.d.ts
/**
* Takes a space separated string of existing CSS class names and merges
* it with `val`, which is either another string of class names, an
* object of booleans or an `IDeref` evaluating to either. Returns
* updated class string.
* Takes a space separated string of existing CSS class names and merges it with
* `val`, which is either another string or string array of class names, an
* object of booleans or an `IDeref` evaluating to either. Returns updated class
* string.
*

@@ -10,6 +10,8 @@ * @remarks

*
* If `val` is an object, its keys are used as class names and their
* values indicate if the class should be added or removed from the
* existing set.
* If `val` is an array, it will be joined as space-separated string and
* concatenated to the existing one.
*
* If `val` is an object, its keys are used as class names and their values
* indicate if the class should be added or removed from the existing set.
*
* @example

@@ -20,4 +22,7 @@ * ```ts

*
* mergeClasses("foo", ["bar", "baz"]);
* // "foo bar baz"
*
* mergeClasses("foo bar", "baz");
* // "baz"
* // "foo bar baz"
* ```

@@ -24,0 +29,0 @@ *

import { deref } from "@thi.ng/api/deref";
import { isArray } from "@thi.ng/checks/is-array";
import { isString } from "@thi.ng/checks/is-string";
/**
* Takes a space separated string of existing CSS class names and merges
* it with `val`, which is either another string of class names, an
* object of booleans or an `IDeref` evaluating to either. Returns
* updated class string.
* Takes a space separated string of existing CSS class names and merges it with
* `val`, which is either another string or string array of class names, an
* object of booleans or an `IDeref` evaluating to either. Returns updated class
* string.
*

@@ -12,6 +13,8 @@ * @remarks

*
* If `val` is an object, its keys are used as class names and their
* values indicate if the class should be added or removed from the
* existing set.
* If `val` is an array, it will be joined as space-separated string and
* concatenated to the existing one.
*
* If `val` is an object, its keys are used as class names and their values
* indicate if the class should be added or removed from the existing set.
*
* @example

@@ -22,4 +25,7 @@ * ```ts

*
* mergeClasses("foo", ["bar", "baz"]);
* // "foo bar baz"
*
* mergeClasses("foo bar", "baz");
* // "baz"
* // "foo bar baz"
* ```

@@ -34,5 +40,7 @@ *

return existing;
if (isArray(val))
val = val.join(" ");
if (isString(val))
return existing + " " + val;
const classes = new Set(existing.split(" "));
return existing ? existing + " " + val : val;
const classes = new Set(existing ? existing.split(" ") : undefined);
for (let id in val) {

@@ -39,0 +47,0 @@ deref(val[id]) ? classes.add(id) : classes.delete(id);

# Change Log
- **Last updated**: 2023-12-03T12:13:31Z
- **Last updated**: 2023-12-09T19:12:03Z
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)

@@ -12,2 +12,14 @@

## [5.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@5.1.0) (2023-12-09)
#### 🚀 Features
- allow `class` attrib as string array ([448edd0](https://github.com/thi-ng/umbrella/commit/448edd0))
- update mergeClasses()
- update docs & tests
#### 🩹 Bug fixes
- fix mergeClasses(), add tests ([c734794](https://github.com/thi-ng/umbrella/commit/c734794))
### [5.0.6](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@5.0.6) (2023-11-09)

@@ -14,0 +26,0 @@

{
"name": "@thi.ng/hiccup",
"version": "5.0.9",
"version": "5.1.0",
"description": "HTML/SVG/XML serialization of nested data structures, iterables & closures",

@@ -36,11 +36,10 @@ "type": "module",

"dependencies": {
"@thi.ng/api": "^8.9.10",
"@thi.ng/checks": "^3.4.10",
"@thi.ng/errors": "^2.4.4",
"@thi.ng/strings": "^3.7.1"
"@thi.ng/api": "^8.9.11",
"@thi.ng/checks": "^3.4.11",
"@thi.ng/errors": "^2.4.5",
"@thi.ng/strings": "^3.7.2"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.38.3",
"@thi.ng/atom": "^5.2.16",
"@thi.ng/testament": "^0.4.3",
"@thi.ng/atom": "^5.2.17",
"rimraf": "^5.0.5",

@@ -130,3 +129,3 @@ "tools": "^0.0.1",

},
"gitHead": "04d1de79f256d7a53c6b5fd157b37f49bc88e11d\n"
"gitHead": "25f2ac8ff795a432a930119661b364d4d93b59a0\n"
}

@@ -176,3 +176,3 @@ <!-- This file is generated - DO NOT EDIT! -->

Package sizes (brotli'd, pre-treeshake): ESM: 2.14 KB
Package sizes (brotli'd, pre-treeshake): ESM: 2.17 KB

@@ -179,0 +179,0 @@ ## Dependencies

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