Skip to content

Commit 0de90f9

Browse files
zaaackalfonsogarciacaro
authored andcommitted
Fix netstandard1.6 & style mismatch with client
1 parent 4dec6b9 commit 0de90f9

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

src/Fable.React/Fable.Helpers.React.fs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,13 +783,21 @@ module ServerRenderingInternal =
783783
| ServerElementType.Component ->
784784
let tag = tag :?> System.Type
785785
let comp = System.Activator.CreateInstance(tag, props)
786+
#if NETSTANDARD1_6
787+
let tag = tag.GetTypeInfo()
788+
#endif
786789
let childrenProp = tag.GetProperty(ChildrenName)
787790
childrenProp.SetValue(comp, children |> Seq.toArray)
788791
let render = tag.GetMethod("render")
789792
render.Invoke(comp, null) :?> ReactElement
790793

791794
let createServerElementByFn = fun (f, props, children) ->
795+
#if NETSTANDARD1_6
796+
let propsType' = props.GetType()
797+
let propsType = propsType'.GetTypeInfo()
798+
#else
792799
let propsType = props.GetType()
800+
#endif
793801
let props =
794802
if propsType.GetProperty (ChildrenName) |> isNull then
795803
props
@@ -801,6 +809,9 @@ module ServerRenderingInternal =
801809
values.Add (children |> Seq.toArray)
802810
else
803811
values.Add (FSharpValue.GetRecordField(props, p))
812+
#if NETSTANDARD1_6
813+
let propsType = propsType'
814+
#endif
804815
FSharpValue.MakeRecord(propsType, values.ToArray()) :?> 'P
805816
f props
806817

src/Fable.React/Fable.Helpers.ReactServer.fs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ let private cssProp (html:StringBuilder) (key: string) (value: obj) =
3737
match value with
3838
| :? int as v -> addUnit html key (string v)
3939
| :? float as v -> addUnit html key (string v)
40-
| _ -> html.Append value |> ignore
40+
| _ -> escapeHtml html (value.ToString()) |> ignore
4141

4242
html.Append ';' |> ignore
4343

@@ -615,7 +615,8 @@ let private renderHtmlAttr (html:StringBuilder) (attr: HTMLAttr) =
615615

616616
for cssProp in cssList do
617617
renderCssProp html cssProp
618-
618+
if not(List.isEmpty cssList) then
619+
html.Remove (html.Length - 1, 1) |> ignore
619620
html.Append '"' |> ignore
620621

621622
| HTMLAttr.Custom (key, value) -> strAttr html (key.ToLower()) (string value)

src/Fable.React/Fable.React.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Project Sdk="Microsoft.NET.Sdk">
33
<PropertyGroup>
44
<Version>3.1.0</Version>
5-
<TargetFramework>netstandard1.6</TargetFramework>
5+
<TargetFrameworks>netstandard1.6;netstandard2.0</TargetFrameworks>
66
</PropertyGroup>
77
<ItemGroup>
88
<Compile Include="Fable.Import.React.fs" />

0 commit comments

Comments
 (0)