|
For inserting raw html, I don’t like the way it is built into the tags bindings, with I tried to reproduce it with Oxpecker bindings : namespace Oxpecker.Solid
open Fable.Core
open Oxpecker.Solid
open Browser.Types
[<AutoOpen>]
[<Erase>]
type Bindings =
[<Import("template", "solid-js/web")>]
static member solidTemplate(t: string, ?n: int) : HTMLElement = jsNative
[<AutoOpen>]
module Tags =
[<SolidComponent>]
let RawNode (node: Node) : HtmlElement =
let mutable el: Node = Unchecked.defaultof<_>
onMount (fun () -> el.parentNode.replaceChild (node, el) |> ignore)
template().ref (fun e -> el <- e)
[<SolidComponent>]
let RawHtmlNode (t: string) : HtmlElement =
(solidTemplate t).cloneNode true |> RawNodeIt works as is, but is there is a better, more cleaner approach than direct dom manipulation ? |
Answered by
Lanayx
Feb 24, 2025
Replies: 2 comments 1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@fradav as Oxpecker.Solid is a Solid.js wrapper, all it's benefits and quirks are in place, so workarounds are also the same :) I personally use innerHTML everywhere and additional dom node doesn't get in a way.