Skip to content

Commit

Permalink
release
Browse files Browse the repository at this point in the history
  • Loading branch information
ecmel committed Jan 28, 2024
1 parent 3a8e529 commit 14de295
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 74 deletions.
116 changes: 58 additions & 58 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "refable-light",
"displayName": "Refable Light",
"version": "0.0.9",
"description": "Lighter version of Refable.",
"version": "1.0.0",
"description": "Super simple JS controller.",
"keywords": [
"html",
"controller"
Expand All @@ -19,14 +19,15 @@
"files": [
"dist"
],
"type": "module",
"main": "./dist/refable.cjs",
"module": "./dist/refable.mjs",
"types": "./dist/refable.d.ts",
"scripts": {
"clean": "git clean -Xdf",
"prereset": "npm run clean",
"reset": "npm install",
"update": "ncu -u -x prettier",
"update": "npx npm-check-updates -u -x prettier",
"format": "prettier --ignore-path .gitignore -w --list-different .",
"build": "rollup -c --forceExit",
"prepack": "npm run build"
Expand All @@ -35,7 +36,7 @@
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.6",
"prettier": "^2.8.8",
"rollup": "^4.9.5",
"rollup": "^4.9.6",
"rollup-plugin-cleandir": "^2.0.0",
"tslib": "^2.6.2",
"typescript": "^5.3.3"
Expand Down
21 changes: 13 additions & 8 deletions refable.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1986-2023 Ecmel Ercan (https://ecmel.dev/)
* Copyright (c) 1986-2024 Ecmel Ercan (https://ecmel.dev/)
* Licensed under the MIT License
*/

Expand Down Expand Up @@ -56,19 +56,24 @@ export class Application {

if (!controller) {
const id = el.getAttribute("data-controller");
const ctor = this.ctors.get(id);
controller = new ctor(el, this);
this.controllers.set(el, controller);
queueMicrotask(() => controller.created());
if (id) {
const ctor = this.ctors.get(id);
if (ctor) {
controller = new ctor(el, this);
this.controllers.set(el, controller);
queueMicrotask(() => controller?.created());
}
}
}

queueMicrotask(() => controller.connected());
queueMicrotask(() => controller?.connected());
}

private removeController(el: Element) {
const controller = this.controllers.get(el);

queueMicrotask(() => controller.disconnected());
if (controller) {
queueMicrotask(() => controller.disconnected());
}
}

register(id: string, ctor: Class<Controller>) {
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.mjs → rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1986-2023 Ecmel Ercan (https://ecmel.dev/)
* Copyright (c) 1986-2024 Ecmel Ercan (https://ecmel.dev/)
* Licensed under the MIT License
*/

Expand Down
11 changes: 8 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
{
"compilerOptions": {
"outDir": "./",
"target": "es6",
"moduleResolution": "node",
"declaration": true
"target": "ES2020",
"module": "ES2020",
"moduleResolution": "Bundler",
"isolatedModules": true,
"esModuleInterop": true,
"skipLibCheck": true,
"strict": true,
"noUnusedLocals": true
},
"exclude": ["node_modules"]
}

0 comments on commit 14de295

Please sign in to comment.