Skip to content

Commit 0b10d62

Browse files
committed
fixed minor bugs
1 parent 205eac3 commit 0b10d62

7 files changed

Lines changed: 33 additions & 240 deletions

File tree

docs/COMPONENT_AUTO_IMPORT.md

Lines changed: 0 additions & 184 deletions
This file was deleted.

docs/COMPONENT_AUTO_IMPORT_README_SECTION.md

Lines changed: 0 additions & 39 deletions
This file was deleted.

docs/notes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Putting a stage on the root component of the app can result in a memory leak that keeps at least double of the dom nodes currently rendered. It's best to have a second level component on which the states can are passed if at all there must be global states.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "modular-openscriptjs",
3-
"version": "2.0.0",
3+
"version": "2.0.3",
44
"description": "OpenScriptJs Framework - A lightweight, reactive JavaScript framework for building modern web applications",
55
"type": "module",
66
"main": "./dist/modular-openscriptjs.umd.js",

src/component/Component.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ export default class Component {
522522
let Cls = class extends Component {
523523
constructor() {
524524
super();
525-
this.name = `anonym-${id}`;
525+
this.name = `anonym${id}`;
526526
this.isAnonymous = true;
527527
}
528528

src/core/Runner.js

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,29 +35,40 @@ export default class Runner {
3535
let c = cls[i];
3636
let instance;
3737
const classKey = this.getClassKey(c);
38+
const instanceName = c.name;
3839

3940
if (!this.isClass(c)) {
40-
instance = new Component(c.name);
41-
} else {
42-
if (registrations[classKey] === "ongoing") {
43-
continue;
44-
}
41+
let functionClass = class extends Component {
42+
constructor() {
43+
super();
4544

46-
if (container.has(classKey)) {
47-
instance = container.resolve(classKey);
48-
if (instance.__ojsRegistered) {
49-
continue;
45+
this.name = instanceName;
5046
}
51-
} else {
52-
instance = new c();
53-
container.singleton(classKey, () => instance, []);
54-
registrations[classKey] = "ongoing";
47+
};
48+
49+
functionClass.prototype.render = c;
50+
51+
c = functionClass;
52+
}
53+
54+
if (registrations[classKey] === "ongoing") {
55+
continue;
56+
}
57+
58+
if (container.has(classKey)) {
59+
instance = container.resolve(classKey);
60+
if (instance.__ojsRegistered) {
61+
continue;
5562
}
63+
} else {
64+
instance = new c();
65+
container.singleton(classKey, () => instance, []);
66+
registrations[classKey] = "ongoing";
5667
}
5768

5869
if (instance instanceof Component) {
5970
registrations[classKey] = "completed";
60-
h.registerComponent(c.name, c);
71+
h.registerComponent(instanceName, c);
6172
} else if (instance instanceof Mediator || instance instanceof Listener) {
6273
await instance.register();
6374
registrations[classKey] = "completed";

src/core/State.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ export default class State {
5757
) {
5858
if (typeof listener === "string") {
5959
let uid = listener.split("-")[1];
60-
listener = container.resolve("repository").findComponent(Number(uid));
60+
listener = container.resolve("repository").findComponent(uid);
61+
62+
if (!listener) {
63+
return null;
64+
}
6165
}
6266

6367
this.$__listeners__.set(`component-${listener.id}`, listener);

0 commit comments

Comments
 (0)