8000 avoid directive splicing during unlink in production mode · GCLluochen/vue@6b466c6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6b466c6

Browse files
committed
avoid directive splicing during unlink in production mode
1 parent dc9fc33 commit 6b466c6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/compiler/compile.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,15 @@ export function compile (el, options, partial) {
9999
*/
100100

101101
function linkAndCapture (linker, vm) {
102+
/* istanbul ignore if */
103+
if (process.env.NODE_ENV === 'production') {
104+
// reset directives before every capture in production
105+
// mode, so that when unlinking we don't need to splice
106+
// them out (which turns out to be a perf hit).
107+
// they are kept in development mode because they are
108+
// useful for Vue's own tests.
109+
vm._directives = []
110+
}
102111
var originalDirCount = vm._directives.length
103112
linker()
104113
var dirs = vm._directives.slice(originalDirCount)
@@ -161,7 +170,7 @@ function teardownDirs (vm, dirs, destroying) {
161170
var i = dirs.length
162171
while (i--) {
163172
dirs[i]._teardown()
164-
if (!destroying) {
173+
if (process.env.NODE_ENV !== 'production' && !destroying) {
165174
vm._directives.$remove(dirs[i])
166175
}
167176
}

0 commit comments

Comments
 (0)
0