mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-23 04:33:06 +00:00
feat: bool attr white list
This commit is contained in:
parent
4f1894ff5c
commit
8f4aa84f1a
3 changed files with 67 additions and 2 deletions
|
@ -18,6 +18,11 @@ fn app(cx: Scope) -> Element {
|
|||
disabled: "{disabled}",
|
||||
"lower button"
|
||||
}
|
||||
|
||||
input {
|
||||
value: "false",
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -369,8 +369,38 @@ class Interpreter {
|
|||
node.innerHTML = value;
|
||||
break;
|
||||
default:
|
||||
|
||||
const bool_attrs = [
|
||||
"allowfullscreen",
|
||||
"allowpaymentrequest",
|
||||
"async",
|
||||
"autofocus",
|
||||
"autoplay",
|
||||
"checked",
|
||||
"controls",
|
||||
"default",
|
||||
"defer",
|
||||
"disabled",
|
||||
"formnovalidate",
|
||||
"hidden",
|
||||
"ismap",
|
||||
"itemscope",
|
||||
"loop",
|
||||
"multiple",
|
||||
"muted",
|
||||
"nomodule",
|
||||
"novalidate",
|
||||
"open",
|
||||
"playsinline",
|
||||
"readonly",
|
||||
"required",
|
||||
"reversed",
|
||||
"selected",
|
||||
"truespeed",
|
||||
]
|
||||
|
||||
// https://github.com/facebook/react/blob/8b88ac2592c5f555f315f9440cbb665dd1e7457a/packages/react-dom/src/shared/DOMProperty.js#L352-L364
|
||||
if (value == "false" && name != "capture" && name != "download") {
|
||||
if (value == "false" && bool_attrs.indexOf(name)) {
|
||||
node.removeAttribute(name);
|
||||
} else {
|
||||
node.setAttribute(name, value);
|
||||
|
|
|
@ -348,8 +348,38 @@ impl WebsysDom {
|
|||
}
|
||||
}
|
||||
_ => {
|
||||
|
||||
let bool_attrs = vec![
|
||||
"allowfullscreen",
|
||||
"allowpaymentrequest",
|
||||
"async",
|
||||
"autofocus",
|
||||
"autoplay",
|
||||
"checked",
|
||||
"controls",
|
||||
"default",
|
||||
"defer",
|
||||
"disabled",
|
||||
"formnovalidate",
|
||||
"hidden",
|
||||
"ismap",
|
||||
"itemscope",
|
||||
"loop",
|
||||
"multiple",
|
||||
"muted",
|
||||
"nomodule",
|
||||
"novalidate",
|
||||
"open",
|
||||
"playsinline",
|
||||
"readonly",
|
||||
"required",
|
||||
"reversed",
|
||||
"selected",
|
||||
"truespeed",
|
||||
];
|
||||
|
||||
// https://github.com/facebook/react/blob/8b88ac2592c5f555f315f9440cbb665dd1e7457a/packages/react-dom/src/shared/DOMProperty.js#L352-L364
|
||||
if value == "false" && ((name != "capture") && (name != "download")) {
|
||||
if value == "false" && bool_attrs.contains(&name) {
|
||||
if let Some(el) = node.dyn_ref::<Element>() {
|
||||
let _ = el.remove_attribute(name);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue