1
0
mirror of https://github.com/videojs/video.js.git synced 2024-12-10 11:10:19 +02:00

fix: Don't copy deprecated Event.path (#7782)

This commit is contained in:
mister-ben 2022-05-31 21:51:12 +02:00 committed by GitHub
parent a14ace202b
commit 27f22efe6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View File

@ -117,8 +117,10 @@ export function fixEvent(event) {
// Safari 6.0.3 warns you if you try to copy deprecated layerX/Y
// Chrome warns you if you try to copy deprecated keyboardEvent.keyLocation
// and webkitMovementX/Y
// Lighthouse complains if Event.path is copied
if (key !== 'layerX' && key !== 'layerY' && key !== 'keyLocation' &&
key !== 'webkitMovementX' && key !== 'webkitMovementY') {
key !== 'webkitMovementX' && key !== 'webkitMovementY' &&
key !== 'path') {
// Chrome 32+ warns if you try to copy deprecated returnValue, but
// we still want to if preventDefault isn't supported (IE8).
if (!(key === 'returnValue' && old.preventDefault)) {

View File

@ -383,3 +383,21 @@ QUnit.test('only the first event should call listener via any', function(assert)
Events.trigger(el, 'event2');
assert.equal(triggered, 1, 'listener was not triggered again');
});
QUnit.test('fixEvent should not copy excluded properties', function(assert) {
const event = Events.fixEvent({
a: 'a',
layerX: 0,
layerY: 0,
keyLocation: 0,
webkitMovementX: 0,
webkitMovementY: 0,
path: 0
});
assert.true(event.fixed_, 'event is a fixed event');
assert.strictEqual(event.a, 'a', 'other props copied');
['layerX', 'layerY', 'keyLocation', 'webkitMovementX', 'webkitMovementY', 'path'].forEach(prop => {
assert.equal(event[prop], undefined, `${prop} is undefined`);
});
});