Skip to content

Commit 8ef6f96

Browse files
committed
Revert "Cast enabled option to a string"
This reverts commit 17401aa.
1 parent 17401aa commit 8ef6f96

File tree

3 files changed

+2
-99
lines changed

3 files changed

+2
-99
lines changed

src/mixins/componentDebug.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
export function createComponentDebugMixin(options = {}) {
22
const { enabled = process.env.NODE_ENV === 'development' } = options;
33

4-
// Handle string values from environment variables
5-
const isEnabled = typeof enabled === 'string' ? enabled.toLowerCase() === 'true' : Boolean(enabled);
6-
74
return {
85
mounted() {
9-
if (!isEnabled) {
6+
if (!enabled) {
107
return;
118
}
129

@@ -19,7 +16,7 @@ export function createComponentDebugMixin(options = {}) {
1916
this.$el.parentNode?.insertBefore(endComment, this.$el.nextSibling);
2017
},
2118
beforeUnmount() {
22-
if (!isEnabled) {
19+
if (!enabled) {
2320
return;
2421
}
2522

tests/debugMixin.test.js

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -299,50 +299,4 @@ describe('createComponentDebugMixin', () => {
299299

300300
wrapper.unmount();
301301
});
302-
303-
it('handles string "false" as disabled', () => {
304-
process.env.NODE_ENV = 'development';
305-
306-
const TestComponent = {
307-
name: 'TestComponent',
308-
__file: 'src/components/TestComponent.vue',
309-
mixins: [createComponentDebugMixin({ enabled: 'false' })],
310-
template: '<div>Test Content</div>',
311-
};
312-
313-
const wrapper = mount(TestComponent, {
314-
attachTo: document.body,
315-
});
316-
317-
const element = wrapper.element;
318-
319-
// Should not have comment siblings when disabled via string "false"
320-
expect(element.previousSibling).toBeNull();
321-
expect(element.nextSibling).toBeNull();
322-
323-
wrapper.unmount();
324-
});
325-
326-
it('handles string "true" as enabled', () => {
327-
process.env.NODE_ENV = 'production';
328-
329-
const TestComponent = {
330-
name: 'TestComponent',
331-
__file: 'src/components/TestComponent.vue',
332-
mixins: [createComponentDebugMixin({ enabled: 'true' })],
333-
template: '<div>Test Content</div>',
334-
};
335-
336-
const wrapper = mount(TestComponent, {
337-
attachTo: document.body,
338-
});
339-
340-
const element = wrapper.element;
341-
342-
// Should have comments even in production when explicitly enabled via string "true"
343-
expect(element.previousSibling?.nodeType).toBe(Node.COMMENT_NODE);
344-
expect(element.nextSibling?.nodeType).toBe(Node.COMMENT_NODE);
345-
346-
wrapper.unmount();
347-
});
348302
});

tests/plugin.test.js

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -234,52 +234,4 @@ describe('VueComponentDebug Plugin', () => {
234234

235235
wrapper.unmount();
236236
});
237-
238-
it('handles string "false" from environment variables', () => {
239-
process.env.NODE_ENV = 'development';
240-
241-
const TestComponent = {
242-
name: 'TestComponent',
243-
template: '<div>Test</div>',
244-
};
245-
246-
const wrapper = mount(TestComponent, {
247-
attachTo: document.body,
248-
global: {
249-
plugins: [[VueComponentDebug, { enabled: 'false' }]],
250-
},
251-
});
252-
253-
const element = wrapper.element;
254-
255-
// Should not have comments when disabled via string "false"
256-
expect(element.previousSibling).toBeNull();
257-
expect(element.nextSibling).toBeNull();
258-
259-
wrapper.unmount();
260-
});
261-
262-
it('handles string "true" from environment variables', () => {
263-
process.env.NODE_ENV = 'production';
264-
265-
const TestComponent = {
266-
name: 'TestComponent',
267-
template: '<div>Test</div>',
268-
};
269-
270-
const wrapper = mount(TestComponent, {
271-
attachTo: document.body,
272-
global: {
273-
plugins: [[VueComponentDebug, { enabled: 'true' }]],
274-
},
275-
});
276-
277-
const element = wrapper.element;
278-
279-
// Should have comments when enabled via string "true"
280-
expect(element.previousSibling?.nodeType).toBe(Node.COMMENT_NODE);
281-
expect(element.nextSibling?.nodeType).toBe(Node.COMMENT_NODE);
282-
283-
wrapper.unmount();
284-
});
285237
});

0 commit comments

Comments
 (0)