@jackens/nnn 2026.4.12 → 2026.4.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/nnn.js +46 -50
  2. package/package.json +1 -1
  3. package/readme.md +1 -1
package/nnn.js CHANGED
@@ -67,65 +67,61 @@ var isRecord = (arg) => typeof arg === "object" && arg != null && !isArray(arg);
67
67
 
68
68
  // src/nnn/h.ts
69
69
  var XLINK_NS = "http://www.w3.org/1999/xlink";
70
- var newH = (namespaceUri) => {
71
- const createElement = namespaceUri == null ? (tag) => document.createElement(tag) : (tag) => document.createElementNS(namespaceUri, tag);
72
- const h = (tagOrNode, ...args) => {
73
- const node = isString(tagOrNode) ? createElement(tagOrNode) : tagOrNode;
74
- args.forEach((arg) => {
75
- let child = null;
76
- if (arg instanceof Node) {
77
- child = arg;
78
- } else if (isArray(arg)) {
79
- child = h(...arg);
80
- } else if (isRecord(arg)) {
81
- for (const name in arg) {
82
- const value = arg[name];
83
- if (name[0] === "$") {
84
- const name1 = name.slice(1);
85
- if (isRecord(value)) {
86
- node[name1] ??= {};
87
- Object.assign(node[name1], value);
88
- } else {
89
- node[name1] = value;
90
- }
91
- } else if (node instanceof Element) {
92
- const indexOfColon = name.indexOf(":");
93
- if (indexOfColon >= 0) {
94
- const nsKey = name.slice(0, indexOfColon);
95
- if (nsKey === "xlink") {
96
- const basename = name.slice(indexOfColon + 1);
97
- if (value === true) {
98
- node.setAttributeNS(XLINK_NS, basename, "");
99
- } else if (value === false) {
100
- node.removeAttributeNS(XLINK_NS, basename);
101
- } else {
102
- node.setAttributeNS(XLINK_NS, basename, "" + value);
103
- }
104
- }
105
- } else {
70
+ var _h = (createElement, tagOrNode, ...args) => {
71
+ const node = isString(tagOrNode) ? createElement(tagOrNode) : tagOrNode;
72
+ args.forEach((arg) => {
73
+ let child = null;
74
+ if (arg instanceof Node) {
75
+ child = arg;
76
+ } else if (isArray(arg)) {
77
+ child = _h(createElement, ...arg);
78
+ } else if (isRecord(arg)) {
79
+ for (const name in arg) {
80
+ const value = arg[name];
81
+ if (name[0] === "$") {
82
+ const name1 = name.slice(1);
83
+ if (isRecord(value)) {
84
+ node[name1] ??= {};
85
+ Object.assign(node[name1], value);
86
+ } else {
87
+ node[name1] = value;
88
+ }
89
+ } else if (node instanceof Element) {
90
+ const indexOfColon = name.indexOf(":");
91
+ if (indexOfColon >= 0) {
92
+ const nsKey = name.slice(0, indexOfColon);
93
+ if (nsKey === "xlink") {
94
+ const basename = name.slice(indexOfColon + 1);
106
95
  if (value === true) {
107
- node.setAttribute(name, "");
96
+ node.setAttributeNS(XLINK_NS, basename, "");
108
97
  } else if (value === false) {
109
- node.removeAttribute(name);
98
+ node.removeAttributeNS(XLINK_NS, basename);
110
99
  } else {
111
- node.setAttribute(name, "" + value);
100
+ node.setAttributeNS(XLINK_NS, basename, "" + value);
112
101
  }
113
102
  }
103
+ } else {
104
+ if (value === true) {
105
+ node.setAttribute(name, "");
106
+ } else if (value === false) {
107
+ node.removeAttribute(name);
108
+ } else {
109
+ node.setAttribute(name, "" + value);
110
+ }
114
111
  }
115
112
  }
116
- } else if (isString(arg) || isNumber(arg)) {
117
- child = document.createTextNode(arg);
118
- }
119
- if (child != null) {
120
- node.appendChild(child);
121
113
  }
122
- });
123
- return node;
124
- };
125
- return h;
114
+ } else if (isString(arg) || isNumber(arg)) {
115
+ child = document.createTextNode(arg);
116
+ }
117
+ if (child != null) {
118
+ node.appendChild(child);
119
+ }
120
+ });
121
+ return node;
126
122
  };
127
- var h = newH(null);
128
- var s = newH("http://www.w3.org/2000/svg");
123
+ var h = _h.bind(null, document.createElement);
124
+ var s = _h.bind(null, document.createElementNS.bind(document, "http://www.w3.org/2000/svg"));
129
125
  var svgUse = (id, ...args) => s("svg", ["use", { "xlink:href": "#" + id }], ...args);
130
126
 
131
127
  // src/nnn/fixPlTypography.ts
package/package.json CHANGED
@@ -44,5 +44,5 @@
44
44
  "name": "@jackens/nnn",
45
45
  "type": "module",
46
46
  "types": "nnn.d.ts",
47
- "version": "2026.4.12"
47
+ "version": "2026.4.13"
48
48
  }
package/readme.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # nnn
2
2
 
3
- A collection of Jackens’ JavaScript helper utilities (version: `2026.4.12`).
3
+ A collection of Jackens’ JavaScript helper utilities (version: `2026.4.13`).
4
4
 
5
5
  ## Installation
6
6