fix: add ns param for removeAttribute

This commit is contained in:
Shuanghui Yan committed 2022-02-22 23:14:11 +08:00
1 parent d19ae3ff56
commit 4eeb3da8c9
4 files changed
+23 -11

No files matched your search

+1 -1
View File
@@ -63,5 +63,5 @@ extern "C" {
);
#[wasm_bindgen(method)]
pub fn RemoveAttribute(this: &Interpreter, root: u64, field: &str);
pub fn RemoveAttribute(this: &Interpreter, root: u64, field: &str, ns: Option<&str>);
}
+8 -6
View File
@@ -105,7 +105,7 @@ export class Interpreter {
if (ns === "style") {
// @ts-ignore
node.style[name] = value;
} else if (ns != null || ns != undefined) {
} else if (ns !== null || ns !== undefined) {
node.setAttributeNS(ns, name, value);
} else {
switch (name) {
@@ -133,10 +133,12 @@ export class Interpreter {
}
}
}
RemoveAttribute(root, name) {
RemoveAttribute(root, field, ns) {
const name = field;
const node = this.nodes[root];
if (name === "value") {
if (ns !== null || ns !== undefined) {
node.removeAttributeNS(ns, name);
} else if (name === "value") {
node.value = "";
} else if (name === "checked") {
node.checked = false;
@@ -260,7 +262,7 @@ export class Interpreter {
}
}
if (realId == null) {
if (realId === null) {
return;
}
window.ipc.postMessage(
@@ -281,7 +283,7 @@ export class Interpreter {
this.SetAttribute(edit.root, edit.field, edit.value, edit.ns);
break;
case "RemoveAttribute":
this.RemoveAttribute(edit.root, edit.name);
this.RemoveAttribute(edit.root, edit.name, edit.ns);
break;
}
}