diff options
| author | Joris | 2023-02-13 15:14:26 +0100 | 
|---|---|---|
| committer | Joris | 2023-02-13 21:32:29 +0100 | 
| commit | 4c8aabecf9f9db9f9427ec7bca5cc52c99128c44 (patch) | |
| tree | ab648c8132f01adbb037041c0b657c242aa89ee8 | |
| parent | 4fb4e101b671056affc6cc67e4670709e36b89c1 (diff) | |
Accept attribute undefined
| -rw-r--r-- | src/rx.ts | 17 | 
1 files changed, 9 insertions, 8 deletions
@@ -32,7 +32,8 @@ interface Attributes {  }  type AttributeValue -  = string +  = undefined +  | string    | number    | boolean    | ((event: Event) => void) @@ -386,15 +387,15 @@ function appendNode(base: Element, node: Node, lastAdded?: Node) {  }  function setAttribute(state: State, element: Element, key: string, attribute: AttributeValue) { -  if (typeof attribute == "boolean") { -    if (attribute) { -      // @ts-ignore -      element[key] = "true" -    } -  } else if (typeof attribute == "number") { +  if (attribute === undefined || attribute === false) { +    // Do nothing +  } else if (attribute === true) { +    // @ts-ignore +    element[key] = "true" +  } else if (typeof attribute === "number") {      // @ts-ignore      element[key] = attribute.toString() -  } else if (typeof attribute == "string") { +  } else if (typeof attribute === "string") {      // @ts-ignore      element[key] = attribute    } else {  | 
