summaryrefslogtreecommitdiff
path: root/Miso/Extend.hs
blob: e7a9ff634bf7fbda64a934fcaf9cc890767ebdc0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
{-# LANGUAGE OverloadedStrings #-}

module Miso.Extend
  ( crossorigin_,
    onPreventClick,
  )
where

import Miso
import Miso.String

-- | HTML crossorigin attribute
--
-- https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin
crossorigin_ :: MisoString -> Attribute action
crossorigin_ = textProp "crossorigin"

-- | Like 'onClick' but prevents the default action from triggering. Use this to
-- overide 'a_' links, for example.
onPreventClick :: action -> Attribute action
onPreventClick action =
  onWithOptions
    Miso.defaultOptions {preventDefault = True}
    "click"
    emptyDecoder
    (\() -> action)