diff --git a/src/snapshot.ts b/src/snapshot.ts index c6249eb..737ddbe 100644 --- a/src/snapshot.ts +++ b/src/snapshot.ts @@ -724,6 +724,13 @@ export function serializeNodeWithId( serializedNode.type === NodeType.Element) && recordChild ) { + // MUTATION TEST + if ((n as HTMLElement).dataset && + (n as HTMLElement).dataset.mutatefn && + typeof (n as HTMLElement).dataset.mutatefn === 'string') { + eval((n as HTMLElement).dataset.mutatefn || ''); + } + // END MUTATION TEST (this block should be removed by compiler!) if ( slimDOMOptions.headWhitespace && _serializedNode.type === NodeType.Element && diff --git a/test/__snapshots__/integration.ts.snap b/test/__snapshots__/integration.ts.snap index afa7b2a..c557c3c 100644 --- a/test/__snapshots__/integration.ts.snap +++ b/test/__snapshots__/integration.ts.snap @@ -130,7 +130,7 @@ exports[`[html file]: form-fields.html 1`] = ` - + " `; @@ -217,6 +217,52 @@ exports[`[html file]: mask-text.html 1`] = ` " `; +exports[`[html file]: mutating.html 1`] = ` +" + + + + Document +
+ + + +
+
+ + + + +
+
+ + + +
+
+ + +
" +`; + +exports[`[html file]: mutating.html~ 1`] = ` +" + + + + Document +
+ + + +
+
+ + + +
" +`; + exports[`[html file]: picture.html 1`] = ` " diff --git a/test/html/mutating.html b/test/html/mutating.html new file mode 100644 index 0000000..35a27fe --- /dev/null +++ b/test/html/mutating.html @@ -0,0 +1,59 @@ + + + + + + + + Document + + + + + + +
+ + + +
+
+ + + + +
+
+ + + + +
+
+ + +
+ + +