diff --git a/addon/classes/Column.js b/addon/classes/Column.js index 5e35a8b0..fa94ab91 100644 --- a/addon/classes/Column.js +++ b/addon/classes/Column.js @@ -2,7 +2,6 @@ import { A as emberArray, makeArray } from '@ember/array'; import EmberObject, { computed } from '@ember/object'; import { isEmpty } from '@ember/utils'; import { guidFor } from '@ember/object/internals'; -import fixProto from 'ember-light-table/utils/fix-proto'; /** * @module Table @@ -324,6 +323,3 @@ export default class Column extends EmberObject.extend({ this.set('subColumns', subColumns); } }) {} - -// https://github.com/offirgolan/ember-light-table/issues/436#issuecomment-310138868 -fixProto(Column); diff --git a/addon/classes/Row.js b/addon/classes/Row.js index f987f429..1cebd3d8 100644 --- a/addon/classes/Row.js +++ b/addon/classes/Row.js @@ -1,7 +1,6 @@ import ObjectProxy from '@ember/object/proxy'; import { computed } from '@ember/object'; import { guidFor } from '@ember/object/internals'; -import fixProto from 'ember-light-table/utils/fix-proto'; /** * @module Table @@ -78,6 +77,3 @@ export default class Row extends ObjectProxy.extend({ return guidFor(this); }).readOnly() }) {} - -// https://github.com/offirgolan/ember-light-table/issues/436#issuecomment-310138868 -fixProto(Row); diff --git a/addon/classes/Table.js b/addon/classes/Table.js index d969272e..8a45b83d 100644 --- a/addon/classes/Table.js +++ b/addon/classes/Table.js @@ -5,7 +5,6 @@ import Row from 'ember-light-table/classes/Row'; import Column from 'ember-light-table/classes/Column'; import SyncArrayProxy from 'ember-light-table/-private/sync-array-proxy'; import { mergeOptionsWithGlobals } from 'ember-light-table/-private/global-options'; -import fixProto from 'ember-light-table/utils/fix-proto'; import { assign } from '@ember/polyfills'; import { isNone } from '@ember/utils'; @@ -455,6 +454,3 @@ export default class Table extends EmberObject.extend({ return columns.map((c) => Table.createColumn(c)); } } - -// https://github.com/offirgolan/ember-light-table/issues/436#issuecomment-310138868 -fixProto(Table); diff --git a/addon/utils/fix-proto.js b/addon/utils/fix-proto.js deleted file mode 100644 index efc82bdb..00000000 --- a/addon/utils/fix-proto.js +++ /dev/null @@ -1,77 +0,0 @@ -/** - * @module Utils - * @private - */ - -/** - * Internet Explorer <= 10 has no support for `__proto__`. - * This conditional polyfill works around that, so that static methods like - * `reopen` may be used. There are some caveats though. - * - * For more information, please see: [Issue #436 (comment)][436] - * - * [436]: https://github.com/offirgolan/ember-light-table/issues/436#issuecomment-310138868 - * - * @class fixProto - */ - -/** - * Whether or not this environment supports `__proto__`. - * IE <= 10 is known to not support it- - * - * More information on `__proto__`: - * - * https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/proto - * - * @const isProtoSupported - * @type {Boolean} - * @readOnly - */ -export const isProtoSupported = ({ __proto__: [] }) instanceof Array; - -/** - * Assigns all properties of `defaults` to `obj`, if they are not already - * defined on `obj`. This means that `obj` is mutated in place. - * - * Taken from: - * - * https://github.com/babel/babel/blob/64eafad472ebac6333671fff65a9669739e6cd88/packages/babel-helpers/src/helpers.js#L287-L299 - * - * @method defaults - * @param {Object} obj The object to assign the default properties to - * @param {Object} defaults The object that provides all default properties to - * be assigned - * @return {Object} The `obj` that was passed in - */ -export function defaults(obj, defaults) { - const keys = Object.getOwnPropertyNames(defaults); - for (let i = 0; i < keys.length; i++) { - const key = keys[i]; - const value = Object.getOwnPropertyDescriptor(defaults, key); - if (value && value.configurable && obj[key] === undefined) { - Object.defineProperty(obj, key, value); - } - } - - return obj; -} - -/** - * Conditionally attempt to polyfill support for `__proto__` in environments - * that do not support it. - * - * If `__proto__` is not supported, this function assigns all properties and - * methods pf `Class.__proto__` to `Class` itself. - * - * @method fixProto - * @param {Function} Class The base class - * @return {Function} The `Class` that was passed in - */ -export default function fixProto(Class) { - if (isProtoSupported) { - return; - } - - // https://github.com/babel/babel/tree/64eafad472ebac6333671fff65a9669739e6cd88/packages/babel-plugin-transform-proto-to-assign#example - return defaults(Class, Class.__proto__); -} diff --git a/tests/unit/utils/fix-proto-test.js b/tests/unit/utils/fix-proto-test.js deleted file mode 100644 index 86b0de22..00000000 --- a/tests/unit/utils/fix-proto-test.js +++ /dev/null @@ -1,31 +0,0 @@ -import EmberObject from '@ember/object'; -import fixProto from 'ember-light-table/utils/fix-proto'; -import { module, test } from 'qunit'; - -module('Unit | Utility | fix proto', function() { - /* - * Running this test in an environment that does not need the polyfill doesn't - * make any sense. The only relevent environments are IE <= 10. - */ - - test('ES6 classes that extend `Ember.Object` can be reopened after `fixProto` was used on them', function(assert) { - class DerivedClass extends EmberObject.extend() {} - - fixProto(DerivedClass); - - DerivedClass.reopenClass({ - someStaticMethod() { - return true; - } - }); - assert.ok(DerivedClass.someStaticMethod(), 'reopenClass works'); - - DerivedClass.reopen({ - someMethod() { - return true; - } - }); - let instance = DerivedClass.create(); - assert.ok(instance.someMethod(), 'reopen works'); - }); -});