diff options
| author | Joris | 2025-04-09 22:34:08 +0200 | 
|---|---|---|
| committer | Joris | 2025-04-09 22:34:08 +0200 | 
| commit | b20c50b4beafa2bd3ebc8be6cab66f6012bc59ef (patch) | |
| tree | 24efcd256315f2ae82a6b623decf555b8aece703 /src | |
| parent | 6b59fe02b72f2bcd034ffb405e0d4b0ccedd8920 (diff) | |
Use correct element in setAttribute
Diffstat (limited to 'src')
| -rw-r--r-- | src/rx.ts | 12 | 
1 files changed, 5 insertions, 7 deletions
| @@ -485,9 +485,9 @@ function appendChild(state: State, element: Element, child: Html, lastAdded?: No      const cancelAttributes = Object.entries(attributes).map(([key, value]) => {        if (isRx<AttributeValue>(value)) { -        return rxRun(state, value, newValue => setAttribute(state, setAttr, element, key, newValue)) +        return rxRun(state, value, newValue => setAttribute(setAttr, childElement, key, newValue))        } else { -        setAttribute(state, setAttr, element, key, value) +        setAttribute(setAttr, childElement, key, value)        }      }) @@ -659,7 +659,7 @@ function appendChild(state: State, element: Element, child: Html, lastAdded?: No    }  } -const svgElements = ['svg', 'circle', 'polygon', 'line', 'rect', 'ellipse', 'text'] +const svgElements = ['svg', 'circle', 'polygon', 'line', 'rect', 'ellipse', 'text', 'path']  function isSvg(tagName: string): boolean {      return !(svgElements.indexOf(tagName) === -1)  } @@ -700,16 +700,14 @@ function appendNode(base: Element, node: Node, lastAdded?: Node) {    }  } -function setAttribute(state: State, setAttr: (key: any, value: any) => void, element: Element, key: string, attribute: AttributeValue) { +function setAttribute(setAttr: (key: any, value: any) => void, element: Element, key: string, attribute: AttributeValue) {    if (attribute === undefined) {      // Do nothing    } else if (attribute === true) {      setAttr(key, 'true')    } else if (attribute === false) {      // @ts-ignore -    if (key in element) { -      setAttr(key, false) -    } +    if (key in element) setAttr(key, false)    } else if (typeof attribute === "number") {      setAttr(key, attribute.toString())    } else if (typeof attribute === "string") { | 
