lume-js 2.0.1 → 2.2.0
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.
- package/README.md +54 -11
- package/dist/addons.min.mjs +1 -1
- package/dist/addons.mjs +61 -2
- package/dist/addons.mjs.map +1 -1
- package/dist/handlers.min.mjs +1 -1
- package/dist/handlers.mjs +15 -8
- package/dist/handlers.mjs.map +1 -1
- package/dist/lume.global.js +1 -1
- package/dist/lume.global.js.map +1 -1
- package/dist/shared-Dcokqj5a.mjs.map +1 -1
- package/package.json +12 -5
- package/src/addons/index.d.ts +26 -7
- package/src/addons/repeat.js +63 -3
- package/src/addons/watch.js +10 -1
- package/src/core/effect.js +1 -0
- package/src/core/state.js +1 -0
- package/src/handlers/ariaAttr.js +14 -0
- package/src/handlers/boolAttr.js +14 -0
- package/src/handlers/className.js +5 -0
- package/src/handlers/classToggle.js +14 -0
- package/src/handlers/htmlAttrs.js +57 -0
- package/src/handlers/index.d.ts +13 -0
- package/src/handlers/index.js +8 -196
- package/src/handlers/presets.js +14 -0
- package/src/handlers/show.js +5 -0
- package/src/handlers/stringAttr.js +16 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a handler for any string attribute (href, src, title, alt, action, etc.)
|
|
3
|
+
* Sets the attribute value as a string. Removes the attribute when value is null/undefined.
|
|
4
|
+
*
|
|
5
|
+
* @param {string} name - HTML attribute name (e.g., 'href', 'src', 'title')
|
|
6
|
+
* @returns {{ attr: string, apply: function }}
|
|
7
|
+
*/
|
|
8
|
+
export function stringAttr(name) {
|
|
9
|
+
return {
|
|
10
|
+
attr: `data-${name}`,
|
|
11
|
+
apply(el, val) {
|
|
12
|
+
if (val == null) el.removeAttribute(name);
|
|
13
|
+
else el.setAttribute(name, String(val));
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
}
|