Skip to content

Commit 4c8fea7

Browse files
committed
Add spread functionality pending fable-compiler/Fable#4038
1 parent 2730fec commit 4c8fea7

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/Oxpecker.Solid.FablePlugin/Library.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ module internal rec AST =
205205
| "bool", EventHandler(eventName, handler) -> ("bool:" + eventName, handler) :: restResults
206206
| "data", EventHandler(eventName, handler) -> ("data-" + eventName, handler) :: restResults
207207
| "attr", EventHandler(eventName, handler) -> (eventName, handler) :: restResults
208+
| "spread", { Args = [ _; identExpr ] } -> ("__SPREAD_PROPERTY__", identExpr) :: restResults
208209
| "ref", { Args = [ _; identExpr ] } -> ("ref", identExpr) :: restResults
209210
| "style'", { Args = [ _; identExpr ] } -> ("style", identExpr) :: restResults
210211
| "classList", { Args = [ _; identExpr ] } -> ("classList", identExpr) :: restResults

src/Oxpecker.Solid/Tags.fs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ module Tags =
2323
[<Extension; Erase>]
2424
static member attr(this: #HtmlTag, name: string, value: string) = this
2525

26+
/// Applies JS Object Spread to the given value within the given element. Care must be taken to provide valid
27+
/// objects. Mostly used to pass on properties in bindings/imports to nested children.
28+
[<Extension; Erase>]
29+
static member spread(this: #HtmlTag, value: 'T) = this
30+
2631
/// Add event handler to the element through the corresponding attribute
2732
[<Extension; Erase>]
2833
static member on(this: #HtmlTag, eventName: string, eventHandler: Event -> unit) = this

0 commit comments

Comments
 (0)