mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2025-01-06 22:39:41 +03:00
Fix preloading setup bug.
This commit is contained in:
parent
0b7eb041b9
commit
4b9b3a5a3b
@ -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 _ ->
|
||||
|
13
index.js
13
index.js
@ -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();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user