-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #561 from microsoft/samart/styleSpeed
AdoptedStyles and Slot fixes
- Loading branch information
Showing
13 changed files
with
120 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
let version = "0.7.25"; | ||
let version = "0.7.26"; | ||
export default version; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { Metric } from "@clarity-types/data"; | ||
import { StyleSheetState } from "@clarity-types/layout"; | ||
import * as core from "@src/core"; | ||
import * as metric from "@src/data/metric"; | ||
|
||
export let state: StyleSheetState[] = []; | ||
let replace: (text?: string) => Promise<CSSStyleSheet> = null; | ||
let replaceSync: (text?: string) => void = null; | ||
|
||
export function start(): void { | ||
reset(); | ||
|
||
if (replace === null) { | ||
replace = CSSStyleSheet.prototype.replace; | ||
CSSStyleSheet.prototype.replace = function(): Promise<CSSStyleSheet> { | ||
if (core.active()) { | ||
metric.max(Metric.ConstructedStyles, 1); | ||
} | ||
return replace.apply(this, arguments); | ||
}; | ||
} | ||
|
||
if (replaceSync === null) { | ||
replaceSync = CSSStyleSheet.prototype.replaceSync; | ||
CSSStyleSheet.prototype.replaceSync = function(): void { | ||
if (core.active()) { | ||
metric.max(Metric.ConstructedStyles, 1); | ||
} | ||
return replaceSync.apply(this, arguments); | ||
}; | ||
} | ||
} | ||
|
||
export function checkDocumentStyles(documentNode: Document): void { | ||
if (!documentNode?.adoptedStyleSheets) { | ||
// if we don't have adoptedStyledSheets on the Node passed to us, we can short circuit. | ||
return; | ||
} | ||
metric.max(Metric.ConstructedStyles, 1); | ||
} | ||
|
||
export function compute(): void { | ||
checkDocumentStyles(document); | ||
} | ||
|
||
export function reset(): void { | ||
state = []; | ||
} | ||
|
||
export function stop(): void { | ||
reset(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters