@thi.ng/rdom 1.1.21 → 1.2.0

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.
Files changed (4) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/README.md +9 -9
  3. package/dom.js +13 -22
  4. package/package.json +10 -10
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2024-03-27T09:53:45Z
3
+ - **Last updated**: 2024-04-11T12:32:44Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
@@ -9,6 +9,14 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
9
9
  **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
10
10
  and/or version bumps of transitive dependencies.
11
11
 
12
+ ## [1.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/rdom@1.2.0) (2024-04-11)
13
+
14
+ #### 🚀 Features
15
+
16
+ - update setAttrib() property vs. attrib handling ([52cfe72](https://github.com/thi-ng/umbrella/commit/52cfe72))
17
+ - add/build cache of property setters
18
+ - update setAttrib() to prioritize setters and only fallback to attributes
19
+
12
20
  ## [1.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/rdom@1.1.0) (2024-02-10)
13
21
 
14
22
  #### 🚀 Features
package/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  [![Mastodon Follow](https://img.shields.io/mastodon/follow/109331703950160316?domain=https%3A%2F%2Fmastodon.thi.ng&style=social)](https://mastodon.thi.ng/@toxi)
8
8
 
9
9
  > [!NOTE]
10
- > This is one of 190 standalone projects, maintained as part
10
+ > This is one of 192 standalone projects, maintained as part
11
11
  > of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
12
12
  > and anti-framework.
13
13
  >
@@ -265,7 +265,13 @@ $compile([
265
265
  yarn add @thi.ng/rdom
266
266
  ```
267
267
 
268
- ES module import:
268
+ ESM import:
269
+
270
+ ```ts
271
+ import * as rdom from "@thi.ng/rdom";
272
+ ```
273
+
274
+ Browser ESM import:
269
275
 
270
276
  ```html
271
277
  <script type="module" src="https://cdn.skypack.dev/@thi.ng/rdom"></script>
@@ -273,13 +279,7 @@ ES module import:
273
279
 
274
280
  [Skypack documentation](https://docs.skypack.dev/)
275
281
 
276
- For Node.js REPL:
277
-
278
- ```js
279
- const rdom = await import("@thi.ng/rdom");
280
- ```
281
-
282
- Package sizes (brotli'd, pre-treeshake): ESM: 4.02 KB
282
+ Package sizes (brotli'd, pre-treeshake): ESM: 4.04 KB
283
283
 
284
284
  ## Dependencies
285
285
 
package/dom.js CHANGED
@@ -100,10 +100,17 @@ const $attribs = (el, attribs) => {
100
100
  }
101
101
  return el;
102
102
  };
103
+ const __setterCache = {};
104
+ const getproto = Object.getPrototypeOf;
105
+ const getdesc = Object.getOwnPropertyDescriptor;
106
+ const __desc = (proto, prop) => proto ? getdesc(proto, prop) ?? __desc(getproto(proto), prop) : void 0;
107
+ const __setter = (el, prop) => {
108
+ const key = `${el.namespaceURI}/${el.tagName}#${prop}`;
109
+ return __setterCache[key] ?? (__setterCache[key] = __desc(getproto(el), prop)?.set ?? false);
110
+ };
103
111
  const setAttrib = (el, id, val, attribs) => {
104
112
  implementsFunction(val, "deref") && (val = val.deref());
105
- const isListener = id.startsWith("on");
106
- if (isListener) {
113
+ if (id.startsWith("on")) {
107
114
  if (isString(val)) {
108
115
  el.setAttribute(id, val);
109
116
  } else {
@@ -130,27 +137,11 @@ const setAttrib = (el, id, val, attribs) => {
130
137
  case "prefix":
131
138
  el.setAttribute(id, isString(val) ? val : formatPrefixes(val));
132
139
  break;
133
- case "accessKey":
134
- case "autocapitalize":
135
- case "checked":
136
- case "contentEditable":
137
- case "dir":
138
- case "draggable":
139
- case "hidden":
140
- case "id":
141
- case "indeterminate":
142
- case "lang":
143
- case "scrollLeft":
144
- case "scrollTop":
145
- case "selectionEnd":
146
- case "selectionStart":
147
- case "slot":
148
- case "spellcheck":
149
- case "tabIndex":
150
- case "title":
151
- el[id] = val;
152
- break;
153
140
  default: {
141
+ const setter = __setter(el, id);
142
+ if (setter && val != null) {
143
+ return setter.call(el, val);
144
+ }
154
145
  const idx = id.indexOf(":");
155
146
  if (idx < 0) {
156
147
  val === false || val == null ? el.removeAttribute(id) : el.setAttribute(id, val === true ? id : val);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/rdom",
3
- "version": "1.1.21",
3
+ "version": "1.2.0",
4
4
  "description": "Lightweight, reactive, VDOM-less UI/DOM components with async lifecycle and @thi.ng/hiccup compatible",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -37,14 +37,14 @@
37
37
  "tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
38
38
  },
39
39
  "dependencies": {
40
- "@thi.ng/api": "^8.9.31",
41
- "@thi.ng/checks": "^3.5.5",
42
- "@thi.ng/errors": "^2.5.2",
43
- "@thi.ng/hiccup": "^5.1.26",
44
- "@thi.ng/paths": "^5.1.76",
45
- "@thi.ng/prefixes": "^2.3.14",
46
- "@thi.ng/rstream": "^8.3.19",
47
- "@thi.ng/strings": "^3.7.28"
40
+ "@thi.ng/api": "^8.10.1",
41
+ "@thi.ng/checks": "^3.6.1",
42
+ "@thi.ng/errors": "^2.5.4",
43
+ "@thi.ng/hiccup": "^5.1.28",
44
+ "@thi.ng/paths": "^5.1.78",
45
+ "@thi.ng/prefixes": "^2.3.16",
46
+ "@thi.ng/rstream": "^8.4.0",
47
+ "@thi.ng/strings": "^3.7.30"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@microsoft/api-extractor": "^7.43.0",
@@ -143,5 +143,5 @@
143
143
  ],
144
144
  "year": 2020
145
145
  },
146
- "gitHead": "ce5ae2a322d50a7ce8ecccbd94fa55c496ba04fd\n"
146
+ "gitHead": "18a0c063a7b33d790e5bc2486c106f45f663ac28\n"
147
147
  }