diff --git a/src/snapshot.ts b/src/snapshot.ts index 3d04acc..0b9839b 100644 --- a/src/snapshot.ts +++ b/src/snapshot.ts @@ -525,6 +525,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 d7d76c6..a519045 100644 --- a/test/__snapshots__/integration.ts.snap +++ b/test/__snapshots__/integration.ts.snap @@ -202,6 +202,52 @@ exports[`[html file]: invalid-tagname.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 + + + + + + +
+ + + +
+
+ + + + +
+
+ + + + +
+
+ + +
+ + +