Conversation
a9eef6d to
11971c2
Compare
| if (arg === undefined) { | ||
| this.callHostMethod('scrollIntoView'); | ||
| } else { | ||
| this.callHostMethod('scrollIntoView', arg); | ||
| } |
There was a problem hiding this comment.
| if (arg === undefined) { | |
| this.callHostMethod('scrollIntoView'); | |
| } else { | |
| this.callHostMethod('scrollIntoView', arg); | |
| } | |
| this[HOOKS].callMethod?.(this as any, 'scrollIntoView', arg); |
There was a problem hiding this comment.
Same as above — inlined via a rest tuple to preserve arity.
| if (options === undefined) { | ||
| this.callHostMethod('focus'); | ||
| } else { | ||
| this.callHostMethod('focus', options); | ||
| } |
There was a problem hiding this comment.
| if (options === undefined) { | |
| this.callHostMethod('focus'); | |
| } else { | |
| this.callHostMethod('focus', options); | |
| } | |
| this[HOOKS].callMethod?.(this as any, 'focus', arg); |
There was a problem hiding this comment.
Applied, with one tweak: the argument is spread through a rest tuple (focus(...args: [options?: FocusOptions])) so a bare element.focus() reaches the host as callMethod(el, 'focus') rather than callMethod(el, 'focus', undefined) — keeps the arity the host sees identical to what the caller wrote.
| protected callHostMethod(method: string, ...args: unknown[]) { | ||
| this[HOOKS].callMethod?.(this as any, method, ...args); | ||
| } | ||
|
|
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).
| protected callHostMethod(method: string, ...args: unknown[]) { | |
| this[HOOKS].callMethod?.(this as any, method, ...args); | |
| } |
There was a problem hiding this comment.
Done in 726ae5f — callHostMethod is gone and both call sites invoke this[HOOKS].callMethod?.(this as any, …) directly. Also rebased onto main to pick up the erasable-syntax import changes.
Assisted-By: devx/ca2f43ab-bbf9-4273-b1bc-0b06f8c90a57
11971c2 to
726ae5f
Compare
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