jizy-dom 2.1.7 → 2.1.9
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 +141 -18
- package/dist/js/jizy-dom.min.js +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1,18 +1,141 @@
|
|
|
1
|
-
# jizy-dom
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
##
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
# jizy-dom
|
|
2
|
+
|
|
3
|
+
A lightweight, chainable DOM manipulation library — a small jQuery-like wrapper over native DOM APIs, with no runtime dependencies.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install jizy-dom
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
ESM (Node / bundlers):
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import DOM from 'jizy-dom';
|
|
17
|
+
|
|
18
|
+
const $items = new DOM('.item');
|
|
19
|
+
$items.addClass('active').on('click', (e) => console.log(e.target));
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Browser (UMD/IIFE bundle, exposes the `DOM` global):
|
|
23
|
+
|
|
24
|
+
```html
|
|
25
|
+
<script src="node_modules/jizy-dom/dist/js/jizy-dom.min.js"></script>
|
|
26
|
+
<script>
|
|
27
|
+
new DOM('.item').show();
|
|
28
|
+
</script>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Constructor
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
new DOM(selector, parent)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
`selector` may be a CSS string, a single `Element`, an array/NodeList of elements, or another `DOM` instance. `parent` is optional and may be a CSS string, an `Element`, or another `DOM` instance — when given, the lookup is scoped to it. Passing a `DOM` instance as `selector` returns it as-is.
|
|
38
|
+
|
|
39
|
+
## `lib/js` directory
|
|
40
|
+
|
|
41
|
+
- **dom.js** — the `DOM` class (chainable API), CSS/data/class helpers, and a small `slide` animation primitive.
|
|
42
|
+
- **selector.js** — lightweight selector engine that normalizes the input (string, node, NodeList, window/document) and returns a flat array of elements.
|
|
43
|
+
|
|
44
|
+
## API
|
|
45
|
+
|
|
46
|
+
All chainable methods return the `DOM` instance. Read methods return the requested value (or `null`/`false`/`undefined` when nothing matches).
|
|
47
|
+
|
|
48
|
+
### Traversal & access
|
|
49
|
+
|
|
50
|
+
- `toArray()` — underlying elements as a plain array.
|
|
51
|
+
- `exists()` / `size()` — has matches / count.
|
|
52
|
+
- `each(cb)` — iterate `(el, i)`.
|
|
53
|
+
- `map(cb)` — collect callback return values; entries returning `false` are skipped.
|
|
54
|
+
- `filter(cbOrSelector)` — keep elements matching a selector or for which the callback returns truthy.
|
|
55
|
+
- `not(selector)` — inverse of `filter`.
|
|
56
|
+
- `get(index)` — single-element `DOM` at `index` (negative indexes count from the end).
|
|
57
|
+
- `getElement(tag)` — the first raw `Element`, or a freshly created `<tag>` (default `div`) when empty.
|
|
58
|
+
- `is(selector)` — match against a selector, an `Element`, a `DOM` instance, or the pseudo-selectors `:visible` / `:hidden`.
|
|
59
|
+
- `find(selector)` — descendants matching the selector; supports comma lists and a leading `>` for direct children.
|
|
60
|
+
- `parent(selector?)`, `children(selector?)`, `closest(selector)`, `prev(selector?)`, `next(selector?)`, `first(selector?)`, `last(selector?)`.
|
|
61
|
+
|
|
62
|
+
### Mutation
|
|
63
|
+
|
|
64
|
+
- `insert(newEl, position)` — `position` accepts `before` / `after` / `prepend` / `append` (mapped to `insertAdjacent*`). `newEl` may be a `DOM`, an `Element`, or an HTML string.
|
|
65
|
+
- `before(newEl)`, `after(newEl)`, `append(newEl)`, `prepend(newEl)`.
|
|
66
|
+
- `replaceWith(newEl)`, `remove()`, `wrap(wrapper)`.
|
|
67
|
+
|
|
68
|
+
### Content
|
|
69
|
+
|
|
70
|
+
- `text(value?)`, `html(value?)`, `content(value?)` — getter when called with no argument, setter otherwise.
|
|
71
|
+
|
|
72
|
+
### Classes
|
|
73
|
+
|
|
74
|
+
- `addClass(name)`, `removeClass(name)`, `toggleClass(name)`, `replaceClass(oldClass, newClass)`.
|
|
75
|
+
- `hasClass(name)`, `hasClasses(names)` (any), `hasAllClasses(names)` (all), `containsClass(substring)`.
|
|
76
|
+
|
|
77
|
+
### CSS / visibility
|
|
78
|
+
|
|
79
|
+
- `css(prop)` — read computed/inline value.
|
|
80
|
+
- `css(prop, value, important?)` — set; numeric values get `px` appended for size/spacing properties; pass `null` to remove.
|
|
81
|
+
- `css(['prop1','prop2'])` — read multiple values into an object.
|
|
82
|
+
- `show()`, `hide()`, `toggle()` — track the original `display` via `data-css-initial-display`.
|
|
83
|
+
- `offset()` — `{ top, left }` relative to the document.
|
|
84
|
+
- `outerHeight()`, `outerWidth()` — content + padding + margin.
|
|
85
|
+
|
|
86
|
+
### Data & attributes
|
|
87
|
+
|
|
88
|
+
- `data()` / `data(key)` / `data(key, value)` — read all dataset values, read one, or write one. Values are deserialized: `"true"`/`"false"`/`"null"`, numbers, and JSON literals are parsed; everything else stays a string. Object values are written as `data-key-subkey`.
|
|
89
|
+
- `attr(name)` / `attr(name, value)` — `setAttribute` / `getAttribute`; passing `null` removes the attribute.
|
|
90
|
+
- `prop(name)` / `prop(name, value)` — DOM property access with HTML→DOM remapping (`class` → `className`, `for` → `htmlFor`, `tabindex` → `tabIndex`, etc.).
|
|
91
|
+
- `tagName(uppercase?)` — tag name of the first element.
|
|
92
|
+
- `val(value?)` — form-control value getter/setter.
|
|
93
|
+
|
|
94
|
+
### Events
|
|
95
|
+
|
|
96
|
+
- `on(events, listener, options?)` — space-separated event list; `options` is forwarded to `addEventListener`.
|
|
97
|
+
- `off(events, listener)`.
|
|
98
|
+
- `delegate(events, selector, listener, options?)` — runs `listener` only when `event.target` matches `selector`.
|
|
99
|
+
- `trigger(eventName, eventData?, bubbles?, cancellable?)` — dispatches a `CustomEvent` when `eventData` is given, otherwise a plain `Event`.
|
|
100
|
+
- `submit()`, `focus()`.
|
|
101
|
+
- `swipe(swipeCb, ignoreCb?, params?)` — touch-swipe detector. `swipeCb(event, dir)` receives `'left' | 'right' | 'up' | 'down' | 'none'`. `params` overrides `{ scrolling: false, threshold: 10, restraint: 100, allowedTime: 300 }`. Uses passive listeners when supported.
|
|
102
|
+
|
|
103
|
+
### Animation & scroll
|
|
104
|
+
|
|
105
|
+
- `slideDown(speed?, easing?, delay?, display?)`.
|
|
106
|
+
- `slideUp(speed?, easing?, delay?)`.
|
|
107
|
+
- `slideToggle(speed?, easing?, delay?, display?)` — falls back to `show`/`hide`/`toggle` when `Promise` is unavailable. Defaults: `speed=500`, `easing='cubic-bezier(0.25, 0.1, 0.44, 1.4)'`, `delay=200`. Hidden state is tracked via the `slider-hidden` class.
|
|
108
|
+
- `scrollTop(position?)` — read or smooth-scroll the first element.
|
|
109
|
+
|
|
110
|
+
### Forms
|
|
111
|
+
|
|
112
|
+
- `serialize()` — first matched form serialized as a URL-encoded query string via `FormData` + `URLSearchParams`.
|
|
113
|
+
|
|
114
|
+
## Per-element helpers
|
|
115
|
+
|
|
116
|
+
Inside `each`/`map` callbacks, the raw `Element` is decorated with shorthand methods bound to that element: `el.data`, `el.css`, `el.addClass`, `el.removeClass`, `el.hasClass`, `el.hasClasses`, `el.hasAllClasses`. They behave like their `DOM` counterparts but operate on the single element.
|
|
117
|
+
|
|
118
|
+
## Build
|
|
119
|
+
|
|
120
|
+
This package follows the standard `jizy-*` packer layout. Build commands:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
npm run jpack:dist # build dist/ from lib/
|
|
124
|
+
npm run jpack:export # consumer-specific build (--name perso)
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
The browser bundle exposes the global `DOM` (configured in `config/jpack.js`).
|
|
128
|
+
|
|
129
|
+
## Tests
|
|
130
|
+
|
|
131
|
+
Vitest + happy-dom. Tests live under `tests/`.
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
npm run test # watch mode
|
|
135
|
+
npm run test:run # one-shot
|
|
136
|
+
npm run test:coverage # with coverage
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## License
|
|
140
|
+
|
|
141
|
+
MIT — see [LICENSE](LICENSE).
|
package/dist/js/jizy-dom.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! DOM v2.1.
|
|
1
|
+
/*! DOM v2.1.9 | MIT | 2026-05-28T17:34Z | [default] */
|
|
2
2
|
!function(e){"use strict";if("object"!=typeof e||!e||!e.document)throw new Error("DOM requires a window with a document");if(void 0!==e.DOM)throw new Error("DOM is already defined");var t=function(){const e="compareDocumentPosition"in document.documentElement?function(e,t){return!(16&~t.compareDocumentPosition(e))}:function(e,t){return(t=t==document||t==window?document.documentElement:t)!==e&&t.contains(e)};function t(e){return[].slice.call(e,0)}function s(e){let t;return e&&"object"==typeof e&&(t=e.nodeType)&&(1==t||9==t)}function n(e){return"object"==typeof e&&isFinite(e.length)}function i(r,l){const a=function(e){return e?"string"==typeof e?i(e)[0]:!e.nodeType&&n(e)?e[0]:e:document}(l);let o;return a&&r?r===window||s(r)?!l||r!==window&&s(a)&&e(r,a)?[r]:[]:r&&n(r)?function(e){for(var t=[],s=0,i=e.length;s<i;++s)n(e[s])?t=t.concat(e[s]):t[t.length]=e[s];return t}(r):document.getElementsByClassName&&"string"==r&&(o=r.match(/^\.([\w\-]+)$/))?t(a.getElementsByClassName(o[1])):r&&(r.document||r.nodeType&&9==r.nodeType)?l?[]:[r]:t(a.querySelectorAll(r)):[]}function r(...e){let t=!1,s=0,n={};"boolean"==typeof e[0]&&(t=e[0],s=1);const i=e=>e&&"[object Object]"===Object.prototype.toString.call(e),l=e=>{for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t&&i(e[s])?n[s]=r(!0,n[s]||{},e[s]):void 0!==e[s]&&(n[s]=e[s]))};for(;s<e.length;s++)e[s]&&l(e[s]);return n}const l=/^(?:(width|height|top|right|bottom|left|margin|padding)|((min|max)(Width|Height))|((margin|padding)(Top|Right|Bottom|Left)))$/,a={"column-count":1,columns:1,"font-weight":1,"line-height":1,opacity:1,"z-index":1,zoom:1},o={tabindex:"tabIndex",readonly:"readOnly",for:"htmlFor",class:"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},c=(()=>{let e=!1;try{const t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("test",null,t),window.removeEventListener("test",null,t)}catch(e){}return e})();function h(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function u(e){return e.replace(/-([a-z])/g,e=>e[1].toUpperCase())}function d(e,t){return!!(t&&e&&1===e.nodeType&&e.matches(t))}function m(e,t){return null==t?new E(e):new E(e).filter(t)}function p(e,t,s){null==s?e.removeAttribute(t):e.setAttribute(t,s)}function f(e){if(e.data("cssInitialDisplay"))return e.data("cssInitialDisplay");if(e.css("display")&&"none"!==e.css("display"))return e.css("display");switch(e.tagName.toLowerCase()){case"table":return"table";case"thead":return"table-header-group";case"tfoot":return"table-footer-group";case"tr":return"table-row";case"th":case"td":return"table-cell";case"span":return"inline";case"li":return"list-item"}return"block"}function g(e,t){for(var s in t)if(!0===e.classList.contains(t[s]))return!0;return!1}function y(e,t){for(var s in t)if(!1===e.classList.contains(t[s]))return!1;return!0}function w(e,t,s,n){return 2 in arguments?null===s?void e.style.removeProperty(h(t)):("number"==typeof s&&!a[h(t)]&&l.test(u(t))&&(s+="px"),void(n?e.style.setProperty(h(t),s,"important"):e.style[u(t)]=s)):e.style[u(t)]||getComputedStyle(e,null).getPropertyValue(h(t))}function b(e,t,s){if(1===arguments.length){const t={};for(let s in e.dataset)t[s]=b(e,s);return t}const n="data-"+h(t);if(!(2 in arguments))return null!==(s=e.getAttribute(n))?function(e){try{return e?"true"==e||"false"!=e&&("null"==e?null:+e+""==e?+e:/^[\[\{]/.test(e)?JSON.parse(e):e):e}catch(t){return e}}(s):void 0;if("object"!=typeof s||null===s||Array.isArray(s))p(e,n,s);else for(let n in s)b(e,t+"-"+n,s[n])}function v(e,t,s){const n=s.split(" ");return e.classList[t].apply(e.classList,n)}async function C(e,t){const s=t.slideSpeed,n=t.direction,i=t.easing,r=t.delay,l=void 0===r?0:r,a=t.visibleDisplayValue,o=void 0===a?"block":a,c=e.dataset.domSliderId||(Date.now()*Math.random()).toFixed(0);e.dataset.domSliderId||(e.dataset.domSliderId=c);const h=window.getComputedStyle(e),u="none"===h.getPropertyValue("display"),d=n||(u||e.classList.contains("slider-hidden")?"down":"up"),m=s||(0===s?0:300),p=h.getPropertyValue("box-sizing"),f=parseInt(h.getPropertyValue("padding-top").split("px")[0]),g=parseInt(h.getPropertyValue("padding-bottom").split("px")[0]);let y=Math.max(e.scrollHeight-f-g,0);return"border-box"===p&&(y=Math.max(e.scrollHeight,0)),e.dataset.sliding?Promise.resolve(e):"down"!==d||u||e.classList.contains("slider-hidden")?"up"===d&&e.classList.contains("slider-hidden")?Promise.resolve(e):(e.dataset.sliding=!0,e.setAttribute("aria-hidden","down"===d?"false":"true"),"down"===d&&u&&(e.classList.add("slider-hidden"),e.style.display=o,y=e.scrollHeight),e.style.height="".concat(y,"px"),e.style.transition="all ".concat(m,"ms ").concat(i||""),e.style.overflow="hidden",await new Promise(t=>{setTimeout(()=>{e.classList.contains("slider-hidden")||setTimeout(()=>{e.style.display="none"},300),e.classList.toggle("slider-hidden"),t()},+l>20?+l:20)}),await new Promise(t=>{setTimeout(()=>{e.style.removeProperty("height"),e.style.removeProperty("transition"),e.style.removeProperty("overflow"),e.removeAttribute("data-sliding"),t(e)},m)})):Promise.resolve(e)}class E{constructor(e,t){if(t=t||document,e instanceof E)return e;if(t instanceof E)return t.find(e);this.elems=i(e,t);for(let e=0;e<this.elems.length;e++){const t=this.elems[e];t.data=function(e,s){return 0===arguments.length?b(t):1===arguments.length?b(t,e):(b(t,e,s),t)},t.css=function(e,s,n){return arguments.length>=2?w(t,e,s,n||!1):w(t,e)},t.addClass=e=>v(t,"add",e),t.removeClass=e=>v(t,"remove",e),t.hasClass=e=>v(t,"contains",e),t.hasClasses=e=>g(t,e),t.hasAllClasses=e=>y(t,e)}return this}toArray(){return this.elems}exists(){return this.elems.length>0}size(){return this.elems.length}each(e){for(let t=0,s=this.elems.length;t<s;t++)e.call(this,this.elems[t],t);return this}map(e){const t=[];for(let s=0,n=this.elems.length;s<n;s++){const n=e.call(this,this.elems[s],s);!1!==n&&t.push(n)}return t}filter(e){if("function"!=typeof e){const t=e;e=e=>!!d(e,t)&&e}const t=[];for(let s=0,n=this.elems.length;s<n;s++){const n=e.call(this,this.elems[s],s);!1!==n&&t.push(n)}return new E(t)}not(e){const t=[];if("function"==typeof e&&void 0!==e.call)this.each(function(s,n){!1===e.call(s,n)&&t.push(s)});else{let s=[];s="string"==typeof e?this.filter(e):new E(e),s instanceof E&&(s=s.elems),this.each(function(e,n){s.indexOf(e)<0&&t.push(e)})}return new E(t)}get(e){const t=(e=e||0)>=0?e:this.elems.length+e;return void 0!==this.elems[t]?new E(this.elems[t]):this}getElement(e){return 0 in this.elems?this.elems[0]:document.createElement(e||"div")}is(e){return e instanceof HTMLElement?e===this.getElement():e instanceof E?e.getElement()===this.getElement():0 in this.elems&&"string"==typeof e&&(":visible"===e?"none"!==this.elems[0].css("display"):":hidden"===e?"none"===this.elems[0].css("display"):d(this.elems[0],e))}find(e){const t=e.trim().split(/,\s*/);let s=[];return this.each(function(e){for(let n=0,r=t.length;n<r;n++){const r=t[n].match(/^>\s*(.+)$/);if(t[n].match(/^\:(first|last)/),r){if(i(r[1],e))for(const t in e.childNodes)d(e.childNodes[t],r[1])&&(s=s.concat(e.childNodes[t]))}else{const r=i(t[n],e);r&&(s=s.concat(r))}}}),new E(s)}insert(e,t){return"before"===t&&(t="beforebegin"),"after"===t&&(t="afterend"),"prepend"===t&&(t="afterbegin"),"append"===t&&(t="beforeend"),this.each(s=>{e instanceof E?e.each(e=>{s.insertAdjacentElement(t,e)}):e instanceof Element?s.insertAdjacentElement(t,e):s.insertAdjacentHTML(t,e)})}before(e){return this.insert(e,"before")}after(e){return this.insert(e,"after")}append(e){return this.insert(e,"append")}prepend(e){return this.insert(e,"prepend")}replaceWith(e){return this.insert(e,"before"),this.remove(),this}remove(){return this.each(e=>e.parentNode.removeChild(e))}parent(e){let t=[];return this.each(e=>{const s=e.parentNode;s&&(t=t.concat(s))}),m(t,e||null)}children(e){let t=[];return this.each(e=>{const s=e.childNodes;s&&(t=t.concat(Array.from(s)))}),m(t,e||null)}closest(e){let t=[];return this.each(s=>{const n=s.closest(e);n&&(t=t.concat(n))}),new E(t)}prev(e){let t=[];return this.each(e=>{const s=e.previousElementSibling;s&&(t=t.concat(s))}),m(t,e||null)}next(e){let t=[];return this.each(e=>{const s=e.nextElementSibling;s&&(t=t.concat(s))}),m(t,e||null)}first(e){let t=[];return this.each(e=>{const s=e.firstElementChild;s&&(t=t.concat(s))}),m(t,e||null)}last(e){let t=[];return this.each(e=>{const s=e.lastElementChild;s&&(t=t.concat(s))}),m(t,e||null)}wrap(e){return this.each(t=>{t.parentNode.insertBefore(e,t),e.appendChild(t)}),this}on(e,t,s){return s=s||!1,e.split(" ").forEach(e=>{this.each(n=>{n.addEventListener(e,t,s)})}),this}delegate(e,t,s,n){return n=n||!1,this.on(e,e=>{new E(e.target).is(t)&&s(...arguments)},n)}off(e,t){return e.split(" ").forEach(e=>{this.each(s=>{s.removeEventListener(e,t)})}),this}submit(){return 0 in this.elems&&this.elems[0]instanceof HTMLFormElement&&this.elems[0].submit(),this}focus(){return 0 in this.elems&&this.elems[0].focus(),this}trigger(e,t,s,n){let i;return arguments.length<4&&(n=!0),arguments.length<3&&(s=!1),arguments.length<2&&(t=null),i=t?new CustomEvent(e,{bubbles:s,cancellable:n,detail:t}):new Event(e,{bubbles:s,cancellable:n}),this.each(e=>{e.dispatchEvent(i)})}swipe(e,t,s){return this.each(n=>{let i,l,a,o,h,u,d,m=e||function(e,t){},p=t||function(e){return!1},f=r({scrolling:!1,threshold:10,restraint:100,allowedTime:300},s||{});return n.addEventListener("touchstart",e=>{if(!1===p(e)){const t=e.changedTouches[0];i="none",l=t.pageX,a=t.pageY,d=(new Date).getTime(),!c&&e.preventDefault()}},c?{passive:!0}:void 0),n.addEventListener("touchmove",e=>{!1===p(e)&&!1===f.scrolling&&!c&&e.preventDefault()},c?{passive:!0}:void 0),n.addEventListener("touchend",e=>{if(!1===p(e)){const t=e.changedTouches[0];o=t.pageX-l,h=t.pageY-a,u=(new Date).getTime()-d,u<=f.allowedTime&&(Math.abs(o)>=f.threshold&&Math.abs(h)<=f.restraint?i=o<0?"left":"right":Math.abs(h)>=f.threshold&&Math.abs(o)<=f.restraint&&(i=h<0?"up":"down")),!c&&e.preventDefault(),m(e,i)}},c?{passive:!0}:void 0),this})}text(e){return 0 in arguments?this.each(t=>{t.innerText=e}):0 in this.elems?this.elems[0].innerText:null}html(e){return 0 in arguments?this.each(t=>{t.innerHTML=e}):0 in this.elems?this.elems[0].innerHTML:null}content(e){return 0 in arguments?this.each(t=>{t.innerContent=e}):0 in this.elems?this.elems[0].innerContent:null}addClass(e){return this.each(t=>{t.addClass(e)})}removeClass(e){return this.each(t=>{t.removeClass(e)})}toggleClass(e){return this.each(t=>{t.classList.toggle(e)})}replaceClass(e,t){return this.each(s=>{s.classList.replace(e,t)})}hasClass(e){return 0 in this.elems&&this.elems[0].classList.contains(e)}hasClasses(e){return 0 in this.elems&&this.elems[0].hasClasses(e)}hasAllClasses(e){return 0 in this.elems&&this.elems[0].hasAllClasses(e)}containsClass(e){if(0 in this.elems)for(var t=this.elems[0].classList,s=0;s<t.length;s++)if(t[s].indexOf(e)>-1)return!0;return!1}toggle(){return this.each(e=>{const t=f(e);e.data("cssInitialDisplay")||e.data("cssInitialDisplay",t),"none"===e.css("display")?e.style.display="block":e.style.display="none"})}show(){return this.each(e=>{const t=f(e);e.data("cssInitialDisplay")||e.data("cssInitialDisplay",t),e.style.display=t})}hide(){return this.each(e=>{e.data("cssInitialDisplay")||e.data("cssInitialDisplay",f(e)),e.style.display="none"})}offset(){if(0===this.elems.length)return{top:0,left:0};const e=this.elems[0].getBoundingClientRect();return{top:e.top+window.pageYOffset,left:e.left+window.pageXOffset}}serialize(){if(!(0 in this.elems))return"";const e=new FormData(this.elems[0]);return new URLSearchParams(e).toString()}css(e,t,s){if(1 in arguments)return this.each(n=>{w(n,e,t,s||!1)});if(0 in this.elems){if("string"==typeof e)return w(this.elems[0],e);const t={};if(Array.isArray(e)){const s=this.elems[0];e.forEach(e=>{t[e]=w(s,e)})}return t}return null}data(e,t){return 0 in arguments&&e?1 in arguments?this.each(s=>{b(s,e,t)}):0 in this.elems?b(this.elems[0],e):void 0:0 in this.elems?b(this.elems[0]):{}}attr(e,t){if(1 in arguments)return this.each(s=>{1===s.nodeType&&p(s,e,t)});let s=null;return 0 in this.elems&&1==this.elems[0].nodeType&&(s=this.elems[0].getAttribute(e)),s}prop(e,t){if(e=o[e]||e,1 in arguments)return this.each(s=>{s[e]=t});let s=null;return 0 in this.elems&&(s=this.elems[0][e]),s}tagName(e){let t=0 in this.elems?this.elems[0].tagName:null;return t&&(t=t.toLowerCase(),e&&(t=t.toUpperCase())),t}val(e){return 0 in arguments?(null==e&&(e=""),this.each(t=>{t.value=e})):0 in this.elems?this.elems[0].value:null}outerHeight(){let e=0;return 0 in this.elems&&(e+=parseInt(this.elems[0].css("height")),e+=parseInt(this.elems[0].css("padding-top")),e+=parseInt(this.elems[0].css("padding-bottom")),e+=parseInt(this.elems[0].css("margin-top")),e+=parseInt(this.elems[0].css("margin-bottom"))),e}outerWidth(){let e=0;return 0 in this.elems&&(e+=parseInt(this.elems[0].css("width")),e+=parseInt(this.elems[0].css("padding-left")),e+=parseInt(this.elems[0].css("padding-right")),e+=parseInt(this.elems[0].css("margin-left")),e+=parseInt(this.elems[0].css("margin-right"))),e}slideDown(e,t,s,n){return window.Promise?(e=e||500,t=t||"cubic-bezier(0.25, 0.1, 0.44, 1.4)",s=s||200,this.each(i=>C(i,{direction:"down",slideSpeed:e,easing:t,delay:s,visibleDisplayValue:n||f(i)}))):this.show()}slideUp(e,t,s){return window.Promise?(e=e||500,t=t||"cubic-bezier(0.25, 0.1, 0.44, 1.4)",s=s||200,this.each(n=>C(n,{direction:"up",slideSpeed:e,easing:t,delay:s}))):this.hide()}slideToggle(e,t,s,n){return window.Promise?(e=e||500,t=t||"cubic-bezier(0.25, 0.1, 0.44, 1.4)",s=s||200,this.each(i=>C(i,{slideSpeed:e,easing:t,delay:s,visibleDisplayValue:n||f(i)}))):this.toggle()}scrollTop(e){return 0 in arguments?this.each(t=>{t.style.scrollBehavior="smooth",t.scrollTop=e||0}):0 in this.elems?this.elems[0].scrollTop:0}}return E}();e.DOM=t}("undefined"!=typeof window?window:this);
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jizy-dom",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.9",
|
|
4
4
|
"browser": "dist/js/jizy-dom.min.js",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"
|
|
7
|
+
"author": "Joffrey Demetz <joffrey.demetz@gmail.com> (https://joffreydemetz.com/)",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"description": "A lightweight DOM manipulation library",
|
|
10
|
+
"homepage": "https://jizy.joffreydemetz.com/dom",
|
|
8
11
|
"files": [
|
|
9
12
|
"dist/*",
|
|
10
13
|
"lib/*"
|
|
@@ -24,13 +27,10 @@
|
|
|
24
27
|
"JiZy",
|
|
25
28
|
"DOM"
|
|
26
29
|
],
|
|
27
|
-
"author": "Joffrey Demetz <joffrey.demetz@gmail.com> (https://joffreydemetz.com/)",
|
|
28
|
-
"license": "MIT",
|
|
29
|
-
"description": "A lightweight DOM manipulation library",
|
|
30
|
-
"homepage": "https://jizy.joffreydemetz.com/dom",
|
|
31
30
|
"devDependencies": {
|
|
32
31
|
"happy-dom": "^20.9.0",
|
|
33
32
|
"jizy-packer": "^2.1.44",
|
|
33
|
+
"vite": "^6.0.0",
|
|
34
34
|
"vitest": "^4.1.5"
|
|
35
35
|
}
|
|
36
36
|
}
|