Skip to content

Commit a7f9bbe

Browse files
committed
Add support for parsing a byte stream and fetching @import style sheet
Adding support for one depends on adding support for the other, since parsing a byte stream requires looking up an encoding in HTTP headers. The implementation of "fetch a style resource" uses fetch() from undici, which uses the same "fetch" algorithm but: - it does not make the response opaque for the user (which is is needed here) - it does not check CORS headers (which has been implemented) - it does not set credentials (which will be implemented in a future commit) fetch() can do everything that an implementation with get() or request() from node can do. None can set the request initiator reported to the Performance API, nor the use-URL-credentials flag to authenticate with credentials in the URL, which could be circumvented later. Adding the style sheet to document.styleSheets, aborting fetch() when the rule is discarded by the parser, fetching the style sheet when its media condition becomes true, setting document.cookies with entries defined in the response, also have been postponed. This implementation has multiple deviations from the specifications, which will remain undocumented since "fetch a style resource" and "fetch @import style sheet" are objectively more drafts than carefully reviewed algorithms. This commit also includes minor changes not directly related.
1 parent 5b2a9f7 commit a7f9bbe

25 files changed

+925
-91
lines changed
50 Bytes
Binary file not shown.
50 Bytes
Binary file not shown.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@charset "shift-jis";
2+
3+
style { content: "€"; }

__tests__/imported/bom-utf-8.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
style { content: "€"; }
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@charset "shift-jis";
2+
3+
style { content: ""; }
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@charset "utf-16";
2+
3+
style { content: "€"; }
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@charset "utf-16be";
2+
3+
style { content: "€"; }

__tests__/imported/circular-a.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@import "circular-b.css";

__tests__/imported/circular-b.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@import "circular-a.css";

__tests__/imported/css/sheet.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
style { content: "css/sheet.css" }

0 commit comments

Comments
 (0)