@k37z3r/jbase 2.0.2 → 2.1.1

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.
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * @k37z3r/jbase - A modern micro-framework for the web: jBase offers the familiar syntax of classic DOM libraries, but without their baggage. Fully typed, modular, and optimized for modern browser engines.
3
- * @version 2.0.2
4
- * @homepage https://github.com/k37z3r/jBase-2.0
5
- * @author Sven Minio (https://github.com/k37z3r/jBase-2.0)
3
+ * @version 2.1.1
4
+ * @homepage https://github.com/k37z3r/jBase-2
5
+ * @author Sven Minio (https://github.com/k37z3r/jBase-2)
6
6
  * @license GPL-3.0-or-later
7
- * @copyright 2026 Sven Minio (https://github.com/k37z3r/jBase-2.0)
7
+ * @copyright 2026 Sven Minio (https://github.com/k37z3r/jBase-2)
8
8
  */
9
9
  "use strict";
10
10
  (() => {
@@ -170,24 +170,46 @@
170
170
  css: () => css
171
171
  });
172
172
  function css(property, value) {
173
- if (value === void 0) {
174
- const el = this[0];
175
- if (el instanceof HTMLElement || el instanceof SVGElement) {
176
- const doc = el.ownerDocument;
177
- const win = doc ? doc.defaultView : null;
178
- if (win) {
179
- return win.getComputedStyle(el)[property];
180
- } else {
181
- return el.style[property] || "";
173
+ if (typeof property === "object" && property !== null) {
174
+ this.forEach((el) => {
175
+ if (el instanceof HTMLElement || el instanceof SVGElement) {
176
+ for (const key in property) {
177
+ if (Object.prototype.hasOwnProperty.call(property, key)) {
178
+ if (key.includes("-")) {
179
+ el.style.setProperty(key, String(property[key]));
180
+ } else {
181
+ el.style[key] = property[key];
182
+ }
183
+ }
184
+ }
182
185
  }
183
- }
184
- return "";
186
+ });
187
+ return this;
185
188
  }
186
- this.forEach((el) => {
187
- if (el instanceof HTMLElement || el instanceof SVGElement) {
188
- el.style[property] = value;
189
+ if (typeof property === "string") {
190
+ if (value === void 0) {
191
+ const el = this[0];
192
+ if (el instanceof HTMLElement || el instanceof SVGElement) {
193
+ const doc = el.ownerDocument;
194
+ const win = doc ? doc.defaultView : null;
195
+ if (win) {
196
+ return win.getComputedStyle(el).getPropertyValue(property) || win.getComputedStyle(el)[property] || "";
197
+ } else {
198
+ return el.style[property] || "";
199
+ }
200
+ }
201
+ return "";
189
202
  }
190
- });
203
+ this.forEach((el) => {
204
+ if (el instanceof HTMLElement || el instanceof SVGElement) {
205
+ if (property.includes("-")) {
206
+ el.style.setProperty(property, String(value));
207
+ } else {
208
+ el.style[property] = value;
209
+ }
210
+ }
211
+ });
212
+ }
191
213
  return this;
192
214
  }
193
215
  var init_styles = __esm({
@@ -195,7 +217,7 @@
195
217
  "use strict";
196
218
  /**
197
219
  * @file src/modules/css/styles.ts
198
- * @version 2.0.2
220
+ * @version 2.0.3
199
221
  * @since 2.0.0
200
222
  * @license GPL-3.0-or-later
201
223
  * @copyright Sven Minio 2026
@@ -576,6 +598,8 @@
576
598
  var attributes_exports = {};
577
599
  __export(attributes_exports, {
578
600
  attr: () => attr,
601
+ prop: () => prop,
602
+ removeAttr: () => removeAttr,
579
603
  val: () => val
580
604
  });
581
605
  function attr(name, value) {
@@ -603,12 +627,30 @@
603
627
  });
604
628
  return this;
605
629
  }
630
+ function removeAttr(name) {
631
+ this.forEach((el) => {
632
+ if (el instanceof Element) el.removeAttribute(name);
633
+ });
634
+ return this;
635
+ }
636
+ function prop(name, value) {
637
+ if (value === void 0) {
638
+ const el = this[0];
639
+ return el instanceof Element ? el[name] : void 0;
640
+ }
641
+ this.forEach((el) => {
642
+ if (el instanceof Element) {
643
+ el[name] = value;
644
+ }
645
+ });
646
+ return this;
647
+ }
606
648
  var init_attributes = __esm({
607
649
  "src/modules/dom/attributes.ts"() {
608
650
  "use strict";
609
651
  /**
610
652
  * @file src/modules/dom/attributes.ts
611
- * @version 2.0.2
653
+ * @version 2.1.0
612
654
  * @since 2.0.0
613
655
  * @license GPL-3.0-or-later
614
656
  * @copyright Sven Minio 2026
@@ -1675,9 +1717,16 @@
1675
1717
  get: () => get,
1676
1718
  getText: () => getText
1677
1719
  });
1678
- async function get(url) {
1720
+ async function get(url, option) {
1721
+ const fetchOptions = { ...option };
1722
+ if (fetchOptions.method?.toLowerCase() === "post") {
1723
+ fetchOptions.method = "GET";
1724
+ }
1725
+ if (!fetchOptions.signal) {
1726
+ fetchOptions.signal = AbortSignal.timeout(5e3);
1727
+ }
1679
1728
  const response = await fetch(url, {
1680
- signal: AbortSignal.timeout(5e3)
1729
+ ...fetchOptions
1681
1730
  });
1682
1731
  if (!response.ok) {
1683
1732
  throw new Error(`HTTP Error: ${response.status}`);
@@ -1685,20 +1734,29 @@
1685
1734
  const text2 = await response.text();
1686
1735
  return text2 ? JSON.parse(text2) : {};
1687
1736
  }
1688
- async function getText(url) {
1689
- const response = await fetch(url);
1737
+ async function getText(url, option) {
1738
+ const fetchOptions = { ...option };
1739
+ if (fetchOptions.method?.toLowerCase() !== "get") {
1740
+ fetchOptions.method = "GET";
1741
+ }
1742
+ if (!fetchOptions.signal) {
1743
+ fetchOptions.signal = AbortSignal.timeout(5e3);
1744
+ }
1745
+ const response = await fetch(url, {
1746
+ ...fetchOptions
1747
+ });
1690
1748
  if (!response.ok) {
1691
1749
  throw new Error(`HTTP Error: ${response.status}`);
1692
1750
  }
1693
1751
  const text2 = await response.text();
1694
- return text2 ? JSON.parse(text2) : {};
1752
+ return text2;
1695
1753
  }
1696
1754
  var init_get = __esm({
1697
1755
  "src/modules/http/get.ts"() {
1698
1756
  "use strict";
1699
1757
  /**
1700
1758
  * @file src/modules/http/get.ts
1701
- * @version 2.0.2
1759
+ * @version 2.0.4
1702
1760
  * @since 2.0.0
1703
1761
  * @license GPL-3.0-or-later
1704
1762
  * @copyright Sven Minio 2026
@@ -1717,9 +1775,16 @@
1717
1775
  __export(post_exports, {
1718
1776
  post: () => post
1719
1777
  });
1720
- async function post(url, body = {}) {
1778
+ async function post(url, body = {}, option) {
1779
+ const fetchOptions = { ...option };
1780
+ if (fetchOptions.method?.toLowerCase() !== "post") {
1781
+ fetchOptions.method = "post";
1782
+ }
1783
+ if (!fetchOptions.signal) {
1784
+ fetchOptions.signal = AbortSignal.timeout(5e3);
1785
+ }
1721
1786
  const response = await fetch(url, {
1722
- method: "POST",
1787
+ ...fetchOptions,
1723
1788
  headers: { "Content-Type": "application/json" },
1724
1789
  body: JSON.stringify(body)
1725
1790
  });
@@ -1738,8 +1803,8 @@
1738
1803
  "use strict";
1739
1804
  /**
1740
1805
  * @file src/modules/http/post.ts
1741
- * @version 2.0.2
1742
- * @since 2.0.0
1806
+ * @version 2.0.3
1807
+ * @since 2.0.2
1743
1808
  * @license GPL-3.0-or-later
1744
1809
  * @copyright Sven Minio 2026
1745
1810
  * @author Sven Minio <https://sven-minio.de>
@@ -1863,7 +1928,7 @@
1863
1928
  init_data();
1864
1929
  /**
1865
1930
  * @file src/index.ts
1866
- * @version 2.0.2
1931
+ * @version 2.1.1
1867
1932
  * @since 2.0.0
1868
1933
  * @license GPL-3.0-or-later
1869
1934
  * @copyright Sven Minio 2026