The issue in the code provided is that the el method of the Lizardx class returns the inf object, which does not have the styles method defined on it. This results in the error "Cannot read properties of undefined (reading 'styles')".
To fix this issue, you can update the el method to return the Lizardx instance itself so that you can chain the styles method after it. Here is an updated version of the code:
With this change, the el method now returns the Lizardx instance itself, allowing you to chain the styles and on methods after it. This should resolve the issue with the undefined property error.
The issue in the code provided is that the el method of the Lizardx class returns the inf object, which does not have the styles method defined on it. This results in the error "Cannot read properties of undefined (reading 'styles')".
To fix this issue, you can update the el method to return the Lizardx instance itself so that you can chain the styles method after it. Here is an updated version of the code:
import Faw from "./Lizardx";const { el } = new Faw();
el(".title").styles({ color: "red" }).on("click", () => {
console.log("click");
});
export default class Lizardx {
constructor(private inf) {
this.inf = { $el: null };
}
el(selector) {
this.inf.$el = document.querySelector(selector);
return this;
}
styles(stylesObj) {
for (const primary in stylesObj) {
this.inf.$el.style[primary] = stylesObj[primary];
}
return this;
}
on(event, func) {
this.inf.$el.addEventListener(event, func());
return this;
}
}
With this change, the el method now returns the Lizardx instance itself, allowing you to chain the styles and on methods after it. This should resolve the issue with the undefined property error.