a11y-dialog icon indicating copy to clipboard operation
a11y-dialog copied to clipboard

feat: use delegation to listen to trigger clicks

Open mxmason opened this issue 1 year ago • 6 comments

Summary

As it says on the tin!

mxmason avatar Jul 26 '22 02:07 mxmason

I also think we’ll have to update the Cypress tests?

KittyGiraudel avatar Jul 26 '22 08:07 KittyGiraudel

Wondering whether it will have an impact on performance, but it’s probably marginal at best.

Probably marginal, yes, but I’ll take it! By not storing references to DOM nodes, we also reduce the (equally marginal) risk of a memory leak happening if the author removes from the DOM a node to which we have a reference.

As for the tests: they still pass! Is there something I should change?

mxmason avatar Jul 26 '22 14:07 mxmason

As for the tests: they still pass! Is there something I should change?

Considering the signature of our event handlers has changed (we no longer pass the dialog element as a first argument), I was under the impression we might have to tweak or tests. It’s not a great sign that they don‘t break in that instance. 😹

KittyGiraudel avatar Jul 27 '22 07:07 KittyGiraudel

Considering the signature of our event handlers has changed (we no longer pass the dialog element as a first argument)

I’m not sure I follow. The delegate function explicitly passes the event object to the show and hide functions, just as direct binding used to, and there’s no change to user-facing APIs in this PR.

mxmason avatar Jul 27 '22 09:07 mxmason

I’m not sure I follow. The delegate function explicitly passes the event object to the show and hide functions, just as direct binding used to, and there’s no change to user-facing APIs in this PR.

Ah not in this PR no, I meant in general. Our signature did change when we moved the events to be DOM-based. Previously the function would receive this.$el as a first argument, and no longer. That‘s not related to that PR per se though. Sorry for the confusion! :)

KittyGiraudel avatar Jul 27 '22 09:07 KittyGiraudel

Created some fancy new tests in https://github.com/KittyGiraudel/a11y-dialog/pull/390.

KittyGiraudel avatar Jul 27 '22 14:07 KittyGiraudel