Skip to content

Commit

Permalink
fix: Allow to assign Array.of and Array.from to a variable at Interne…
Browse files Browse the repository at this point in the history
…t Explorer 9
  • Loading branch information
finom committed Oct 11, 2016

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent ff4a275 commit f0071d9
Showing 5 changed files with 13 additions and 24 deletions.
9 changes: 8 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -10,6 +10,13 @@
"transform-object-spread-inline",
["transform-es2015-template-literals", { "loose": true }],
["transform-es2015-destructuring", { "loose": true }],
["transform-es2015-computed-properties", { "loose": true }]
["transform-es2015-computed-properties", { "loose": true }],

// the following plugins are used at tests
"transform-es2015-classes",
"transform-es2015-for-of",
["transform-es2015-spread", {
"loose": true
}]
]
}
2 changes: 1 addition & 1 deletion src/array/from.js
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import cheapRecreate from './_cheaprecreate';
export default function from(arrayLike, mapFn, thisArg) {
// allow to inherit this method by child classes
// require('./') fixes circular ref issue
const ParentClass = this || require('./');
const ParentClass = typeof this === 'function' ? this : require('./');

const result = new ParentClass();
const length = arrayLike.length;
2 changes: 1 addition & 1 deletion src/array/of.js
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import cheapRecreate from './_cheaprecreate';
export default function of() {
// allow to inherit this method by child classes
// require('./') fixes circular ref issue
const ParentClass = this || require('./');
const ParentClass = typeof this === 'function' ? this : require('./');

const result = new ParentClass();
const newItems = Array(arguments.length);
19 changes: 0 additions & 19 deletions test/.babelrc

This file was deleted.

5 changes: 3 additions & 2 deletions test/spec/matreshka_array/static_methods_spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable import/no-extraneous-dependencies, import/extensions */
import MatreshkaArray from 'src/array';
import Class from 'src/class';

describe('Matreshka.Array static methods (of and from)', () => {
it('converts an array to Matreshka.Array instance via Matreshka.Array.from', () => {
@@ -14,7 +15,7 @@ describe('Matreshka.Array static methods (of and from)', () => {

it('allows to inherit Matreshka.Array.from', () => {
const items = [1, 2, 3];
class OwnerClass extends MatreshkaArray {}
const OwnerClass = Class({'extends': MatreshkaArray});
const arr = OwnerClass.from(items);

expect(arr instanceof OwnerClass).toBe(true);
@@ -46,7 +47,7 @@ describe('Matreshka.Array static methods (of and from)', () => {

it('allows to inherit Matreshka.Array.of', () => {
const items = [1, 2, 3];
class OwnerClass extends MatreshkaArray {}
const OwnerClass = Class({'extends': MatreshkaArray});
const arr = OwnerClass.of(...items);

expect(arr instanceof OwnerClass).toBe(true);

0 comments on commit f0071d9

Please sign in to comment.