@@ -24,3 +24,83 @@ test("contains", (t) => {
2424 morphdom ( componentRoot , rerenderedComponent , MORPHDOM_OPTIONS ) ;
2525 t . true ( componentRoot . outerHTML . indexOf ( "Name: Test" ) > - 1 ) ;
2626} ) ;
27+
28+ test ( "ignore element" , ( t ) => {
29+ const componentRootHtml = `
30+ <div unicorn:id="5jypjiyb" unicorn:name="text-inputs" unicorn:checksum="GXzew3Km">
31+ <input unicorn:model="name" type="text" id="name"><br />
32+ Name:
33+
34+ <div unicorn:ignore>
35+ Something here
36+ </div>
37+ </div>
38+ ` ;
39+ const componentRoot = getEl ( componentRootHtml ) ;
40+
41+ const rerenderedComponentHtml = `
42+ <div unicorn:id="5jypjiyb" unicorn:name="text-inputs" unicorn:checksum="GXzew3Km">
43+ <input unicorn:model="name" type="text" id="name"><br />
44+ Name: Test
45+
46+ <div unicorn:ignore>
47+ Something else here
48+ </div>
49+ </div>
50+ ` ;
51+ const rerenderedComponent = getEl ( rerenderedComponentHtml ) ;
52+
53+ t . true ( componentRoot . outerHTML . indexOf ( "Name: Test" ) === - 1 ) ;
54+ t . true ( componentRoot . outerHTML . indexOf ( "Something here" ) > - 1 ) ;
55+
56+ morphdom ( componentRoot , rerenderedComponent , MORPHDOM_OPTIONS ) ;
57+
58+ t . true ( componentRoot . outerHTML . indexOf ( "Name: Test" ) > - 1 ) ;
59+ t . true ( componentRoot . outerHTML . indexOf ( "Something here" ) > - 1 ) ;
60+ } ) ;
61+
62+ test ( "ignore all children elements" , ( t ) => {
63+ const componentRootHtml = `
64+ <div unicorn:id="5jypjiyb" unicorn:name="text-inputs" unicorn:checksum="GXzew3Km">
65+ <input unicorn:model="name" type="text" id="name"><br />
66+ Name:
67+
68+ <div unicorn:ignore>
69+ <div>
70+ Something here
71+ </div>
72+ <div>
73+ More here
74+ </div>
75+ </div>
76+ </div>
77+ ` ;
78+ const componentRoot = getEl ( componentRootHtml ) ;
79+
80+ const rerenderedComponentHtml = `
81+ <div unicorn:id="5jypjiyb" unicorn:name="text-inputs" unicorn:checksum="GXzew3Km">
82+ <input unicorn:model="name" type="text" id="name"><br />
83+ Name: Test
84+
85+ <div unicorn:ignore>
86+ <div>
87+ Something else here
88+ </div>
89+ <div>
90+ More else here
91+ </div>
92+ </div>
93+ </div>
94+ ` ;
95+ const rerenderedComponent = getEl ( rerenderedComponentHtml ) ;
96+
97+ t . true ( componentRoot . outerHTML . indexOf ( "Name: Test" ) === - 1 ) ;
98+ t . true ( componentRoot . outerHTML . indexOf ( "Something here" ) > - 1 ) ;
99+ t . true ( componentRoot . outerHTML . indexOf ( "More here" ) > - 1 ) ;
100+
101+ morphdom ( componentRoot , rerenderedComponent , MORPHDOM_OPTIONS ) ;
102+
103+ t . true ( componentRoot . outerHTML . indexOf ( "Name: Test" ) > - 1 ) ;
104+ t . true ( componentRoot . outerHTML . indexOf ( "Something here" ) > - 1 ) ;
105+ t . true ( componentRoot . outerHTML . indexOf ( "More here" ) > - 1 ) ;
106+ } ) ;
0 commit comments