Repository navigation
feat: make collect_css and track_css_responses public to allow more scraping control - #8
Merged
Merged
Conversation
…re scraping control Co-authored-by: Joan León <1307927+nucliweb@users.noreply.github.com>
|
| 📦 Package | 📏 Base Size | 📏 Source Size | 📈 Size Change |
|---|---|---|---|
| @projectwallace/css-scraper | 5.7 kB | 6 kB | +303 B |
Contributor
|
Tried this branch in the page flow of the webperf-snippets CLI: tracking before Two things I noticed, both already in
Happy to send a PR for |
Member
Author
|
Yeah, please do! This library is really early stages and I haven't used it anywhere myself yet, so I'm probably missing heaps of test cases. |
bartveneman
pushed a commit
that referenced
this pull request
Nov 3, 2026
`CSSLinkSource` and `CSSImportSource` declare `media`, but it was never set, so a print stylesheet and one that applies came back the same. Follow-up to #8. - A `link` source carries the `media` attribute of its `<link>`, as written. - An `import` source carries the condition of its `@import` rule, read from the CSSOM, so as the browser serializes it. The walk follows nested imports and open shadow roots. - A rule inside a cross-origin stylesheet stays without `media`: the page cannot read those rules. - If one URL is imported twice with different conditions, the last one wins, since the sources are collapsed by URL. The fixtures with a media condition now expect it, and a new one covers `@import` in a `<style>` element. Nested imports and shadow roots go through the same walk, without a test of their own. Tried in the page flow of the webperf-snippets CLI, with throttling, on local pages.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After @nucliweb's suggestion. Basically took his idea 1:1 and made it the default in the readme because it's actually a better API that way.
Also decided to expose most of the types because that may be helpful in building up your own system of scraped css.
closes #5