Skip to content

Commit

Permalink
Collapse class properties.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmjio committed Jul 5, 2020
1 parent d81a011 commit bb23019
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ghc-src/Miso/Html/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@ module Miso.Html.Internal (
, onBeforeDestroyed
) where

import Data.Aeson (Value(..), ToJSON(..))
import Data.Aeson (Value(..), ToJSON(..))
import qualified Data.Map as M
import Data.Proxy
import Data.String (IsString(..))
import qualified Data.Text as T
import qualified Data.Vector as V
import qualified Lucid as L
import qualified Lucid.Base as L
import Prelude hiding (null)
import Servant.API

import Miso.Event
Expand Down Expand Up @@ -186,7 +187,12 @@ data NS
-- | `VNode` creation
node :: NS -> MisoString -> Maybe Key -> [Attribute action] -> [View action] -> View action
node vNs vType vKey as xs =
let vProps = Props $ M.fromList [ (k,v) | P k v <- as ]
let classes = intercalate " " [ v | P "class" (String v) <- as ]
vProps = Props $ do
let propClass = M.fromList [ (k,v) | P k v <- as ]
if not (null classes)
then M.insert "class" (String classes) propClass
else propClass
vChildren = V.fromList $ map runView xs
in View VNode {..}

Expand Down

0 comments on commit bb23019

Please sign in to comment.