Skip to content

Commit

Permalink
Make patch only Array.prototype is freezen
Browse files Browse the repository at this point in the history
  • Loading branch information
xcodebuild committed Sep 18, 2017
1 parent 262d9ba commit 6e963c6
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions src/types/observablearray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,27 +120,30 @@ function inherit(ctor, proto) {
inherit(StubArray, Array.prototype)

// Weex freeze Array.prototype
// Make them writeable and configurable in prototype chain
// https://github.com/alibaba/weex/pull/1529
;[
"constructor",
"push",
"shift",
"concat",
"pop",
"unshift",
"replace",
"find",
"findIndex",
"splice",
"reverse",
"sort"
].forEach(function (key) {
Object.defineProperty(StubArray.prototype, key, {
configurable: true,
writable: true,
value: Array.prototype[key]
})
})
if (Object.isFrozen(Array)) {
;[
"constructor",
"push",
"shift",
"concat",
"pop",
"unshift",
"replace",
"find",
"findIndex",
"splice",
"reverse",
"sort"
].forEach(function (key) {
Object.defineProperty(StubArray.prototype, key, {
configurable: true,
writable: true,
value: Array.prototype[key]
})
})
}

class ObservableArrayAdministration<T>
implements IInterceptable<IArrayWillChange<T> | IArrayWillSplice<T>>, IListenable {
Expand Down

0 comments on commit 6e963c6

Please sign in to comment.