philomena-dev / philomena

Next-generation imageboard
GNU Affero General Public License v3.0
84 stars 29 forks source link

ujs: migrate to TypeScript #225

Closed liamwhite closed 2 months ago

liamwhite commented 2 months ago

This moves all of the ujs events convenience library into TypeScript. There should be no substantial changes to the logic here, but two bugs were discovered during testing and fixed:

  1. Incorrect use of target where input was intended.
    $$('[disabled][data-disable-with][data-enable-with]', target).forEach(input => {
     // ...
     input.innerHTML = target.dataset.enableWith;
     //                ^^^^^^ input
    }
  2. HTMLFormElement's method property is restricted, so the final 'POST' case is unreachable here:
    method: (target.dataset.method || target.method || 'POST').toUpperCase(),

This has 100% test coverage in unit tests and has also been manually integration tested.