From 6d50ecc73bc61810a067e81267af3f85544826da Mon Sep 17 00:00:00 2001 From: Masquerade Circus Date: Fri, 27 Mar 2020 17:01:28 -0600 Subject: [PATCH] test(directives): add v-skip directive test --- lib/index.js | 4 ++-- test/directives_test.js | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 69d6292..f9d2c11 100644 --- a/lib/index.js +++ b/lib/index.js @@ -436,11 +436,11 @@ function valyrian() { }); v.directive('v-html', (html, vnode) => { vnode.dom.innerHTML = html; - vnode.props['v-skip'] = true; + vnode.props[skip] = true; }); v.directive('v-text', (text, vnode) => { vnode.dom.textContent = text; - vnode.props['v-skip'] = true; + vnode.props[skip] = true; }); return v; diff --git a/test/directives_test.js b/test/directives_test.js index faf4309..35d3f56 100644 --- a/test/directives_test.js +++ b/test/directives_test.js @@ -397,6 +397,30 @@ describe('Directives', () => { }); }); + /** + * The v-skip directive is used to prevent the patch of children vnodes but allow the patch of dom attributes + * Its main use will be along with other custom directives to prevent the children patch step + */ + describe('v-skip', () => { + it('should prevent child patching step', () => { + let Store = { + id: 'example', + children: 'Hello world' + }; + + let Component = () =>
{Store.children}
; + let result = v.mount('body', Component); + expect(result).toEqual('
'); + + Store.id = 'example-updated'; + Store.children = 'Hello John Doe'; + + let result2 = v.update(); + + expect(result2).toEqual('
'); + }); + }); + /** * The v-html directive is used to direct raw html render to increase performance * We can use this directive to replace the v.trust use like in this test @@ -430,5 +454,6 @@ describe('Directives', () => { expect(result).toEqual('
Hello world
'); }); }); + });