mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2025-01-08 07:29:08 +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 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 _ ->
|
||||||
|
13
index.js
13
index.js
@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user