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 Head
import Html exposing (Html)
import Html.Attributes
import Http
import Json.Decode
import Json.Encode
@ -120,8 +121,12 @@ view pathKey content pageView model =
in
{ title = title
, body =
[ body
|> Html.map UserMsg
[ Html.div
[ 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
Ok updatedCache ->
( { model | url = url, contentCache = updatedCache }
, toJsPort
(Json.Encode.object
[ ( "event", Json.Encode.string "page-changed" )
]
)
, Cmd.none
)
Err _ ->

View File

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