mirror of
https://github.com/DioxusLabs/dioxus
synced 2025-02-17 06:08:26 +00:00
fix: add ns param for removeAttribute
This commit is contained in:
parent
d19ae3ff56
commit
4eeb3da8c9
4 changed files with 23 additions and 11 deletions
|
@ -107,6 +107,7 @@ pub enum DomEdit<'bump> {
|
||||||
RemoveAttribute {
|
RemoveAttribute {
|
||||||
root: u64,
|
root: u64,
|
||||||
name: &'static str,
|
name: &'static str,
|
||||||
|
ns: Option<&'bump str>,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,8 +219,17 @@ impl<'a> Mutations<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn remove_attribute(&mut self, attribute: &Attribute, root: u64) {
|
pub(crate) fn remove_attribute(&mut self, attribute: &Attribute, root: u64) {
|
||||||
let name = attribute.name;
|
let Attribute {
|
||||||
self.edits.push(RemoveAttribute { name, root });
|
name,
|
||||||
|
namespace,
|
||||||
|
..
|
||||||
|
} = attribute;
|
||||||
|
|
||||||
|
self.edits.push(RemoveAttribute {
|
||||||
|
name,
|
||||||
|
ns: *namespace,
|
||||||
|
root
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn mark_dirty_scope(&mut self, scope: ScopeId) {
|
pub(crate) fn mark_dirty_scope(&mut self, scope: ScopeId) {
|
||||||
|
|
|
@ -63,5 +63,5 @@ extern "C" {
|
||||||
);
|
);
|
||||||
|
|
||||||
#[wasm_bindgen(method)]
|
#[wasm_bindgen(method)]
|
||||||
pub fn RemoveAttribute(this: &Interpreter, root: u64, field: &str);
|
pub fn RemoveAttribute(this: &Interpreter, root: u64, field: &str, ns: Option<&str>);
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ export class Interpreter {
|
||||||
if (ns === "style") {
|
if (ns === "style") {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
node.style[name] = value;
|
node.style[name] = value;
|
||||||
} else if (ns != null || ns != undefined) {
|
} else if (ns !== null || ns !== undefined) {
|
||||||
node.setAttributeNS(ns, name, value);
|
node.setAttributeNS(ns, name, value);
|
||||||
} else {
|
} else {
|
||||||
switch (name) {
|
switch (name) {
|
||||||
|
@ -133,10 +133,12 @@ export class Interpreter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RemoveAttribute(root, name) {
|
RemoveAttribute(root, field, ns) {
|
||||||
|
const name = field;
|
||||||
const node = this.nodes[root];
|
const node = this.nodes[root];
|
||||||
|
if (ns !== null || ns !== undefined) {
|
||||||
if (name === "value") {
|
node.removeAttributeNS(ns, name);
|
||||||
|
} else if (name === "value") {
|
||||||
node.value = "";
|
node.value = "";
|
||||||
} else if (name === "checked") {
|
} else if (name === "checked") {
|
||||||
node.checked = false;
|
node.checked = false;
|
||||||
|
@ -260,7 +262,7 @@ export class Interpreter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (realId == null) {
|
if (realId === null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
window.ipc.postMessage(
|
window.ipc.postMessage(
|
||||||
|
@ -281,7 +283,7 @@ export class Interpreter {
|
||||||
this.SetAttribute(edit.root, edit.field, edit.value, edit.ns);
|
this.SetAttribute(edit.root, edit.field, edit.value, edit.ns);
|
||||||
break;
|
break;
|
||||||
case "RemoveAttribute":
|
case "RemoveAttribute":
|
||||||
this.RemoveAttribute(edit.root, edit.name);
|
this.RemoveAttribute(edit.root, edit.name, edit.ns);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,8 +127,8 @@ impl WebsysDom {
|
||||||
self.interpreter.RemoveEventListener(root, event)
|
self.interpreter.RemoveEventListener(root, event)
|
||||||
}
|
}
|
||||||
|
|
||||||
DomEdit::RemoveAttribute { root, name } => {
|
DomEdit::RemoveAttribute { root, name, ns } => {
|
||||||
self.interpreter.RemoveAttribute(root, name)
|
self.interpreter.RemoveAttribute(root, name, ns)
|
||||||
}
|
}
|
||||||
|
|
||||||
DomEdit::CreateTextNode { text, root } => {
|
DomEdit::CreateTextNode { text, root } => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue