lightview 1.4.4-b → 1.4.5-b
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/lightview.js +13 -14
- package/package.json +1 -1
package/README.md
CHANGED
package/lightview.js
CHANGED
|
@@ -73,6 +73,7 @@ const {observe} = (() => {
|
|
|
73
73
|
if (toType === "number") return parseFloat(value + "");
|
|
74
74
|
if (toType === "boolean") {
|
|
75
75
|
if (["on", "checked", "selected"].includes(value)) return true;
|
|
76
|
+
if(value==null || value==="") return false;
|
|
76
77
|
try {
|
|
77
78
|
const parsed = JSON.parse(value + "");
|
|
78
79
|
if (typeof (parsed) === "boolean") return parsed;
|
|
@@ -127,7 +128,7 @@ const {observe} = (() => {
|
|
|
127
128
|
}
|
|
128
129
|
throw new TypeError(`Unable to coerce ${value} to ${toType}`)
|
|
129
130
|
}
|
|
130
|
-
const Reactor = (value
|
|
131
|
+
const Reactor = (value) => {
|
|
131
132
|
if (value && typeof (value) === "object") {
|
|
132
133
|
if (value.__isReactor__) return value;
|
|
133
134
|
const childReactors = [],
|
|
@@ -155,7 +156,7 @@ const {observe} = (() => {
|
|
|
155
156
|
return value;
|
|
156
157
|
}
|
|
157
158
|
if (value && type === "object") {
|
|
158
|
-
value = Reactor(value
|
|
159
|
+
value = Reactor(value);
|
|
159
160
|
childReactors.push(value);
|
|
160
161
|
}
|
|
161
162
|
target[property] = value;
|
|
@@ -165,7 +166,7 @@ const {observe} = (() => {
|
|
|
165
166
|
const type = typeof (value);
|
|
166
167
|
if (target[property] !== value) {
|
|
167
168
|
if (value && type === "object") {
|
|
168
|
-
value = Reactor(value
|
|
169
|
+
value = Reactor(value);
|
|
169
170
|
childReactors.push(value);
|
|
170
171
|
}
|
|
171
172
|
target[property] = value;
|
|
@@ -211,7 +212,7 @@ const {observe} = (() => {
|
|
|
211
212
|
if (newValue == null || type === "any" || newtype === type || (typetype === "function" && newValue && newtype === "object" && newValue instanceof type)) {
|
|
212
213
|
if (value !== newValue) {
|
|
213
214
|
event.oldValue = value;
|
|
214
|
-
target[property].value = reactive ? Reactor(newValue
|
|
215
|
+
target[property].value = reactive ? Reactor(newValue) : newValue; // do first to prevent loops
|
|
215
216
|
target.postEvent.value("change", event);
|
|
216
217
|
if (event.defaultPrevented) target[property].value = value;
|
|
217
218
|
}
|
|
@@ -482,11 +483,17 @@ const {observe} = (() => {
|
|
|
482
483
|
} else if (node.nodeType === Node.ELEMENT_NODE) {
|
|
483
484
|
// resolve the value before all else;
|
|
484
485
|
const attr = node.attributes.value;
|
|
485
|
-
let name;
|
|
486
486
|
if (attr && attr.template) {
|
|
487
487
|
render(!!attr.template, () => {
|
|
488
488
|
const value = resolveNode(attr, this),
|
|
489
489
|
eltype = resolveNode(node.attributes.type, ctx);
|
|
490
|
+
if(node.attributes.value) {
|
|
491
|
+
const template = attr.template;
|
|
492
|
+
if(/\$\{[a-zA-z_]+\}/g.test(template)) {
|
|
493
|
+
const name = template.substring(2,template.length-1);
|
|
494
|
+
if(!name.includes(" ")) bindInput(node,name,this,value);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
490
497
|
if (eltype === "checkbox") {
|
|
491
498
|
if (coerce(value, "boolean") === true) {
|
|
492
499
|
node.setAttribute("checked", "");
|
|
@@ -513,14 +520,6 @@ const {observe} = (() => {
|
|
|
513
520
|
}
|
|
514
521
|
})
|
|
515
522
|
}
|
|
516
|
-
if(node.attributes.value) {
|
|
517
|
-
const valueattr = node.attributes.value,
|
|
518
|
-
template = valueattr.template || valueattr.template.value;
|
|
519
|
-
if(template.startsWith("${") && template.endsWith("}")) {
|
|
520
|
-
const name = template.substring(2,template.length-1);
|
|
521
|
-
if(!name.includes(" ")) bindInput(node,name,this,value);
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
523
|
});
|
|
525
524
|
}
|
|
526
525
|
[...node.attributes].forEach((attr) => {
|
|
@@ -694,7 +693,7 @@ const {observe} = (() => {
|
|
|
694
693
|
}
|
|
695
694
|
if (reactive) {
|
|
696
695
|
variable.reactive = true;
|
|
697
|
-
this.vars[key] = Reactor(variable
|
|
696
|
+
this.vars[key] = Reactor(variable);
|
|
698
697
|
}
|
|
699
698
|
if (shared) {
|
|
700
699
|
variable.shared = true;
|
package/package.json
CHANGED