Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix RUN-1030: add pseudo element CSS rules #291

Merged
merged 1 commit into from
Dec 31, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ constexpr auto P = recordreplay::Print; // because we are lazy?
const char* gReplayScript = R""""(
(() => {

const EmptyArray = Object.freeze([]); // reduce unnecessary mem churn

const Verbose = 1;
const VerboseCommands = Verbose;

Expand Down Expand Up @@ -1954,13 +1956,12 @@ function convertCdpToRrpCssRules(nodeObj, cdpMatchedStyles) {
const appliedRules = [];

const {
matchedRules = [],
inheritedEntries = []
matchedRules = EmptyArray,
inheritedEntries = EmptyArray,
pseudoIdMatches = EmptyArray
} = cdpMatchedStyles;

function addCdpRule(cdpRule) {
// TODO: add pseudoElement support - https://linear.app/replay/issue/RUN-953
const pseudoElement = undefined;
function addCdpRule(cdpRule, pseudoElement = undefined) {
const rrpRuleId = registerCdpAsRrpCssRule(nodeObj, cdpRule);
const appliedRule = {
rule: rrpRuleId,
Expand All @@ -1980,9 +1981,21 @@ function convertCdpToRrpCssRules(nodeObj, cdpMatchedStyles) {
matchedCSSRules // inherited non-inline rules
} = cdpInheritedEntry;

for (const matchedRule of matchedCSSRules) {
// matchedRule.matchingSelectors
addCdpRule(matchedRule.rule);
for (const match of matchedCSSRules) {
// match.matchingSelectors
addCdpRule(match.rule);
}
}

for (const pseudoMatch of pseudoIdMatches) {
const {
// see: https://chromedevtools.github.io/devtools-protocol/tot/DOM/#type-PseudoType
pseudoType,
// pseudoIdentifier,
matches
} = pseudoMatch;
for (const match of matches) {
addCdpRule(match.rule, pseudoType);
}
}

Expand Down