Skip to content

Commit

Permalink
chore: Update preset env, drop IE11 and older browser support (#7708)
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-barstow authored and misteroneill committed Nov 23, 2022
1 parent 3faa866 commit 1281d68
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 32 deletions.
13 changes: 13 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@
[
"@babel/preset-env",
{
"targets": [
"last 3 major versions",
"Firefox ESR",
"Chrome >= 53",
"not dead",
"not ie 11",
"not baidu 7",
"not and_qq 11",
"not and_uc 12",
"not kaios 2",
"not op_mini all",
"not op_mob 64"
],
"bugfixes": true,
"loose": true
}
Expand Down
13 changes: 13 additions & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Browsers that we support

last 3 major versions
Firefox ESR
Chrome >= 53
not dead
not ie 11
not baidu 7
not and_qq 11
not and_uc 12
not kaios 2
not op_mini all
not op_mob 64
4 changes: 1 addition & 3 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// default is: > 0.5%, last 2 versions, Firefox ESR, not dead
// we add on ie 11 since we still support that.
// see https://github.com/browserslist/browserslist for more info
const browsersList = ['defaults', 'ie 11'];
const browsersList = ['last 3 major version', 'Firefox ESR', 'Chrome >= 53', 'not dead', 'not ie 11'];

module.exports = {
plugins: [
Expand Down
14 changes: 14 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,20 @@ const primedBabel = babel({
compact: false,
presets: [
['@babel/preset-env', {
targets: [
'last 3 major versions',
'Firefox ESR',
// This ensures support for certain smart TVs (ex. LG WebOS 4)
'Chrome >= 53',
'not dead',
'not ie 11',
'not baidu 7',
'not and_qq 11',
'not and_uc 12',
'not kaios 2',
'not op_mini all',
'not op_mob 64'
],
bugfixes: true,
loose: true,
modules: false
Expand Down
25 changes: 14 additions & 11 deletions src/js/extend.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
*/

import _inherits from '@babel/runtime/helpers/inherits';
import log from './utils/log.js';

let hasLogged = false;
import log from './utils/log';

/**
* Used to subclass an existing class by emulating ES subclassing using the
Expand All @@ -29,21 +27,24 @@ let hasLogged = false;
*
* @return {Function}
* The new class with subClassMethods that inherited superClass.
*
* @deprecated videojs.extend() is deprecated as of v8; use native ES6 classes instead
*/
const extend = function(superClass, subClassMethods = {}) {
log.warn('The extend() method is deprecated. Please use native ES6 classes instead.');

// Log a warning the first time extend is called to note that it is deprecated
// It was previously deprecated in our documentation (guides, specifically),
// but was never formally deprecated in code.
if (!hasLogged) {
log.warn('videojs.extend is deprecated as of Video.js 7.22.0 and will be removed in Video.js 8.0.0');
hasLogged = true;
}
const isNativeClass = superClass && /^class/.test(superClass.toString());

let subClass = function() {
superClass.apply(this, arguments);
};

// If the provided super class is a native ES6 class,
// make the sub class one as well.
if (isNativeClass) {
subClass = class SubClass extends superClass {};
}

let methods = {};

if (typeof subClassMethods === 'object') {
Expand All @@ -55,7 +56,9 @@ const extend = function(superClass, subClassMethods = {}) {
subClass = subClassMethods;
}

_inherits(subClass, superClass);
if (!isNativeClass) {
_inherits(subClass, superClass);
}

// this is needed for backward-compatibility and node compatibility.
if (superClass) {
Expand Down
53 changes: 39 additions & 14 deletions test/unit/extend.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,52 @@ import extend from '../../src/js/extend.js';
QUnit.module('extend.js');

QUnit.test('should add implicit parent constructor call', function(assert) {
assert.expect(4);

let superCalled = false;
const Parent = function() {
superCalled = true;
};
const Child = extend(Parent, {
foo: 'bar'
});
const child = new Child();

assert.ok(superCalled, 'super constructor called');
assert.ok(child.foo, 'child properties set');
[
function() {
superCalled = true;
},
class Parent {
constructor() {
superCalled = true;
}
}
].forEach(Parent => {
const Child = extend(Parent, {
foo: 'bar'
});
const child = new Child();

assert.ok(superCalled, 'super constructor called');
assert.ok(child.foo, 'child properties set');

superCalled = false;
});
});

QUnit.test('should have a super_ pointer', function(assert) {
const Parent = function() {};
assert.expect(4);

[function() {}, class Parent {}].forEach(Parent => {
const Child = extend(Parent, {
foo: 'bar'
});
const child = new Child();

assert.ok(child.foo, 'child properties set');
assert.equal(child.constructor.super_, Parent, 'super_ is present and equal to the super class');
});
});

QUnit.test('sub class is an ES6 class if the super class is', function(assert) {
class Parent {}

const Child = extend(Parent, {
foo: 'bar'
});

const child = new Child();

assert.ok(child.foo, 'child properties set');
assert.equal(child.constructor.super_, Parent, 'super_ is present and equal to the super class');
assert.ok(/^class/.test(Child.toString()), 'sub class is native es6 class');
});
16 changes: 12 additions & 4 deletions test/unit/tracks/text-track.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,9 @@ QUnit.test('if preloadTextTracks is false, default tracks are not parsed until m

window.WebVTT = () => {};
window.WebVTT.StringDecoder = () => {};
window.WebVTT.Parser = () => {

// This needs to be function expression rather than arrow function so it is constructable
window.WebVTT.Parser = function() {
parserCreated = true;
return {
oncue() {},
Expand Down Expand Up @@ -508,7 +510,9 @@ QUnit.test('tracks are parsed if vttjs is loaded', function(assert) {

window.WebVTT = () => {};
window.WebVTT.StringDecoder = () => {};
window.WebVTT.Parser = () => {

// This needs to be function expression rather than arrow function so it is constructable
window.WebVTT.Parser = function() {
parserCreated = true;
return {
oncue() {},
Expand Down Expand Up @@ -547,7 +551,9 @@ QUnit.test('tracks are loaded withCredentials is crossorigin is set to use-crede

window.WebVTT = () => {};
window.WebVTT.StringDecoder = () => {};
window.WebVTT.Parser = () => {

// This needs to be function expression rather than arrow function so it is constructable
window.WebVTT.Parser = function() {
return {
oncue() {},
onparsingerror() {},
Expand Down Expand Up @@ -619,7 +625,9 @@ QUnit.test('tracks are parsed once vttjs is loaded', function(assert) {

window.WebVTT = () => {};
window.WebVTT.StringDecoder = () => {};
window.WebVTT.Parser = () => {

// This needs to be function expression rather than arrow function so it is constructable
window.WebVTT.Parser = function() {
parserCreated = true;
return {
oncue() {},
Expand Down

0 comments on commit 1281d68

Please sign in to comment.