Skip to content

getContext is undefined when called inside an element attribute. #7549

Closed
@schurhammer

Description

@schurhammer

Describe the bug

I have some text put into the context of a page. When reading it with getContext in a child component into the href of a link, the value is undefined.

The SSR handles it as expected but in the client it becomes undefined (only during hydration I think, not sure).

Note that it is only undefined when called inside an href or other html attribute. When called as part of some text it is the expected value.

Reproduction

https://github.com/schurhammer/sveltekit-context-bug

Logs

Server logs
example
example

Browser logs
Test.svelte? [sm]:5 example
Test.svelte? [sm]:5 undefined

System Info

System:
    OS: Linux 5.15 Manjaro Linux
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
    Memory: 9.27 GB / 31.04 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 16.13.2 - ~/.nvm/versions/node/v16.13.2/bin/node
    npm: 8.1.2 - ~/.nvm/versions/node/v16.13.2/bin/npm
  Browsers:
    Chromium: 101.0.4951.54
    Firefox: 100.0
  npmPackages:
    @sveltejs/adapter-node: next => 1.0.0-next.73 
    @sveltejs/kit: next => 1.0.0-next.335 
    svelte: ^3.44.0 => 3.48.0

Severity

serious, but I can work around it

Additional Information

No response

Metadata

Metadata

Assignees

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