1. 16 Jul, 2021 6 commits
    • Eduardo Sanz García's avatar
      Rename `callback` to `listener` · 1a145742
      Eduardo Sanz García authored
      The word `listener` matches better the internal property names of
      `this.channelListeners` and `this.onConnectListeners`. In addition, it
      helps to differentiate from the `callback` function which is the last
      (optional) argument of the `listener`. The `callback` is used to send
      back a `postMessage` response to the other frame/s.
      1a145742
    • Eduardo Sanz García's avatar
      Error when adding a handler if a channel has been created · 6b786774
      Eduardo Sanz García authored
      The RPC class design requires all the handlers to be provided up-front.
      Currently, adding a new handler after a channel is created has no
      effect. To make more obvious this misuse, the method now throws an
      error.
      6b786774
    • Eduardo Sanz García's avatar
      Simplify `this.link` property in `bridge.js` · 88845500
      Eduardo Sanz García authored
      `this.link` was defined as `Array<{channel: RPC, window: Window}>`
      however, the `window` property was never used. I am guessing that the
      original idea was to avoid creating additional channels for the same
      frame, however, that was never implemented.
      
      I take the decision of removing the `window` property and converting the
      `this.link` to a type of `RPC[]`.
      88845500
    • Eduardo Sanz García's avatar
      Simplify promise · 34b319ce
      Eduardo Sanz García authored
      As far as I know, the `return` statement don't have any effect.
      34b319ce
    • Eduardo Sanz García's avatar
      Remove unnecessary `Array.from(...)` · 8e6307e8
      Eduardo Sanz García authored
      As pointed by @robertknight `Array.from` was probably a leftover from
      the tool that was used to convert CoffeeScript to JavaScript.
      8e6307e8
    • Eduardo Sanz García's avatar
      Added types and comment about a callback · 946eda90
      Eduardo Sanz García authored
      I also include a minor change to improve the readability extracting the
      callback from the `args`.
      946eda90
  2. 15 Jul, 2021 8 commits
  3. 14 Jul, 2021 7 commits
    • Robert Knight's avatar
      Use `$imports.$mock` to mock RPC in bridge-test.js · b5e717ae
      Robert Knight authored
      The `Bridge` code was written before we had good mocking tools in the
      client. As a result the `Bridge` class mocks `RPC` in an unconventional
      way where it constructs the real class, but then stubs out specific
      methods. Also tests varied in the degree to which they tested only
      `Bridge` vs Bridge + RPC together.
      
      This commit mocks `RPC` in bridge-test.js using our standard mocking
      tools and makes all tests in the file unit tests. This involved some
      significant changes to the `onConnect` tests.
      b5e717ae
    • Eduardo Sanz García's avatar
      Various improvements based on PR feedback · 12982d25
      Eduardo Sanz García authored
      * change `@deprecated` for a comment
      * added a test to cover some missing lines in `_isValidSender` function.
      * `_isValidMessage` renamed to `_parseMessage`
      * created helper function `waitForMessageDelivery`
      * parametrise test
      12982d25
    • Eduardo Sanz García's avatar
      Cleanup/follow up work on `RPC` · 1aea95e6
      Eduardo Sanz García authored
      RPC:
      * added `@deprecated` statements and additional comments
      * removed `this._destroyed` for the listener checks, because the
        listener is removed when called `destroy()`.
      * added `this._port.close()` in addition to removing the listner.
      
      `bridge-test`:
      * refactor all the `function () {}` to arrow functions
      
      `frame-rpc-test.js`:
      * added these tests to check the `MessageChannel` functionality.
      1aea95e6
    • Eduardo Sanz García's avatar
      Strengthen types · 3e94f694
      Eduardo Sanz García authored
      3e94f694
    • Eduardo Sanz García's avatar
      Simplify internals · b0f23457
      Eduardo Sanz García authored
      Created a couple of utility methods to avoid duplication of code and
      enable to decouple RPC for `Window` or for `MessagePort`.
      b0f23457
    • Eduardo Sanz García's avatar
      Add `ListenerCollection` utility to handle listeners · 75525988
      Eduardo Sanz García authored
      It simplifies the code.
      75525988
    • Eduardo Sanz García's avatar
      Initial support of `MessageChannel` on `RPC` · 87832dbc
      Eduardo Sanz García authored
      It is a bit of a Frankenstein. The plan is to clean up on the next
      commits.
      87832dbc
  4. 13 Jul, 2021 5 commits
  5. 12 Jul, 2021 1 commit
    • Kyle Keating's avatar
      Remove aria-label from TagEditor and AnnotationPublishControl button · 4ae836c4
      Kyle Keating authored
      Per WCAG 2.1 criterion: 2.5.3 Label in Name--we should not differentiate between the aria-label and the visual name in an input element. In the case of the TagEditor, the `placeholder` and `aria-label` were different. The simple fix is to remove `aria-label`.
      
      The second problem is with AnnotationPublishControl's button where the `aria-label` and button's text did not match. Again, the simple fix is to remove `aria-label`.
      4ae836c4
  6. 09 Jul, 2021 2 commits
    • Robert Knight's avatar
      Always use object shorthand for properties · 2cccebc2
      Robert Knight authored
      Enforce the use of object shorthand syntax everywhere for consistency.
      eg. `{ foo }` instead of `{ foo: foo }`. We had already converted most
      occurrences manually.
      2cccebc2
    • Robert Knight's avatar
      Convert remaining anonymous callbacks to arrow functions · 088864e9
      Robert Knight authored
      We've been gradually converting anonymous functions to arrow functions
      since adopting ES6. This commit uses ESLint to finish the process by
      converting the remaining non-named, non-`this`-using callbacks to arrow
      functions.
      
       - Enable `prefer-arrow-callbacks` lint rule. The `allowNamedFunctions`
         option is enabled because we have a few instances (eg. in
         gulpfile.js) of explicitly naming functions for use in debugging /
         logging etc.
      
       - Run `eslint --fix .` and `yarn format` to automatically fix up the
         code
      088864e9
  7. 07 Jul, 2021 1 commit
  8. 06 Jul, 2021 10 commits