* Feat: Add support for replaying :defined pseudo-class of custom elements * add isCustom flag to serialized elements Applying Justin's review suggestion * fix code lint error * add custom element event * fix: tests (#1348) * Update packages/rrweb/src/record/observer.ts * Update packages/rrweb/src/record/observer.ts --------- Co-authored-by: Nafees Nehar <nafees87n@gmail.com> Co-authored-by: Justin Halsall <Juice10@users.noreply.github.com>
90 lines
2.2 KiB
TypeScript
90 lines
2.2 KiB
TypeScript
import { EventType } from '@rrweb/types';
|
|
import type { eventWithTime } from '@rrweb/types';
|
|
|
|
const now = Date.now();
|
|
const events: eventWithTime[] = [
|
|
{
|
|
type: EventType.DomContentLoaded,
|
|
data: {},
|
|
timestamp: now,
|
|
},
|
|
{
|
|
type: EventType.Load,
|
|
data: {},
|
|
timestamp: now + 100,
|
|
},
|
|
{
|
|
type: EventType.Meta,
|
|
data: {
|
|
href: 'http://localhost',
|
|
width: 1000,
|
|
height: 800,
|
|
},
|
|
timestamp: now + 100,
|
|
},
|
|
// full snapshot:
|
|
{
|
|
data: {
|
|
node: {
|
|
id: 1,
|
|
type: 0,
|
|
childNodes: [
|
|
{ id: 2, name: 'html', type: 1, publicId: '', systemId: '' },
|
|
{
|
|
id: 3,
|
|
type: 2,
|
|
tagName: 'html',
|
|
attributes: { lang: 'en' },
|
|
childNodes: [
|
|
{
|
|
id: 4,
|
|
type: 2,
|
|
tagName: 'head',
|
|
attributes: {},
|
|
childNodes: [
|
|
{
|
|
id: 5,
|
|
type: 2,
|
|
tagName: 'style',
|
|
childNodes: [
|
|
{
|
|
id: 6,
|
|
type: 3,
|
|
isStyle: true,
|
|
// Set style of defined custom element to display: block
|
|
// Set undefined custom element to display: none
|
|
textContent:
|
|
'custom-element:not(:defined) { display: none;} \n custom-element:defined { display: block; }',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
{
|
|
id: 7,
|
|
type: 2,
|
|
tagName: 'body',
|
|
attributes: {},
|
|
childNodes: [
|
|
{
|
|
id: 8,
|
|
type: 2,
|
|
tagName: 'custom-element',
|
|
childNodes: [],
|
|
isCustom: true,
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
initialOffset: { top: 0, left: 0 },
|
|
},
|
|
type: EventType.FullSnapshot,
|
|
timestamp: now + 100,
|
|
},
|
|
];
|
|
|
|
export default events;
|