From 5f010114fd6203d0e699f739dd2efb75ee723de6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aar=C3=B3n=20J=2E=20Montes?= Date: Mon, 23 Jan 2023 19:23:28 -0600 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20Adding=20support=20f?= =?UTF-8?q?or=20important=20modifier=20on=20v-show?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adding support for important modifier on v-show directive --- packages/server-renderer/src/directives/show.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/server-renderer/src/directives/show.ts b/packages/server-renderer/src/directives/show.ts index 4a84fc6168c..a14a4c2a92b 100644 --- a/packages/server-renderer/src/directives/show.ts +++ b/packages/server-renderer/src/directives/show.ts @@ -4,9 +4,9 @@ export default function show(node: VNodeWithData, dir: VNodeDirective) { if (!dir.value) { const style: any = node.data.style || (node.data.style = {}) if (Array.isArray(style)) { - style.push({ display: 'none' }) + style.push({ display: dir?.modifiers?.important ? 'none !important' : 'none' }) } else { - style.display = 'none' + style.display = dir?.modifiers?.important ? 'none !important' : 'none' } } } From a1d1113117b5b8c5e4ddecf2577237c2d2182d20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aar=C3=B3n=20J=2E=20Montes?= Date: Mon, 23 Jan 2023 19:23:55 -0600 Subject: [PATCH 2/2] =?UTF-8?q?test:=20=F0=9F=92=8D=20Adding=20unit=20test?= =?UTF-8?q?=20for=20important=20modifier?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/unit/features/directives/show.spec.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/unit/features/directives/show.spec.ts b/test/unit/features/directives/show.spec.ts index 86641b4af4f..823f9d4ec8f 100644 --- a/test/unit/features/directives/show.spec.ts +++ b/test/unit/features/directives/show.spec.ts @@ -8,6 +8,14 @@ describe('Directive v-show', () => { }).$mount() expect(vm.$el.firstChild.style.display).toBe('') }) + + it('should check not show value is truthy with display none important', () => { + const vm = new Vue({ + template: '
hello
', + data: { foo: false } + }).$mount() + expect(vm.$el.firstChild.style.display).toBe('none !important') + }) it('should check show value is falsy', () => { const vm = new Vue({