tickets

gitoria.worldapi.org #28

Form handlers write DOM values directly

done

opened by Atlas

opened · updated

Audit (layouts.worldapi.org#6), checklist item: 6 (changes come from member writes in handlers; no direct DOM writes that carry state).

Form handlers read and clear DOM values by hand: components/list.hl:61 (e.target.elements) and 68-69 (f.slug.value = '', f.description.value = ''), components/tickets.hl:85 and 92-93 (f.subject.value = '', f.summary.value = ''), components/main.hl:125 (e.target.value = ''). The same shell already does it the framework way in components/sshkeys.hl and tokens.hl (a member bound with value = and set from on input, then cleared by writing the member).

login.js is NOT part of this ticket: it stays by caramboleyo's explicit rule.

History

  1. Atlas opened the ticket
  2. Atlas edited the ticket

    Subject before: Login bridge is a hand-written JavaScript file and handlers write DOM values directly

    Summary before

    Audit (layouts.worldapi.org#6), checklist item: 6 (changes come from member writes in handlers; no direct DOM writes that carry state).

    1. /login.js (login.js, 52 lines, served by the route in project.hl:87 and loaded by components/main.hl:100-101) is hand-written JavaScript. It uses getElementById('selector') and getElementById('identcode'), sets sel.loggedIn on ident's element, sets input.value = code and dispatches a change event, rewrites the login link's href at click time, and runs a MutationObserver on the whole document. Worker rules forbid hand-written JavaScript: at a Hybriel gap the worker must stop and put a minimal repro in .scratch/ and report it. The file's own header says the reason: hl:web cannot listen to a custom DOM event (ident-login) and cannot set a property on a custom element. That gap has not been reported (no repro found under .scratch/ for it).
    2. Form handlers read and clear DOM values by hand: components/list.hl:61 (e.target.elements) and 68-69 (f.slug.value = '', f.description.value = ''), components/tickets.hl:85 and 92-93 (f.subject.value = '', f.summary.value = ''), components/main.hl:125 (e.target.value = ''). The same shell already does it the framework way in components/sshkeys.hl and tokens.hl (a member bound with value = and set from on input, then cleared by writing the member).

    Framework way: the form fields are bound to members (value = member, on input writes the member) and a handler clears them by writing the member. For the login bridge: report the missing custom-event and custom-element-property support as a Hybriel gap with a minimal repro, then replace login.js once Hybriel has it.

  3. 2 comments

    1. Atlas
        Write…
      • Gitoria
          Write…
      • Gitoria changed the state done

      Reading is open to everyone. To comment or change the state, log in with ident (top right) and choose a display name.