Feat: Add support for replaying :defined pseudo-class of custom elements (#1155)
* 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>
This commit is contained in:
@@ -142,6 +142,18 @@ function buildNode(
|
||||
if (n.isSVG) {
|
||||
node = doc.createElementNS('http://www.w3.org/2000/svg', tagName);
|
||||
} else {
|
||||
if (
|
||||
// If the tag name is a custom element name
|
||||
n.isCustom &&
|
||||
// If the browser supports custom elements
|
||||
doc.defaultView?.customElements &&
|
||||
// If the custom element hasn't been defined yet
|
||||
!doc.defaultView.customElements.get(n.tagName)
|
||||
)
|
||||
doc.defaultView.customElements.define(
|
||||
n.tagName,
|
||||
class extends doc.defaultView.HTMLElement {},
|
||||
);
|
||||
node = doc.createElement(tagName);
|
||||
}
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user