-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix: use node.baseURI for stringifying stylesheet hrefs #1705
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
base: master
Are you sure you want to change the base?
fix: use node.baseURI for stringifying stylesheet hrefs #1705
Conversation
🦋 Changeset detectedLatest commit: 1bfa38c The changes in this PR will be included in the next version bump. This PR includes changesets to release 19 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
Pull Request Overview
This PR updates the stylesheet stringification logic to use ownerNode.baseURI
for resolving URLs in inline <style>
sheets and adds corresponding tests.
- Swap fallback from
ownerDocument.location.href
toownerNode.baseURI
- Add unit tests for null rules,
.cssRules
fallback, and inline stylesheet baseURI resolution - Include a changeset entry for the patch release
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
File | Description |
---|---|
packages/rrweb-snapshot/test/utils.test.ts | Added tests for stringifyStylesheet handling of missing rules, .cssRules , and inline baseURI resolution |
packages/rrweb-snapshot/src/utils.ts | Changed fallback logic in stringifyStylesheet to use ownerNode.baseURI instead of ownerDocument.location.href |
.changeset/lucky-trainers-joke.md | Added patch-level changeset note |
Comments suppressed due to low confidence (2)
packages/rrweb-snapshot/test/utils.test.ts:302
- [nitpick] Consider adding a test case to verify that when
stylesheet.href
is present alongsideownerNode.baseURI
, the function still prefersstylesheet.href
overbaseURI
.
it('uses ownerNode.baseURI for inline styles', () => {
packages/rrweb-snapshot/test/utils.test.ts:293
- [nitpick] It may be worth adding a test for the scenario where
.rules
is defined but.cssRules
is missing, to ensure.rules
is correctly prioritized.
it('stringifies rules using .cssRules if .rules is missing', () => {
Would you mind running |
f2dcc84
to
1bfa38c
Compare
@eoghanmurray pushed the lint fix just now |
Prioritize using the href from base tag (if present) when stringifying urls in inline stylesheets. Node.baseURI does just this. If a base tag is not present, it falls back to location.href.