-
Notifications
You must be signed in to change notification settings - Fork 60
fix(dom): resolve <slot> projection when flattening shadow DOM (PER-10812) #2437
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -147,12 +147,12 @@ export function serializeFrames({ dom, clone, warnings, resources, enableJavaScr | |
| cloneEl.setAttribute('srcdoc', p.createHTML ? p.createHTML(serialized.html) : serialized.html); | ||
| } catch { } | ||
|
|
||
| cloneEl.removeAttribute('src'); | ||
| cloneEl?.removeAttribute('src'); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Medium] Optional chaining is a partial fix — the accessible-frame branch above still assumes a non-null When a flattened host projects no Suggestion: Bail out once right after let cloneEl = clone.querySelector(`[data-percy-element-id="${percyElementId}"]`);
// no counterpart in the clone means the iframe wasn't rendered — e.g. light
// DOM content no <slot> projected, which the browser doesn't render
if (!cloneEl) continue;Both Reviewer: stack-code-reviewer |
||
|
|
||
| // delete inaccessible frames built with js when js is disabled because they | ||
| // break asset discovery by creating non-captured requests that hang | ||
| } else if (!enableJavaScript && builtWithJs) { | ||
| cloneEl.remove(); | ||
| cloneEl?.remove(); | ||
| } | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Low] Unquoted attribute-selector template, inconsistent with the sibling serializers
serialize-inputs.js,serialize-video.js,serialize-frames.js,serialize-cssom.jsandserialize-dom.jsall quote the attribute value. This line matches the pre-existing unquoted selector increateAndInsertImageElementin the same file, so it's locally consistent — but it copies a latent fragility: an unquoted CSS attribute value must be a valid CSS identifier. Todayuid()returns_${random}and is always valid, so it works; if the ID format ever changes,querySelectorthrows aSyntaxErrorinstead of returningnull, turning a correct "not projected, skip" into a reported canvas-serialization error.Suggestion:
Reviewer: stack-code-reviewer