Skip to content

Commit d455e0b

Browse files
jaj1014github-actions[bot]
authored andcommitted
Apply formatting changes
1 parent 13ad056 commit d455e0b

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

packages/rrdom/src/diff.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ function diffChildren(
383383
nodeMatching(oldEndNode, newStartNode, replayer.mirror, rrnodeMirror)
384384
) {
385385
try {
386-
handleInsertBefore(oldTree, oldEndNode, oldStartNode)
386+
handleInsertBefore(oldTree, oldEndNode, oldStartNode);
387387
} catch (e) {
388388
console.warn(e);
389389
}
@@ -577,7 +577,9 @@ export function nodeMatching(
577577
/**
578578
* Copies CSSRules and their position from HTML style element which don't exist in it's innerText
579579
*/
580-
export function getInsertedStylesFromElement(styleElement: HTMLStyleElement): Array<{ index: number, cssRuleText: string}> | undefined {
580+
export function getInsertedStylesFromElement(
581+
styleElement: HTMLStyleElement,
582+
): Array<{ index: number; cssRuleText: string }> | undefined {
581583
const elementCssRules = styleElement.sheet?.cssRules;
582584
if (!elementCssRules || !elementCssRules.length) return;
583585
// style sheet w/ innerText styles to diff with actual and get only inserted styles
@@ -587,7 +589,8 @@ export function getInsertedStylesFromElement(styleElement: HTMLStyleElement): Ar
587589
const innerTextStylesMap: { [key: string]: CSSRule } = {};
588590

589591
for (let i = 0; i < tempStyleSheet.cssRules.length; i++) {
590-
innerTextStylesMap[tempStyleSheet.cssRules[i].cssText] = tempStyleSheet.cssRules[i];
592+
innerTextStylesMap[tempStyleSheet.cssRules[i].cssText] =
593+
tempStyleSheet.cssRules[i];
591594
}
592595

593596
const insertedStylesStyleSheet = [];
@@ -598,7 +601,7 @@ export function getInsertedStylesFromElement(styleElement: HTMLStyleElement): Ar
598601
if (!innerTextStylesMap[cssRuleText]) {
599602
insertedStylesStyleSheet.push({
600603
index: i,
601-
cssRuleText
604+
cssRuleText,
602605
});
603606
}
604607
}
@@ -610,11 +613,17 @@ export function getInsertedStylesFromElement(styleElement: HTMLStyleElement): Ar
610613
* Conditionally copy insertedStyles for STYLE nodes and apply after calling insertBefore'
611614
* For non-STYLE nodes, just insertBefore
612615
*/
613-
function handleInsertBefore(oldTree: Node, nodeToMove: Node, insertBeforeNode: Node | null): void {
616+
function handleInsertBefore(
617+
oldTree: Node,
618+
nodeToMove: Node,
619+
insertBeforeNode: Node | null,
620+
): void {
614621
let insertedStyles;
615622

616623
if (nodeToMove.nodeName === 'STYLE') {
617-
insertedStyles = getInsertedStylesFromElement(nodeToMove as HTMLStyleElement);
624+
insertedStyles = getInsertedStylesFromElement(
625+
nodeToMove as HTMLStyleElement,
626+
);
618627
}
619628

620629
oldTree.insertBefore(nodeToMove, insertBeforeNode);

packages/rrweb/test/events/moving-style-sheet-on-diff.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,7 @@ const events: eventWithTime[] = [
158158
source: IncrementalSource.Mutation,
159159
texts: [],
160160
attributes: [],
161-
removes: [
162-
{ parentId: 4, id: 7 }
163-
],
161+
removes: [{ parentId: 4, id: 7 }],
164162
adds: [
165163
{
166164
parentId: 4,

0 commit comments

Comments
 (0)