Fix preloading setup bug.

This commit is contained in:
Dillon Kearns 2019-09-17 09:40:35 -07:00
parent 0b7eb041b9
commit 4b9b3a5a3b
2 changed files with 12 additions and 16 deletions

View File

@ -5,6 +5,7 @@ import Browser.Navigation
import Dict exposing (Dict) import Dict exposing (Dict)
import Head import Head
import Html exposing (Html) import Html exposing (Html)
import Html.Attributes
import Http import Http
import Json.Decode import Json.Decode
import Json.Encode import Json.Encode
@ -120,8 +121,12 @@ view pathKey content pageView model =
in in
{ title = title { title = title
, body = , body =
[ body [ Html.div
|> Html.map UserMsg [ Html.Attributes.attribute "data-url" (Url.toString model.url)
]
[ body
|> Html.map UserMsg
]
] ]
} }
@ -282,11 +287,7 @@ update toJsPort document userUpdate msg model =
-- to keep track of the last url change -- to keep track of the last url change
Ok updatedCache -> Ok updatedCache ->
( { model | url = url, contentCache = updatedCache } ( { model | url = url, contentCache = updatedCache }
, toJsPort , Cmd.none
(Json.Encode.object
[ ( "event", Json.Encode.string "page-changed" )
]
)
) )
Err _ -> Err _ ->

View File

@ -46,10 +46,6 @@ module.exports = function pagesInit(
) { ) {
for (let mutation of mutationList) { for (let mutation of mutationList) {
if (mutation.type === "childList") { if (mutation.type === "childList") {
console.log(
"Setting up prefetch links for ",
mutation.target.attributes["data-url"]
);
setupLinkPrefetchingHelp(); setupLinkPrefetchingHelp();
} }
} }
@ -65,11 +61,10 @@ module.exports = function pagesInit(
/** @type {MutationObserver} */ _theObserver /** @type {MutationObserver} */ _theObserver
) { ) {
for (let mutation of mutationList) { for (let mutation of mutationList) {
if (mutation.type === "attributes") { if (
console.log( mutation.type === "attributes" &&
"Setting up prefetch links for ", mutation.attributeName === "data-url"
mutation.target.attributes["data-url"] ) {
);
setupLinkPrefetchingHelp(); setupLinkPrefetchingHelp();
} }
} }