jsquery_node 1.0.2 → 1.0.3

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 (4) hide show
  1. package/jsquery.d.ts +2757 -2774
  2. package/jsquery.js +1 -1
  3. package/jsquery.ts +23 -11
  4. package/package.json +1 -1
package/jsquery.js CHANGED
@@ -20,7 +20,7 @@ export const { $, JSQuery } = (() => {
20
20
  return this.map((v) => v.is(q));
21
21
  }
22
22
  checked(val) {
23
- if (val) {
23
+ if (val !== undefined) {
24
24
  this.forEach((v) => v.checked(val));
25
25
  return this;
26
26
  }
package/jsquery.ts CHANGED
@@ -13,8 +13,10 @@ export const { $, JSQuery } = (() => {
13
13
  is(q:string) {
14
14
  return this.map((v) => v.is(q));
15
15
  }
16
+ checked(): boolean[];
17
+ checked(val: boolean): this;
16
18
  checked(val?: boolean): this | boolean[] {
17
- if (val) {
19
+ if (val !== undefined) {
18
20
  this.forEach((v) => v.checked(val));
19
21
  return this;
20
22
  }
@@ -66,7 +68,7 @@ export const { $, JSQuery } = (() => {
66
68
 
67
69
  class Element {
68
70
  elt: HTMLElement;
69
- #TriggerEvent(e: any, func: (this:HTMLElement, ev: any) => any, s: boolean | AddEventListenerOptions) {
71
+ #TriggerEvent(e: any, func: (this:HTMLElement, ev: any) => any, s?: boolean | AddEventListenerOptions) {
70
72
  if (!func) {
71
73
  this.trigger(e);
72
74
  return;
@@ -88,11 +90,11 @@ export const { $, JSQuery } = (() => {
88
90
  constructor(elt:HTMLElement) {
89
91
  this.elt = elt;
90
92
  }
91
- on(e: any, func: (this:HTMLElement, ev: any) => any, s: boolean | AddEventListenerOptions) {
93
+ on(e: any, func: (this:HTMLElement, ev: any) => any, s?: boolean | AddEventListenerOptions) {
92
94
  this.elt.addEventListener(e, func, s);
93
95
  return this;
94
96
  }
95
- removeEvent(e: any, func: (this:HTMLElement, ev: any) => any, s: boolean | AddEventListenerOptions) {
97
+ removeEvent(e: any, func: (this:HTMLElement, ev: any) => any, s?: boolean | AddEventListenerOptions) {
96
98
  this.elt.removeEventListener(e, func, s);
97
99
  return this;
98
100
  }
@@ -122,7 +124,9 @@ export const { $, JSQuery } = (() => {
122
124
  getProp(name: string) {
123
125
  return this.elt.getAttribute(name);
124
126
  }
125
- id(val: string | undefined): string | this {
127
+ id(): string;
128
+ id(val: string): this;
129
+ id(val?: string): string | this {
126
130
  if (val == undefined) return this.getProp("id");
127
131
  this.props({ id: val });
128
132
  return this;
@@ -154,11 +158,11 @@ export const { $, JSQuery } = (() => {
154
158
  hasClass(name: string) {
155
159
  return this.elt.classList.contains(name);
156
160
  }
157
- $(q: any) {
158
- return J.from(this.elt.querySelector(q));
161
+ $(q: any): Element {
162
+ return J.from(this.elt.querySelector(q)) as any;
159
163
  }
160
- all(q: any) {
161
- return J.from(this.elt.querySelectorAll(q));
164
+ all(q: any): ElementArray {
165
+ return J.from(this.elt.querySelectorAll(q)) as any;
162
166
  }
163
167
  is(q:string) {
164
168
  return this.elt.matches(q);
@@ -178,11 +182,15 @@ export const { $, JSQuery } = (() => {
178
182
  get children() {
179
183
  return Element.from(this.elt.children);
180
184
  }
185
+ html(): string;
186
+ html(val: string): this;
181
187
  html(val?:string): string|this {
182
188
  if (val == undefined) return this.elt.innerHTML;
183
189
  this.elt.innerHTML = val;
184
190
  return this;
185
191
  }
192
+ text(): string;
193
+ text(val: string): this;
186
194
  text(val?: string): string | this {
187
195
  if (val == undefined) return this.elt.textContent;
188
196
  this.elt.textContent = val;
@@ -191,18 +199,22 @@ export const { $, JSQuery } = (() => {
191
199
  rect() {
192
200
  return this.elt.getBoundingClientRect().toJSON();
193
201
  }
194
- value(val?: string | undefined): string | this {
202
+ value(): string;
203
+ value(val: string): this;
204
+ value(val?: string): string | this {
195
205
  if (val == undefined) return this.getProp("value");
196
206
  this.props({value: val});
197
207
  return this;
198
208
  }
209
+ checked(): boolean;
210
+ checked(val: boolean): this;
199
211
  checked(val?: boolean): boolean| this {
200
212
  if (val == undefined) return this.getProp("checked") !== null;
201
213
  this.props({checked: val? "": null});
202
214
  return this;
203
215
  }
204
216
  //events
205
- click(func: (this:HTMLElement, ev: any) => any, s: boolean | AddEventListenerOptions) {
217
+ click(func?: (this:HTMLElement, ev: any) => any, s?: boolean | AddEventListenerOptions) {
206
218
  this.#TriggerEvent("click", func, s);
207
219
  return this;
208
220
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsquery_node",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "jsquery",
5
5
  "homepage": "https://github.com/chickencuber/jsquery_node#readme",
6
6
  "bugs": {