Skip to content

Commit

Permalink
Add check to verify whether base methods exists
Browse files Browse the repository at this point in the history
  • Loading branch information
mweststrate committed Sep 23, 2016
1 parent 1d4c2d5 commit edc65e1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/types/observablearray.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {getNextId, deepEquals, makeNonEnumerable, Lambda, deprecated, EMPTY_ARRAY, addHiddenFinalProp, addHiddenProp} from "../utils/utils";
import {getNextId, deepEquals, makeNonEnumerable, Lambda, deprecated, EMPTY_ARRAY, addHiddenFinalProp, addHiddenProp, invariant} from "../utils/utils";
import {BaseAtom} from "../core/atom";
import {ValueMode, assertUnwrapped, makeChildObservable} from "./modifiers";
import {checkIfStateModificationsAreAllowed} from "../core/derivation";
Expand Down Expand Up @@ -427,6 +427,7 @@ Object.defineProperty(ObservableArray.prototype, "length", {
"some"
].forEach(funcName => {
const baseFunc = Array.prototype[funcName];
invariant(typeof baseFunc === "function", `Base function not defined on Array prototype: '${funcName}'`);
addHiddenProp(ObservableArray.prototype, funcName, function() {
this.$mobx.atom.reportObserved();
return baseFunc.apply(this.$mobx.values, arguments);
Expand All @@ -436,7 +437,7 @@ Object.defineProperty(ObservableArray.prototype, "length", {
// See #364
const ENTRY_0 = {
configurable: true,
enumerable:false,
enumerable: false,
set: createArraySetter(0),
get: createArrayGetter(0)
};
Expand Down

0 comments on commit edc65e1

Please sign in to comment.