Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Use EventTarget.prototype.addEventListener instead of the method #3137

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

amortemousque
Copy link
Contributor

@amortemousque amortemousque commented Nov 15, 2024

Motivation

Use the window.EventTarget.prototype when possible to avoid wrong overrides (e.g: salesforce/lwc#1824)

Changes

Testing

  • Local
  • Staging
  • Unit
  • End to end

I have gone over the contributing documentation.

@amortemousque amortemousque marked this pull request as ready for review November 15, 2024 10:49
@amortemousque amortemousque requested a review from a team as a code owner November 15, 2024 10:49
@codecov-commenter
Copy link

codecov-commenter commented Nov 15, 2024

Codecov Report

Attention: Patch coverage is 96.96970% with 1 line in your changes missing coverage. Please review.

Project coverage is 93.44%. Comparing base (16efff7) to head (80baa70).

Files with missing lines Patch % Lines
packages/core/test/emulate/mockEventTarget.ts 93.75% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3137   +/-   ##
=======================================
  Coverage   93.44%   93.44%           
=======================================
  Files         279      280    +1     
  Lines        7683     7679    -4     
  Branches     1718     1719    +1     
=======================================
- Hits         7179     7176    -3     
+ Misses        504      503    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

const addEventListenerSpy = jasmine.createSpy()
const removeEventListenerSpy = jasmine.createSpy()

// The stopLeakDetection function of the global after each hook will reset the EventTarget.prototype.addEventListener
Copy link
Contributor Author

@amortemousque amortemousque Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The addEventListener override conflicts with the leakDetection. The best way I found is to let the stopLeakDetection remove the override

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay I found the root cause. Once this fix is merged I'll cleanup the tests properly

Copy link

cit-pr-commenter bot commented Nov 15, 2024

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 161.52 KiB 161.59 KiB 78 B +0.05%
Logs 55.77 KiB 55.85 KiB 78 B +0.14%
Rum Slim 110.36 KiB 110.43 KiB 78 B +0.07%
Worker 25.21 KiB 25.21 KiB 0 B 0.00%
🚀 CPU Performance
Action Name Base Average Cpu Time (ms) Local Average Cpu Time (ms) 𝚫
addglobalcontext 0.002 0.002 0.001
addaction 0.036 0.049 0.013
addtiming 0.001 0.001 0.000
adderror 0.062 0.066 0.004
startstopsessionreplayrecording 0.980 1.689 0.708
startview 1.269 1.447 0.177
logmessage 0.026 0.061 0.035
🧠 Memory Performance
Action Name Base Consumption Memory (bytes) Local Consumption Memory (bytes) 𝚫 (bytes)
addglobalcontext 8.63 KiB 9.38 KiB 773 B
addaction 39.69 KiB 42.02 KiB 2.32 KiB
addtiming 6.62 KiB 6.02 KiB -615 B
adderror 43.81 KiB 45.38 KiB 1.57 KiB
startstopsessionreplayrecording 4.95 KiB 6.24 KiB 1.28 KiB
startview 425.89 KiB 427.77 KiB 1.88 KiB
logmessage 39.57 KiB 41.81 KiB 2.23 KiB

🔗 RealWorld

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants