diff --git a/yesod-core/src/Yesod/Core/Class/Yesod.hs b/yesod-core/src/Yesod/Core/Class/Yesod.hs index b6886c70..fde5d476 100644 --- a/yesod-core/src/Yesod/Core/Class/Yesod.hs +++ b/yesod-core/src/Yesod/Core/Class/Yesod.hs @@ -252,13 +252,12 @@ class RenderRoute site => Yesod site where -- | Same as @jsAttributes@ but allows you to run arbitrary Handler code -- -- This is useful if you need to add a randomised nonce value to the script - -- tag generated by @widgetFile@. If you use both this function and - -- @jsAttributes@, the two attribute maps will be merged, favouring the - -- keys from @jsAttributes@ in case of a collision. + -- tag generated by @widgetFile@. If this function is overridden then + -- @jsAttributes@ is ignored. -- -- @since 1.6.16 jsAttributesHandler :: HandlerFor site [(Text, Text)] - jsAttributesHandler = pure [] + jsAttributesHandler = getYesod >>= return . jsAttributes -- | Create a session backend. Returning 'Nothing' disables -- sessions. If you'd like to change the way that the session @@ -532,7 +531,7 @@ widgetToPageContent :: Yesod site => WidgetFor site () -> HandlerFor site (PageContent (Route site)) widgetToPageContent w = do - jsAttrsFromHandler <- jsAttributesHandler + jsAttrs <- jsAttributesHandler HandlerFor $ \hd -> do master <- unHandlerFor getYesod hd ref <- newIORef mempty @@ -544,10 +543,6 @@ widgetToPageContent w = do let title = maybe mempty unTitle mTitle scripts = runUniqueList scripts' stylesheets = runUniqueList stylesheets' - jsAttrs = - let jsAttrsStatic = Map.fromList (jsAttributes master) - jsAttrsDynamic = Map.fromList jsAttrsFromHandler - in Map.toList $ Map.union jsAttrsStatic jsAttrsDynamic flip unHandlerFor hd $ do render <- getUrlRenderParams