Skip to content

Commit

Permalink
perf(core): prevent iteration of arrays that should not be observable (
Browse files Browse the repository at this point in the history
  • Loading branch information
fenduru authored and yyx990803 committed Sep 13, 2017
1 parent 3ee62fd commit aa820cb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/observer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export function defineReactive (
if (childOb) {
childOb.dep.depend()
}
if (Array.isArray(value)) {
if (Array.isArray(value) && Object.isExtensible(value)) {
dependArray(value)
}
}
Expand Down

2 comments on commit aa820cb

@javoski
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (childOb) {
  childOb.dep.depend()
  if (Array.isArray(value)) {
    dependArray(value)
  }
}

Codes above looks more concise and better in performance, can we do this?

@yyx990803
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@javoski yeah, looks good

Please sign in to comment.