-
Notifications
You must be signed in to change notification settings - Fork 374
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Always apply jsAttributes to scritps in body (#1836)
* breadcrumb test should be in cabal * failing test for jsAttributes * also apply jsAttributes to scripts without a location the location is only set if cached by addStaticContent * bump version number * add changelog
- Loading branch information
Showing
5 changed files
with
47 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{-# LANGUAGE QuasiQuotes, TypeFamilies, TemplateHaskell, MultiParamTypeClasses #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE FlexibleInstances #-} | ||
module YesodCoreTest.JsAttributes | ||
( specs | ||
-- To avoid unused warning | ||
, Widget | ||
, resourcesApp | ||
) where | ||
|
||
import Test.Hspec | ||
|
||
import Yesod.Core | ||
import Network.Wai.Test | ||
|
||
data App = App | ||
mkYesod "App" [parseRoutes| | ||
/ HeadR GET | ||
|] | ||
instance Yesod App where | ||
jsAttributes _ = [("attr0", "a")] | ||
|
||
getHeadR :: Handler Html | ||
getHeadR = defaultLayout $ do | ||
addScriptRemote "load.js" | ||
toWidget [julius|/*body*/|] | ||
toWidgetHead [julius|/*head*/|] | ||
|
||
specs :: Spec | ||
specs = describe "Test.JsAttributes" $ do | ||
it "script in body gets attributes" $ runner App $ do | ||
res <- request defaultRequest | ||
assertBody "<!DOCTYPE html>\n<html><head><title></title><script>/*head*/</script></head><body><script src=\"load.js\"></script><script attr0=\"a\">/*body*/</script></body></html>" res | ||
|
||
runner :: YesodDispatch master => master -> Session () -> IO () | ||
runner app f = toWaiApp app >>= runSession f | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters