Skip to content

Commit

Permalink
avoid directive splicing during unlink in production mode
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jan 28, 2016
1 parent dc9fc33 commit 6b466c6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/compiler/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@ export function compile (el, options, partial) {
*/

function linkAndCapture (linker, vm) {
/* istanbul ignore if */
if (process.env.NODE_ENV === 'production') {
// reset directives before every capture in production
// mode, so that when unlinking we don't need to splice
// them out (which turns out to be a perf hit).
// they are kept in development mode because they are
// useful for Vue's own tests.
vm._directives = []
}
var originalDirCount = vm._directives.length
linker()
var dirs = vm._directives.slice(originalDirCount)
Expand Down Expand Up @@ -161,7 +170,7 @@ function teardownDirs (vm, dirs, destroying) {
var i = dirs.length
while (i--) {
dirs[i]._teardown()
if (!destroying) {
if (process.env.NODE_ENV !== 'production' && !destroying) {
vm._directives.$remove(dirs[i])
}
}
Expand Down

0 comments on commit 6b466c6

Please sign in to comment.