Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: element2.getAttribute is not a function #15336

Closed
hyunbinseo opened this issue Feb 19, 2025 · 3 comments
Closed

TypeError: element2.getAttribute is not a function #15336

hyunbinseo opened this issue Feb 19, 2025 · 3 comments

Comments

@hyunbinseo
Copy link
Contributor

hyunbinseo commented Feb 19, 2025

Note

If you face similar issue, please comment on #15337

Describe the bug

On an existing, working SvelteKit project without any errors, this suddenly happens in the browser:

Caution

Uncaught (in promise) TypeError: element2.getAttribute is not a function

/**
 * @param {Element} element
 * @param {string} attribute
 * @param {string | null} value
 * @param {boolean} [skip_warning]
 */
export function set_attribute(element, attribute, value, skip_warning) {
	// @ts-expect-error
	var attributes = (element.__attributes ??= {});

	if (hydrating) {
		attributes[attribute] = element.getAttribute(attribute); // here
  in +layout.svelte
  in root.svelte
    set_attribute attributes.js:154
    _layout +layout.svelte:48
    head svelte-head.js:59
    update_reaction runtime.js:427

    (omitted below)

This happens on both macOS and Windows.

This is not fixed with

  • disabling browser cache or using the incognito tab
  • trying another browser (e.g. Chrome instead of Firefox)
  • deleting node_modules/.vite and restarting dev server
  • removing node_modules and reinstalling dependencies
  • re-cloning the project and starting fresh

Reproduction

Cannot provide reproduction (yet)

System Info

System:
  OS: Windows 11 10.0.26100
  CPU: (8) x64 Intel(R) Core(TM) Ultra 7 258V
  Memory: 9.05 GB / 31.51 GB
Binaries:
  Node: 22.14.0 - ~\AppData\Local\fnm_multishells\160156_1739934653049\node.EXE
  npm: 10.9.2 - ~\AppData\Local\fnm_multishells\160156_1739934653049\npm.CMD   
  pnpm: 10.3.0 - ~\AppData\Local\fnm_multishells\160156_1739934653049\pnpm.CMD 
Browsers:
  Edge: Chromium (131.0.2903.112)

Severity

blocking all usage of svelte

@hyunbinseo hyunbinseo changed the title element2.getAttribute is not a function TypeError: element2.getAttribute is not a function Feb 19, 2025
@hyunbinseo
Copy link
Contributor Author

hyunbinseo commented Feb 19, 2025

Clearing pnpm store does not work:

pnpm store prune
# Removed all cached metadata files
# Removed 5948 files
# Removed 195 packages

Remove-Item -Path "node_modules" -Recurse -Force
Remove-Item -Path ".svelte-kit" -Recurse -Force

pnpm i --force
#  WARN  using --force I sure hope you know what you are doing
# Lockfile is up to date, resolution step is skipped
# Packages: +431

pnpm dev

Using a different version of Svelte does not work:

pnpm update svelte
# - svelte 5.19.10
# + svelte 5.20.2

pnpm dev

Using npm does not work:

npm i
npm run dev

Changing the port number does not work:

vite dev --port 4173

@bobvork
Copy link

bobvork commented Feb 20, 2025

I'm having the same issue, and am similarly puzzled as to what's causing this. I've tried the same steps as mentioned in #15337. I also went back a few svelte versions just to be sure.

In my case, this seems to be triggered in a component, but only if I refresh the page. When the component becomes visible through the state it's fine.
I'll see if I can create a reproducible project from this and report back if I can find more info

@hyunbinseo
Copy link
Contributor Author

@bobvork Thanks for sharing your experience. Could you leave a comment on #15337 as well?

This issue was rushed and I should have put more thought on it before creating it.

I have updated this issue's introduction to guide users to #15337 as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants