up.navigate() docs suggest I can omit the URL and use the main target, but that throws an error · Issue #268 · unpoly/unpoly · GitHub
Skip to content

up.navigate() docs suggest I can omit the URL and use the main target, but that throws an error #268

Open

Description

@kezabelle

Given a setup like so, to emulate turbolinks:

<script src="https://unpkg.com/unpoly@2.2.1/unpoly.js"></script>
    <script>
        up.log.enable();
        up.link.config.followSelectors.push('a[href]');
        up.form.config.submitSelectors.push('form');
    </script>

I end up with what I presume is main target of body, because that gets augmented with up-source='/..../.

If I then try and use up.navigate() in the console, as a vague facsimile to window.location.reload() it errors like so:

> up.render() needs either { url, content, fragment, document } option
> Uncaught (in promise) up.Failed: up.render() needs either { url, content, fragment, document } option
    at build (https://unpkg.com/unpoly@2.2.1/unpoly.js:2038:23)
    at Object.fn [as failed] (https://unpkg.com/unpoly@2.2.1/unpoly.js:2047:27)
    at Object.fail (https://unpkg.com/unpoly@2.2.1/unpoly.js:12079:24)
    at Object.assertContentGiven (https://unpkg.com/unpoly@2.2.1/unpoly.js:8641:20)
    at https://unpkg.com/unpoly@2.2.1/unpoly.js:13529:30
    at Object.asyncify (https://unpkg.com/unpoly@2.2.1/unpoly.js:1585:36)
    at https://unpkg.com/unpoly@2.2.1/unpoly.js:13515:18
    at mockableFn (https://unpkg.com/unpoly@2.2.1/unpoly.js:22:36)
    at https://unpkg.com/unpoly@2.2.1/unpoly.js:13579:16
    at Object.mockableFn [as navigate] (https://unpkg.com/unpoly@2.2.1/unpoly.js:22:36)
> 

which, I guess, makes sense. It needs a URL, same as the contract for up.visit(url). But the documentation (for 2.2) for up.navigate(target, options) says of target If omitted a main target will be rendered. Meanwhile, up.reload() works fine for the purposes of refreshing the body fragment (the main target?), but didn't achieve the results I was hoping for because the <title>...</title> doesn't get updated (I guess because it doesn't count as a navigation option, hence the dive into navigate()

(Edit: immediately after opening this I note that I can just use up.reload({navigate: true}) for my purposes, but I think issue around navigate without a target may still be relevant)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions