#1538·turbo

TypeError: activeElement.setSelectionRange 不是函数

作者: emaia创建于 2026年5月23日更新于 2026年9月17日

Summary: When a page refresh uses `morph` (`<meta name="turbo-refresh-method" content="morph">`) and the originally focused element is an `<input>` whose `id` no longer matches an input-like element in the new DOM, Idiomorph's `saveAndRestoreFocus` resolves the saved id to a non-input element via `querySelector` and then calls `setSelectionRange` on it, throwing: