onejs-core 0.3.35 → 0.3.37

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.
@@ -270,7 +270,7 @@ declare global {
270
270
 
271
271
  }
272
272
 
273
- interface RadioButtonGroup extends BindableElement {
273
+ interface RadioButtonGroup extends BaseField<number> {
274
274
  label?: string
275
275
  }
276
276
 
package/dist/dom/dom.js CHANGED
@@ -3,14 +3,14 @@ export class DomWrapper {
3
3
  get _dom() { return this.#dom; }
4
4
  get ve() { return this.#dom.ve; }
5
5
  get childNodes() {
6
- if (!this.#dom.childNodes)
7
- return [];
8
- let arr = new Array(this.#dom.childNodes.Length);
6
+ if (this.#cachedChildNodes)
7
+ return this.#cachedChildNodes;
8
+ this.#cachedChildNodes = new Array(this.#dom.childNodes.Length);
9
9
  var i = this.#dom.childNodes.Length;
10
10
  while (i--) {
11
- arr[i] = new DomWrapper(this.#dom.childNodes.get_Item(i));
11
+ this.#cachedChildNodes[i] = new DomWrapper(this.#dom.childNodes.get_Item(i));
12
12
  }
13
- return arr;
13
+ return this.#cachedChildNodes;
14
14
  }
15
15
  get firstChild() {
16
16
  return this.#dom.firstChild ? new DomWrapper(this.#dom.firstChild) : null;
@@ -35,24 +35,29 @@ export class DomWrapper {
35
35
  set classname(value) { this.#dom.classname = value; }
36
36
  #dom;
37
37
  #domStyleWrapper;
38
+ #cachedChildNodes = null;
38
39
  constructor(dom) {
39
40
  this.#dom = dom;
40
41
  this.#domStyleWrapper = new DomStyleWrapper(dom.style);
41
42
  }
42
43
  appendChild(child) {
43
44
  this.#dom.appendChild(child.#dom);
45
+ this.#cachedChildNodes = null;
44
46
  }
45
47
  removeChild(child) {
46
48
  this.#dom.removeChild(child.#dom);
49
+ this.#cachedChildNodes = null;
47
50
  }
48
51
  insertBefore(a, b) {
49
52
  this.#dom.insertBefore(a?._dom, b?._dom);
53
+ this.#cachedChildNodes = null;
50
54
  }
51
55
  contains(child) {
52
56
  return this.#dom.contains(child._dom);
53
57
  }
54
58
  clearChildren() {
55
59
  this.#dom.clearChildren();
60
+ this.#cachedChildNodes = null;
56
61
  }
57
62
  focus() {
58
63
  this.#dom.focus();
package/dom/dom.ts CHANGED
@@ -5,13 +5,13 @@ export class DomWrapper {
5
5
  public get _dom(): CS.OneJS.Dom.Dom { return this.#dom }
6
6
  public get ve(): CS.UnityEngine.UIElements.VisualElement { return this.#dom.ve }
7
7
  public get childNodes(): DomWrapper[] {
8
- if (!this.#dom.childNodes) return [];
9
- let arr = new Array(this.#dom.childNodes.Length) as DomWrapper[];
8
+ if (this.#cachedChildNodes) return this.#cachedChildNodes
9
+ this.#cachedChildNodes = new Array(this.#dom.childNodes.Length) as DomWrapper[];
10
10
  var i = this.#dom.childNodes.Length;
11
11
  while (i--) {
12
- arr[i] = new DomWrapper(this.#dom.childNodes.get_Item(i));
12
+ this.#cachedChildNodes[i] = new DomWrapper(this.#dom.childNodes.get_Item(i));
13
13
  }
14
- return arr
14
+ return this.#cachedChildNodes
15
15
  }
16
16
  public get firstChild(): DomWrapper | null {
17
17
  return this.#dom.firstChild ? new DomWrapper(this.#dom.firstChild) : null;
@@ -40,6 +40,8 @@ export class DomWrapper {
40
40
  #dom: CS.OneJS.Dom.Dom
41
41
  #domStyleWrapper: DomStyleWrapper
42
42
 
43
+ #cachedChildNodes: DomWrapper[] = null
44
+
43
45
  constructor(dom: CS.OneJS.Dom.Dom) {
44
46
  this.#dom = dom
45
47
  this.#domStyleWrapper = new DomStyleWrapper(dom.style)
@@ -47,14 +49,17 @@ export class DomWrapper {
47
49
 
48
50
  appendChild(child: DomWrapper) {
49
51
  this.#dom.appendChild(child.#dom)
52
+ this.#cachedChildNodes = null
50
53
  }
51
54
 
52
55
  removeChild(child: DomWrapper) {
53
56
  this.#dom.removeChild(child.#dom)
57
+ this.#cachedChildNodes = null
54
58
  }
55
59
 
56
60
  insertBefore(a: DomWrapper, b: DomWrapper) {
57
61
  this.#dom.insertBefore(a?._dom, b?._dom)
62
+ this.#cachedChildNodes = null
58
63
  }
59
64
 
60
65
  contains(child: DomWrapper) {
@@ -63,6 +68,7 @@ export class DomWrapper {
63
68
 
64
69
  clearChildren() {
65
70
  this.#dom.clearChildren()
71
+ this.#cachedChildNodes = null
66
72
  }
67
73
 
68
74
  focus() {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "onejs-core",
3
3
  "description": "The JS part of OneJS, a UI framework and Scripting Engine for Unity.",
4
- "version": "0.3.35",
4
+ "version": "0.3.37",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./typings.d.ts",
7
7
  "dependencies": {