Cannot read properties of undefined (reading 'inf')
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.inf;
}
styles(stylesObj) {
for(const primary in stylesObj) {
this.inf.$el.style[primary] = stylesObj[primary];
}
return this.inf;
}
on(event, func) {
this.inf.$el.addEventListener(event, func());
return this.inf;
}
}
class TotallyNotAjQuery {
constructor() {
this.inf = {
$el: null
}
this.el = this.el.bind(this);
}
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;
}
}
const {el: $} = new TotallyNotAjQuery();
$(".title").styles({
color: "red"
}).on("click", () => {
console.log("click");
});