Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 10x 6x 6x 6x 6x 6x 6x 6x 6x 6x 10x 2x 2x 2x 2x 2x 2x 2x 2x 14x 7x 7x 14x | import { hydrating } from '../hydration.js'; import { effect } from '../../reactivity/effects.js'; import { clear_text_content } from '../operations.js'; /** * @param {HTMLElement} dom * @param {boolean} value * @returns {void} */ export function autofocus(dom, value) { if (value) { const body = document.body; dom.autofocus = true; effect(() => { if (document.activeElement === body) { dom.focus(); } }); } } /** * The child of a textarea actually corresponds to the defaultValue property, so we need * to remove it upon hydration to avoid a bug when someone resets the form value. * @param {HTMLTextAreaElement} dom * @returns {void} */ export function remove_textarea_child(dom) { if (hydrating && dom.firstChild !== null) { clear_text_content(dom); } } |