Comparing version 2.0.0-alpha.15 to 2.0.0-alpha.16
var __defProp = Object.defineProperty; | ||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
var __publicField = (obj, key, value) => { | ||
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); | ||
return value; | ||
}; | ||
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); | ||
var __defProp2 = Object.defineProperty; | ||
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
var __publicField2 = (obj, key, value) => { | ||
__defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value); | ||
return value; | ||
}; | ||
var __publicField2 = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value); | ||
var NodeType$1 = /* @__PURE__ */ ((NodeType2) => { | ||
@@ -29,4 +23,3 @@ NodeType2[NodeType2["Document"] = 0] = "Document"; | ||
var _a; | ||
if (!n) | ||
return -1; | ||
if (!n) return -1; | ||
const id = (_a = this.getMeta(n)) == null ? void 0 : _a.id; | ||
@@ -70,4 +63,3 @@ return id ?? -1; | ||
const meta = this.nodeMetaMap.get(oldNode); | ||
if (meta) | ||
this.nodeMetaMap.set(n, meta); | ||
if (meta) this.nodeMetaMap.set(n, meta); | ||
} | ||
@@ -101,4 +93,3 @@ this.idNodeMap.set(id, n); | ||
const value = style[name]; | ||
if (typeof value !== "string") | ||
continue; | ||
if (typeof value !== "string") continue; | ||
const normalizedName = hyphenate(name); | ||
@@ -112,4 +103,3 @@ properties.push(`${normalizedName}: ${value};`); | ||
const camelize = (str) => { | ||
if (CUSTOM_PROPERTY_REGEX.test(str)) | ||
return str; | ||
if (CUSTOM_PROPERTY_REGEX.test(str)) return str; | ||
return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : ""); | ||
@@ -148,11 +138,7 @@ }; | ||
contains(node) { | ||
if (!(node instanceof BaseRRNode)) | ||
return false; | ||
else if (node.ownerDocument !== this.ownerDocument) | ||
return false; | ||
else if (node === this) | ||
return true; | ||
if (!(node instanceof BaseRRNode)) return false; | ||
else if (node.ownerDocument !== this.ownerDocument) return false; | ||
else if (node === this) return true; | ||
while (node.parentNode) { | ||
if (node.parentNode === this) | ||
return true; | ||
if (node.parentNode === this) return true; | ||
node = node.parentNode; | ||
@@ -365,16 +351,11 @@ } | ||
style.setProperty = (name, value, priority) => { | ||
if (hyphenateRE2.test(name)) | ||
return; | ||
if (hyphenateRE2.test(name)) return; | ||
const normalizedName = camelize(name); | ||
if (!value) | ||
delete style[normalizedName]; | ||
else | ||
style[normalizedName] = value; | ||
if (priority === "important") | ||
style[normalizedName] += " !important"; | ||
if (!value) delete style[normalizedName]; | ||
else style[normalizedName] = value; | ||
if (priority === "important") style[normalizedName] += " !important"; | ||
this.attributes.style = toCSSText(style); | ||
}; | ||
style.removeProperty = (name) => { | ||
if (hyphenateRE2.test(name)) | ||
return ""; | ||
if (hyphenateRE2.test(name)) return ""; | ||
const normalizedName = camelize(name); | ||
@@ -514,4 +495,3 @@ const value = style[normalizedName] || ""; | ||
const className = String(item); | ||
if (this.classes.indexOf(className) >= 0) | ||
continue; | ||
if (this.classes.indexOf(className) >= 0) continue; | ||
this.classes.push(className); | ||
@@ -535,4 +515,3 @@ } | ||
function appendChild(parent, newChild) { | ||
if (newChild.parentNode) | ||
newChild.parentNode.removeChild(newChild); | ||
if (newChild.parentNode) newChild.parentNode.removeChild(newChild); | ||
if (parent.lastChild) { | ||
@@ -553,4 +532,3 @@ parent.lastChild.nextSibling = newChild; | ||
function insertBefore(parent, newChild, refChild) { | ||
if (!refChild) | ||
return appendChild(parent, newChild); | ||
if (!refChild) return appendChild(parent, newChild); | ||
if (refChild.parentNode !== parent) | ||
@@ -560,13 +538,9 @@ throw new Error( | ||
); | ||
if (newChild === refChild) | ||
return newChild; | ||
if (newChild.parentNode) | ||
newChild.parentNode.removeChild(newChild); | ||
if (newChild === refChild) return newChild; | ||
if (newChild.parentNode) newChild.parentNode.removeChild(newChild); | ||
newChild.previousSibling = refChild.previousSibling; | ||
refChild.previousSibling = newChild; | ||
newChild.nextSibling = refChild; | ||
if (newChild.previousSibling) | ||
newChild.previousSibling.nextSibling = newChild; | ||
else | ||
parent.firstChild = newChild; | ||
if (newChild.previousSibling) newChild.previousSibling.nextSibling = newChild; | ||
else parent.firstChild = newChild; | ||
newChild.parentElement = parent; | ||
@@ -584,8 +558,6 @@ newChild.parentNode = parent; | ||
child.previousSibling.nextSibling = child.nextSibling; | ||
else | ||
parent.firstChild = child.nextSibling; | ||
else parent.firstChild = child.nextSibling; | ||
if (child.nextSibling) | ||
child.nextSibling.previousSibling = child.previousSibling; | ||
else | ||
parent.lastChild = child.previousSibling; | ||
else parent.lastChild = child.previousSibling; | ||
child.previousSibling = null; | ||
@@ -703,4 +675,3 @@ child.nextSibling = null; | ||
const oldContentDocument = oldTree.contentDocument; | ||
if (!oldContentDocument) | ||
break; | ||
if (!oldContentDocument) break; | ||
diff( | ||
@@ -716,4 +687,3 @@ oldContentDocument, | ||
if (newRRElement.shadowRoot) { | ||
if (!oldElement.shadowRoot) | ||
oldElement.attachShadow({ mode: "open" }); | ||
if (!oldElement.shadowRoot) oldElement.attachShadow({ mode: "open" }); | ||
diffChildren( | ||
@@ -826,10 +796,7 @@ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
}; | ||
} else if (newTree.tagName === "IFRAME" && name === "srcdoc") | ||
continue; | ||
else | ||
oldTree.setAttribute(name, newValue); | ||
} else if (newTree.tagName === "IFRAME" && name === "srcdoc") continue; | ||
else oldTree.setAttribute(name, newValue); | ||
} | ||
for (const { name } of Array.from(oldAttributes)) | ||
if (!(name in newAttributes)) | ||
oldTree.removeAttribute(name); | ||
if (!(name in newAttributes)) oldTree.removeAttribute(name); | ||
newTree.scrollLeft && (oldTree.scrollLeft = newTree.scrollLeft); | ||
@@ -841,4 +808,3 @@ newTree.scrollTop && (oldTree.scrollTop = newTree.scrollTop); | ||
const newChildren = newTree.childNodes; | ||
if (oldChildren.length === 0 && newChildren.length === 0) | ||
return; | ||
if (oldChildren.length === 0 && newChildren.length === 0) return; | ||
let oldStartIndex = 0, oldEndIndex = oldChildren.length - 1, newStartIndex = 0, newEndIndex = newChildren.length - 1; | ||
@@ -954,4 +920,3 @@ let oldStartNode = oldChildren[oldStartIndex], oldEndNode = oldChildren[oldEndIndex], newStartNode = newChildren[newStartIndex], newEndNode = newChildren[newEndIndex]; | ||
const node = oldChildren[oldStartIndex]; | ||
if (!node || node.parentNode !== oldTree) | ||
continue; | ||
if (!node || node.parentNode !== oldTree) continue; | ||
try { | ||
@@ -977,6 +942,4 @@ oldTree.removeChild(node); | ||
let node = null; | ||
if (nodeId > -1) | ||
node = domMirror.getNode(nodeId); | ||
if (node !== null && sameNodeType(node, rrNode)) | ||
return node; | ||
if (nodeId > -1) node = domMirror.getNode(nodeId); | ||
if (node !== null && sameNodeType(node, rrNode)) return node; | ||
switch (rrNode.RRNodeType) { | ||
@@ -998,4 +961,3 @@ case NodeType$1.Document: | ||
node = document.createElementNS(NAMESPACES["svg"], tagName); | ||
} else | ||
node = document.createElement(rrNode.tagName); | ||
} else node = document.createElement(rrNode.tagName); | ||
break; | ||
@@ -1013,4 +975,3 @@ } | ||
} | ||
if (sn) | ||
domMirror.add(node, { ...sn }); | ||
if (sn) domMirror.add(node, { ...sn }); | ||
try { | ||
@@ -1023,4 +984,3 @@ createdNodeSet == null ? void 0 : createdNodeSet.add(node); | ||
function sameNodeType(node1, node2) { | ||
if (node1.nodeType !== node2.nodeType) | ||
return false; | ||
if (node1.nodeType !== node2.nodeType) return false; | ||
return node1.nodeType !== node1.ELEMENT_NODE || node1.tagName.toUpperCase() === node2.tagName; | ||
@@ -1031,4 +991,3 @@ } | ||
const node2Id = rrdomMirror.getId(node2); | ||
if (node1Id === -1 || node1Id !== node2Id) | ||
return false; | ||
if (node1Id === -1 || node1Id !== node2Id) return false; | ||
return sameNodeType(node1, node2); | ||
@@ -1222,4 +1181,3 @@ } | ||
const rrNode = buildFromNode(node, rrdom, domMirror, parentRRNode); | ||
if (rrNode === null) | ||
return; | ||
if (rrNode === null) return; | ||
if ( | ||
@@ -1256,4 +1214,3 @@ // if the parentRRNode isn't a RRIFrameElement | ||
var _a; | ||
if (!n) | ||
return -1; | ||
if (!n) return -1; | ||
const id = (_a = this.getMeta(n)) == null ? void 0 : _a.id; | ||
@@ -1295,4 +1252,3 @@ return id ?? -1; | ||
const meta = this.nodeMetaMap.get(oldNode); | ||
if (meta) | ||
this.nodeMetaMap.set(n, meta); | ||
if (meta) this.nodeMetaMap.set(n, meta); | ||
} | ||
@@ -1299,0 +1255,0 @@ this.idNodeMap.set(id, n); |
{ | ||
"name": "rrdom", | ||
"version": "2.0.0-alpha.15", | ||
"version": "2.0.0-alpha.16", | ||
"homepage": "https://github.com/rrweb-io/rrweb/tree/main/packages/rrdom#readme", | ||
@@ -33,7 +33,7 @@ "license": "MIT", | ||
"dev": "vite build --watch", | ||
"build": "tsc -noEmit && vite build", | ||
"build": "yarn turbo run prepublish", | ||
"check-types": "tsc -noEmit", | ||
"test": "vitest run", | ||
"test:watch": "vitest", | ||
"prepublish": "npm run build", | ||
"prepublish": "tsc -noEmit && vite build", | ||
"lint": "yarn eslint src/**/*.ts" | ||
@@ -45,3 +45,3 @@ }, | ||
"devDependencies": { | ||
"@rrweb/types": "^2.0.0-alpha.15", | ||
"@rrweb/types": "^2.0.0-alpha.16", | ||
"@types/puppeteer": "^5.4.4", | ||
@@ -52,9 +52,9 @@ "@typescript-eslint/eslint-plugin": "^5.23.0", | ||
"puppeteer": "^17.1.3", | ||
"typescript": "^4.9.0", | ||
"vite": "^5.2.8", | ||
"vite-plugin-dts": "^3.8.1" | ||
"typescript": "^5.4.5", | ||
"vite": "^5.3.1", | ||
"vite-plugin-dts": "^3.9.1" | ||
}, | ||
"dependencies": { | ||
"rrweb-snapshot": "^2.0.0-alpha.15" | ||
"rrweb-snapshot": "^2.0.0-alpha.16" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
785036
4493