Skip to content

Commit

Permalink
[#181] Don't re-add a class with AddClass if it's already there
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarmil committed Jul 12, 2018
1 parent 4a04eee commit ac8bee1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions WebSharper.UI/Doc.Proxy.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1100,8 +1100,13 @@ and [<JavaScript; Proxy(typeof<Elt>); Name "WebSharper.UI.Elt">]
member this.GetProperty'(name: string) : 'T =
elt?(name)

[<Name "AddClass"; Direct "$this.elt.className += ' ' + $cls">]
member this.AddClass'(cls: string) = X<unit>
[<Name "AddClass">]
member this.AddClass'(cls: string) =
let c = elt?className
if c = "" then
elt?className <- cls
elif not <| (clsRE cls).Test(c) then
elt?className <- elt?className + " " + cls

[<Name "RemoveClass">]
member this.RemoveClass'(cls: string) =
Expand Down

0 comments on commit ac8bee1

Please sign in to comment.