Merge pull request #974 from Demonthos/fix-selected-desktop
Fix selected and checked with boolean attributes
This commit is contained in:
1 file changed
+13
-11
@@ -17,8 +17,7 @@ class ListenerMap {
|
|||||||
} else {
|
} else {
|
||||||
this.global[event_name].active++;
|
this.global[event_name].active++;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
const id = element.getAttribute("data-dioxus-id");
|
const id = element.getAttribute("data-dioxus-id");
|
||||||
if (!this.local[id]) {
|
if (!this.local[id]) {
|
||||||
this.local[id] = {};
|
this.local[id] = {};
|
||||||
@@ -32,11 +31,13 @@ class ListenerMap {
|
|||||||
if (bubbles) {
|
if (bubbles) {
|
||||||
this.global[event_name].active--;
|
this.global[event_name].active--;
|
||||||
if (this.global[event_name].active === 0) {
|
if (this.global[event_name].active === 0) {
|
||||||
this.root.removeEventListener(event_name, this.global[event_name].callback);
|
this.root.removeEventListener(
|
||||||
|
event_name,
|
||||||
|
this.global[event_name].callback
|
||||||
|
);
|
||||||
delete this.global[event_name];
|
delete this.global[event_name];
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
const id = element.getAttribute("data-dioxus-id");
|
const id = element.getAttribute("data-dioxus-id");
|
||||||
delete this.local[id][event_name];
|
delete this.local[id][event_name];
|
||||||
if (this.local[id].length === 0) {
|
if (this.local[id].length === 0) {
|
||||||
@@ -143,8 +144,7 @@ class Interpreter {
|
|||||||
SetAttribute(id, field, value, ns) {
|
SetAttribute(id, field, value, ns) {
|
||||||
if (value === null) {
|
if (value === null) {
|
||||||
this.RemoveAttribute(id, field, ns);
|
this.RemoveAttribute(id, field, ns);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
const node = this.nodes[id];
|
const node = this.nodes[id];
|
||||||
this.SetAttributeInner(node, field, value, ns);
|
this.SetAttributeInner(node, field, value, ns);
|
||||||
}
|
}
|
||||||
@@ -167,10 +167,10 @@ class Interpreter {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "checked":
|
case "checked":
|
||||||
node.checked = value === "true";
|
node.checked = value === "true" || value === true;
|
||||||
break;
|
break;
|
||||||
case "selected":
|
case "selected":
|
||||||
node.selected = value === "true";
|
node.selected = value === "true" || value === true;
|
||||||
break;
|
break;
|
||||||
case "dangerous_inner_html":
|
case "dangerous_inner_html":
|
||||||
node.innerHTML = value;
|
node.innerHTML = value;
|
||||||
@@ -342,7 +342,6 @@ class Interpreter {
|
|||||||
this.RemoveEventListener(edit.id, edit.name);
|
this.RemoveEventListener(edit.id, edit.name);
|
||||||
break;
|
break;
|
||||||
case "NewEventListener":
|
case "NewEventListener":
|
||||||
|
|
||||||
let bubbles = event_bubbles(edit.name);
|
let bubbles = event_bubbles(edit.name);
|
||||||
|
|
||||||
// this handler is only provided on desktop implementations since this
|
// this handler is only provided on desktop implementations since this
|
||||||
@@ -360,7 +359,10 @@ class Interpreter {
|
|||||||
let a_element = target.closest("a");
|
let a_element = target.closest("a");
|
||||||
if (a_element != null) {
|
if (a_element != null) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (shouldPreventDefault !== `onclick` && a_element.getAttribute(`dioxus-prevent-default`) !== `onclick`) {
|
if (
|
||||||
|
shouldPreventDefault !== `onclick` &&
|
||||||
|
a_element.getAttribute(`dioxus-prevent-default`) !== `onclick`
|
||||||
|
) {
|
||||||
const href = a_element.getAttribute("href");
|
const href = a_element.getAttribute("href");
|
||||||
if (href !== "" && href !== null && href !== undefined) {
|
if (href !== "" && href !== null && href !== undefined) {
|
||||||
window.ipc.postMessage(
|
window.ipc.postMessage(
|
||||||
|
|||||||
Reference in new issue
Block a user