@joist/observable 2.0.0-alpha.11 → 2.0.0-alpha.14
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.
- package/README.md +1 -1
- package/package.json +2 -2
- package/target/build/lib/observable.js +11 -11
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@joist/observable",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.14",
|
|
4
4
|
"main": "./target/build/lib.js",
|
|
5
5
|
"module": "./target/build/lib.js",
|
|
6
6
|
"exports": {
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"test": "tsc -p tsconfig.test.json && wtr --config ../../wtr.config.mjs --port 8002",
|
|
35
35
|
"build": "tsc -p tsconfig.build.json"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "ee3d50d547903a8ddefbd66a700ab11df8fecfaf"
|
|
38
38
|
}
|
|
@@ -32,16 +32,13 @@ export function observable(Base) {
|
|
|
32
32
|
Object.defineProperties(this, descriptors);
|
|
33
33
|
}
|
|
34
34
|
connectedCallback() {
|
|
35
|
-
attributes.forEach((
|
|
36
|
-
const {
|
|
37
|
-
const
|
|
38
|
-
if (
|
|
39
|
-
Reflect.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const propVal = Reflect.get(this, attribute);
|
|
43
|
-
if (propVal !== undefined && propVal !== null) {
|
|
44
|
-
this.setAttribute(attribute, write(propVal));
|
|
35
|
+
attributes.forEach((key) => {
|
|
36
|
+
const { write } = parsers[key];
|
|
37
|
+
const attrVal = this.getAttribute(key);
|
|
38
|
+
if (attrVal === null) {
|
|
39
|
+
const propVal = Reflect.get(this, key);
|
|
40
|
+
if (propVal !== undefined && propVal !== null && propVal !== '') {
|
|
41
|
+
this.setAttribute(key, write(propVal));
|
|
45
42
|
}
|
|
46
43
|
}
|
|
47
44
|
});
|
|
@@ -61,7 +58,10 @@ export function observable(Base) {
|
|
|
61
58
|
for (let change in changes) {
|
|
62
59
|
if (attributes.includes(change)) {
|
|
63
60
|
const { write } = parsers[change];
|
|
64
|
-
|
|
61
|
+
const value = write(changes[change].value);
|
|
62
|
+
if (value !== this.getAttribute(change)) {
|
|
63
|
+
this.setAttribute(change, write(changes[change].value));
|
|
64
|
+
}
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
}
|