Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.

fix(nuxt): update head entry when speculation rules are updated - #9472

Merged
pi0 merged 1 commit into
mainfrom
fix/reactive-speculation-rules
Dec 5, 2022
Merged

fix(nuxt): update head entry when speculation rules are updated#9472
pi0 merged 1 commit into
mainfrom
fix/reactive-speculation-rules

Conversation

@danielroe

Copy link
Copy Markdown
Member

🔗 Linked issue

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

Previously new crossorigin prefetches were not being injected into the head as it was not reactive outside a vue component. This PR fixes that by manually calling patch when necessary.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@danielroe danielroe added bug Something isn't working 🔨 p3-minor-bug Priority 3: a bug in an edge case that only affects very specific usage labels Dec 2, 2022
@danielroe danielroe self-assigned this Dec 2, 2022
@codesandbox

codesandbox Bot commented Dec 2, 2022

Copy link
Copy Markdown

CodeSandbox logoCodeSandbox logo  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@danielroe
danielroe requested review from harlan-zw and pi0 December 3, 2022 15:11
Comment thread packages/nuxt/src/app/plugins/cross-origin-prefetch.client.ts
@harlan-zw

harlan-zw commented Dec 4, 2022

Copy link
Copy Markdown
Collaborator

TIL nav speculation API is a thing, looks quite interesting.

Just an FYI, with unhead 1.0.7, innerHTML objects are automatically JSON stringified, have also exported the SpeculationRules schema.

import type { SpeculationRules } from '@unhead/schema'

useHead({
  script: [
    {
      type: 'speculationrules',
      innerHTML: <SpeculationRules> {
        prefetch: [
          {
            source: 'list',
            urls: [...externalURLs.value],
            requires: ['anonymous-client-ip-when-cross-origin'],
          },
        ],
      },
    },
  ]
})

@pi0
pi0 merged commit 5fe7c1c into main Dec 5, 2022
@pi0
pi0 deleted the fix/reactive-speculation-rules branch December 5, 2022 10:46
@pi0 pi0 mentioned this pull request Dec 15, 2022
6 tasks
@danielroe danielroe added the 3.x label Jan 19, 2023
@danielroe danielroe mentioned this pull request Jan 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

3.x bug Something isn't working 🔨 p3-minor-bug Priority 3: a bug in an edge case that only affects very specific usage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants