Skip to content

Commit e55b241

Browse files
committed
Early return.
1 parent 8d63424 commit e55b241

File tree

1 file changed

+30
-26
lines changed

1 file changed

+30
-26
lines changed

src/mixins/componentDebug.js

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,44 @@
11
export function createComponentDebugMixin() {
22
return {
33
mounted() {
4-
if (process.env.NODE_ENV === 'development') {
5-
const component = this.$options.__file || this.$options.__name || 'Anonymous';
4+
if (process.env.NODE_ENV !== 'development') {
5+
return;
6+
}
67

7-
const startComment = document.createComment(` Start component: ${component} `);
8-
this.$el.parentNode?.insertBefore(startComment, this.$el);
8+
const component = this.$options.__file || this.$options.__name || 'Anonymous';
99

10-
const endComment = document.createComment(` End component: ${component} `);
11-
this.$el.parentNode?.insertBefore(endComment, this.$el.nextSibling);
12-
}
10+
const startComment = document.createComment(` Start component: ${component} `);
11+
this.$el.parentNode?.insertBefore(startComment, this.$el);
12+
13+
const endComment = document.createComment(` End component: ${component} `);
14+
this.$el.parentNode?.insertBefore(endComment, this.$el.nextSibling);
1315
},
1416
beforeUnmount() {
15-
if (process.env.NODE_ENV === 'development') {
16-
// Clean up comments when components are destroyed.
17-
const component = this.$options.__file || this.$options.__name || 'Anonymous';
18-
const parent = this.$el.parentNode;
17+
if (process.env.NODE_ENV !== 'development') {
18+
return;
19+
}
20+
21+
// Clean up comments when components are destroyed.
22+
const component = this.$options.__file || this.$options.__name || 'Anonymous';
23+
const parent = this.$el.parentNode;
1924

20-
if (parent) {
21-
let node = this.$el.previousSibling;
22-
while (node && node.nodeType === Node.COMMENT_NODE) {
23-
if (node.nodeValue === ` Start component: ${component} `) {
24-
parent.removeChild(node);
25-
break;
26-
}
27-
node = node.previousSibling;
25+
if (parent) {
26+
let node = this.$el.previousSibling;
27+
while (node && node.nodeType === Node.COMMENT_NODE) {
28+
if (node.nodeValue === ` Start component: ${component} `) {
29+
parent.removeChild(node);
30+
break;
2831
}
32+
node = node.previousSibling;
33+
}
2934

30-
node = this.$el.nextSibling;
31-
while (node && node.nodeType === Node.COMMENT_NODE) {
32-
if (node.nodeValue === ` End component: ${component} `) {
33-
parent.removeChild(node);
34-
break;
35-
}
36-
node = node.nextSibling;
35+
node = this.$el.nextSibling;
36+
while (node && node.nodeType === Node.COMMENT_NODE) {
37+
if (node.nodeValue === ` End component: ${component} `) {
38+
parent.removeChild(node);
39+
break;
3740
}
41+
node = node.nextSibling;
3842
}
3943
}
4044
},

0 commit comments

Comments
 (0)