Skip to content

web/polyfill: polyfill customElements.getName for Safari < 17.4 - #22940

Merged
PeshekDotDev merged 3 commits into
mainfrom
issue-22611-window-customelements-getname-is-not-a
Jun 9, 2026
Merged

PeshekDotDev merged 3 commits into
mainfrom
issue-22611-window-customelements-getname-is-not-a

Conversation

@GirlBossRush

Copy link
Copy Markdown
Contributor

What

window.customElements.getName() is undefined on iOS 16 Safari and on any WebKit WebView older than 17.4. The flow renderer began calling it in 2026.5, so those clients throw window.customElements.getName is not a function at the first stage render, and the flow never recovers. Two reporters hit this on iOS 16 (#22611).

getName() is the reverse of customElements.get(): given a constructor, it returns the tag name that constructor was registered under. It shipped in Chrome/Edge 117, Firefox 119, and Safari 17.4, so all of iOS 16 and the 17.0 through 17.3 releases reach the renderer without it.

How

A polyfill in web/src/polyfill/custom-elements-get-name.ts:

  • Installs only when getName is absent, so browsers that already have the native method are left untouched.
  • Wraps define() to record each tag/constructor pair in a WeakMap, then answers getName(ctor) from that map.
  • Loads from the polyfill entry point ahead of every interface bundle, so the wrapped define() is in place before any customElements.define() call runs. Order matters here: an install that ran later would miss every element defined before it.

Unit tests cover the install-when-absent path, round-tripping a defined element, forwarding the full define() argument list (including options), the unregistered-constructor case, and the native no-op path.

Disclosure

Triaged and authored end-to-end by an automated agent operating under my account and supervision. I reviewed the full diff and confirmed the local build, lint, and type-checks before opening.

Fixes #22611

The flow renderer started calling window.customElements.getName in 2026.5,
which crashes on iOS 16 Safari and any WebKit WebView before 17.4. Reporters
saw "getName is not a function" at the first stage render and the page never
recovered.

The polyfill wraps define() to record each tag and constructor pair, then
resolves getName(ctor) from that map. It only installs when the registry is
missing the method, so modern browsers keep their native implementation. The
polyfill bundle is loaded from base/skeleton.html ahead of every interface
entry point, so the wrap is in place before any customElements.define call
runs.

Fixes #22611

Co-Authored-By: Agent (authentik-i22611-committed-cooperative-orchid) <[email protected]>
@GirlBossRush
GirlBossRush requested a review from a team as a code owner June 8, 2026 21:16
@netlify

netlify Bot commented Jun 8, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-storybook ready!

Name Link
🔨 Latest commit 3557d9c
🔍 Latest deploy log https://app.netlify.com/projects/authentik-storybook/deploys/6a28501af9f05c00089ba103
😎 Deploy Preview https://deploy-preview-22940--authentik-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Jun 8, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-docs ready!

Name Link
🔨 Latest commit 3557d9c
🔍 Latest deploy log https://app.netlify.com/projects/authentik-docs/deploys/6a28501a4953840008f3a0eb
😎 Deploy Preview https://deploy-preview-22940--authentik-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Jun 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.27%. Comparing base (6e8176c) to head (3557d9c).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #22940   +/-   ##
=======================================
  Coverage   93.26%   93.27%           
=======================================
  Files        1033     1033           
  Lines       60182    60182           
  Branches      400      400           
=======================================
+ Hits        56129    56132    +3     
+ Misses       4053     4050    -3     
Flag Coverage Δ
conformance 36.54% <ø> (+<0.01%) ⬆️
e2e 41.82% <ø> (+0.02%) ⬆️
integration 32.98% <ø> (+<0.01%) ⬆️
rust 0.00% <ø> (ø)
unit 92.20% <ø> (+<0.01%) ⬆️
unit-migrate 92.24% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@GirlBossRush GirlBossRush added the area:frontend Features or issues related to the browser, TypeScript, Node.js, etc label Jun 8, 2026
@GirlBossRush GirlBossRush self-assigned this Jun 8, 2026
@GirlBossRush GirlBossRush moved this from Todo to Needs review in authentik Core Jun 8, 2026
@GirlBossRush GirlBossRush added the backport/version-2026.5 Add this label to PRs to backport changes to version-2026.5 label Jun 8, 2026
@github-project-automation github-project-automation Bot moved this from Needs review to In Progress in authentik Core Jun 9, 2026
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

authentik PR Installation instructions

Instructions for docker-compose

Add the following block to your .env file:

AUTHENTIK_IMAGE=ghcr.io/goauthentik/dev-server
AUTHENTIK_TAG=gh-3557d9c6285b92ef287ce378f5cabb651c092a8b
AUTHENTIK_OUTPOSTS__CONTAINER_IMAGE_BASE=ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s

Afterwards, run the upgrade commands from the latest release notes.

Instructions for Kubernetes

Add the following block to your values.yml file:

authentik:
    outposts:
        container_image_base: ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s
global:
    image:
        repository: ghcr.io/goauthentik/dev-server
        tag: gh-3557d9c6285b92ef287ce378f5cabb651c092a8b

Afterwards, run the upgrade commands from the latest release notes.

@PeshekDotDev
PeshekDotDev merged commit b456e4a into main Jun 9, 2026
110 checks passed
@PeshekDotDev
PeshekDotDev deleted the issue-22611-window-customelements-getname-is-not-a branch June 9, 2026 18:33
@github-project-automation github-project-automation Bot moved this from In Progress to Done in authentik Core Jun 9, 2026
@authentik-automation

Copy link
Copy Markdown
Contributor

🍒 Cherry-pick to version-2026.5 created: #22963

PeshekDotDev added a commit that referenced this pull request Jun 10, 2026
…ry-pick #22940 to version-2026.5) (#22963)

web/polyfill: polyfill customElements.getName for Safari < 17.4 (#22940)

* web/polyfill: polyfill customElements.getName for Safari < 17.4

The flow renderer started calling window.customElements.getName in 2026.5,
which crashes on iOS 16 Safari and any WebKit WebView before 17.4. Reporters
saw "getName is not a function" at the first stage render and the page never
recovered.

The polyfill wraps define() to record each tag and constructor pair, then
resolves getName(ctor) from that map. It only installs when the registry is
missing the method, so modern browsers keep their native implementation. The
polyfill bundle is loaded from base/skeleton.html ahead of every interface
entry point, so the wrap is in place before any customElements.define call
runs.

Fixes #22611



* Refine.

---------

Co-authored-by: Teffen Ellis <[email protected]>
Co-authored-by: Agent (authentik-i22611-committed-cooperative-orchid) <[email protected]>
Co-authored-by: Connor Peshek <[email protected]>
Co-authored-by: Jens L. <[email protected]>
@sweetpeteza

Copy link
Copy Markdown

Confirming this fix also resolves a crash on Android — not just Safari/WebKit <17.4 as described above.

We hit the identical TypeError: window.customElements.getName is not a function in FlowInterface on 2026.5.2, reproducible in both Android's system WebView and Chrome for Android (desktop Chromium at any viewport width was unaffected). Upgrading to 2026.5.3 resolved it there as well.

Worth broadening the polyfill's documented scope beyond Safari, since the underlying API gap apparently exists on some Chromium-based mobile builds too.

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

Labels

area:frontend Features or issues related to the browser, TypeScript, Node.js, etc backport/version-2026.5 Add this label to PRs to backport changes to version-2026.5

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

window.customElements.getName is not a function.

4 participants