snapshot
snapshot copied to clipboard
fix: snapshot all top level siblings of passed JQuery subjects
Fixes issue #23. When serializes DOM or react elements, instead of taking the first element of the passed JQuery object, we iterate through all top level elements and concatonate the serializations. So when serializing this dom:
<p>1</p>
<p>2</p>
<p>3<p>
The current JSON output is
"1": {
"tagName": "p",
"childNodes": [
{
"nodeName": "#text",
"nodeValue": "1"
}
]
}
and the current HTML output is
"1": "<p>1</p>"
Not that the last two p
tags are missing from the snapshots.
With this fix the JSON output becomes:
"1": [
{
"tagName": "p",
"childNodes": [
{
"nodeName": "#text",
"nodeValue": "1"
}
]
},
{
"tagName": "p",
"childNodes": [
{
"nodeName": "#text",
"nodeValue": "2"
}
]
},
{
"tagName": "p",
"childNodes": [
{
"nodeName": "#text",
"nodeValue": "3"
}
]
}
]
and the HTML output:
"1": "<p>1</p><p>2</p><p>3</p>"
@bahmutov for review
this is good @stuartlong but we need a demo test showing that this has been fixed. A simple index.html
with an element and a snapshot should be enough to confirm
Running into this right now! Any chance this PR could be finished up? 🙏