Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0c75914
commit 6195638
Showing
4 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
description: 'properly track reassignments (#4468)' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { patchEventTarget } from './patchEventTarget.js'; | ||
|
||
class EventTarget { | ||
addEventListener(callback) { | ||
callback(); | ||
} | ||
} | ||
global.window = { EventTarget }; | ||
|
||
let patchCalled = false; | ||
patchEventTarget(() => (patchCalled = true)); | ||
const target = new EventTarget(); | ||
target.addEventListener() | ||
|
||
assert.ok(patchCalled, 'patch'); |
10 changes: 10 additions & 0 deletions
10
test/function/samples/track-reassignments/patchEventTarget.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export function patchEventTarget(callback) { | ||
var proto = window.EventTarget.prototype; | ||
var nativeAddEventListener = proto.addEventListener; | ||
|
||
proto.addEventListener = function () { | ||
return nativeAddEventListener(callback); | ||
}; | ||
|
||
return proto; | ||
} |