Merge pull request #103 from mrxiaozhuox/boolattrs-limit-type
Boolattrs limit type
This commit is contained in:
3 files changed
+69
-3
No files matched your search
@@ -18,6 +18,11 @@ fn app(cx: Scope) -> Element {
|
||||
disabled: "{disabled}",
|
||||
"lower button"
|
||||
}
|
||||
|
||||
input {
|
||||
value: "false",
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -1,3 +1,32 @@
|
||||
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",
|
||||
]
|
||||
|
||||
function serialize_event(event) {
|
||||
switch (event.type) {
|
||||
case "copy":
|
||||
@@ -370,7 +399,7 @@ class Interpreter {
|
||||
break;
|
||||
default:
|
||||
// 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);
|
||||
|
||||
+34
-2
@@ -349,9 +349,41 @@ impl WebsysDom {
|
||||
}
|
||||
_ => {
|
||||
// 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" {
|
||||
if let Some(el) = node.dyn_ref::<Element>() {
|
||||
let _ = el.remove_attribute(name);
|
||||
match name {
|
||||
"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" => {
|
||||
let _ = el.remove_attribute(name);
|
||||
}
|
||||
_ => {
|
||||
let _ = el.set_attribute(name, value);
|
||||
}
|
||||
};
|
||||
}
|
||||
} else {
|
||||
fallback();
|
||||
|
||||
Reference in new issue
Block a user