Forward focus and scrollIntoView to the host - #627
Open
airhorns wants to merge 1 commit into
Open
Conversation
airhorns
force-pushed
the
polyfill-imperative-element-methods
branch
from
July 28, 2026 14:17
f499904 to
a9eef6d
Compare
Assisted-By: devx/ca2f43ab-bbf9-4273-b1bc-0b06f8c90a57
airhorns
force-pushed
the
polyfill-imperative-element-methods
branch
from
July 28, 2026 14:19
a9eef6d to
11971c2
Compare
JoviDeCroock
approved these changes
Jul 29, 2026
developit
requested changes
Jul 29, 2026
Comment on lines
+79
to
+83
| if (arg === undefined) { | ||
| this.callHostMethod('scrollIntoView'); | ||
| } else { | ||
| this.callHostMethod('scrollIntoView', arg); | ||
| } |
Contributor
There was a problem hiding this comment.
Suggested change
| if (arg === undefined) { | |
| this.callHostMethod('scrollIntoView'); | |
| } else { | |
| this.callHostMethod('scrollIntoView', arg); | |
| } | |
| this[HOOKS].callMethod?.(this as any, 'scrollIntoView', arg); |
Comment on lines
+71
to
+75
| if (options === undefined) { | ||
| this.callHostMethod('focus'); | ||
| } else { | ||
| this.callHostMethod('focus', options); | ||
| } |
Contributor
There was a problem hiding this comment.
Suggested change
| if (options === undefined) { | |
| this.callHostMethod('focus'); | |
| } else { | |
| this.callHostMethod('focus', options); | |
| } | |
| this[HOOKS].callMethod?.(this as any, 'focus', arg); |
Comment on lines
+39
to
+42
| protected callHostMethod(method: string, ...args: unknown[]) { | ||
| this[HOOKS].callMethod?.(this as any, method, ...args); | ||
| } | ||
|
|
Contributor
There was a problem hiding this comment.
This makes the method callable from userland. Callsites must just use this[HOOKS].callMethod?.(this as any, 'scrollIntoView', arg) directly (see other suggestion comments).
Suggested change
| protected callHostMethod(method: string, ...args: unknown[]) { | |
| this[HOOKS].callMethod?.(this as any, method, ...args); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
focus()andscrollIntoView()are missing from polyfilled elements, even though Remote DOM already has a method-call channel and both operations can be performed by the rendered host element. Remote code type-checked againstlib.domtherefore fails at runtime before it can use that channel.This adds a general imperative-method hook to
@remote-dom/polyfill, implementsfocus()andscrollIntoView()on the polyfill's sharedElementabstraction, and wires the core polyfill hook to the connectedRemoteConnection. Options are forwarded unchanged. Standalone or disconnected polyfilled elements keep browser-like no-op behavior when no host hook is available.The core regression test connects a real
RemoteRootElementandRemoteReceiver, registers the host implementation, and verifies both method calls end to end.These methods live on the shared
Elementclass because that is the current concrete class returned for ordinary and custom HTML elements onmain. #626 separately proposes concrete HTML constructor identity.getBoundingClientRect()is deliberately not included: it is synchronous and returns host layout data, which cannot be faithfully implemented over an asynchronous remote connection.Validation
pnpm exec vitest run(178 tests)pnpm lintpnpm type-checkmise exec node@20.20.0 -- pnpm --filter @remote-dom/polyfill --filter @remote-dom/core build