Skip to content

Commit eb1b084

Browse files
authoredFeb 13, 2025··
feat(schema): support blocking attributes (#489)
1 parent bae8fdb commit eb1b084

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed
 

‎packages/unhead/src/types/schema/link.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { HttpEventAttributes } from './attributes/event'
22
import type { GlobalAttributes } from './attributes/global'
33
import type { ReferrerPolicy } from './shared'
4+
import type { Blocking } from './struct/blocking'
45

56
export type LinkRelTypes = 'alternate' |
67
'author' |
@@ -33,7 +34,7 @@ export type LinkRelTypes = 'alternate' |
3334
'apple-touch-icon' |
3435
'apple-touch-startup-image'
3536

36-
export interface LinkBase extends Pick<GlobalAttributes, 'nonce'> {
37+
export interface LinkBase extends Pick<GlobalAttributes, 'nonce'>, Blocking {
3738
/**
3839
* This attribute is only used when rel="preload" or rel="prefetch" has been set on the `<link>` element.
3940
* It specifies the type of content being loaded by the `<link>`, which is necessary for request matching,

‎packages/unhead/src/types/schema/script.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import type { Booleanable } from '../util'
22
import type { HttpEventAttributes } from './attributes/event'
33
import type { GlobalAttributes } from './attributes/global'
44
import type { ReferrerPolicy } from './shared'
5+
import type { Blocking } from './struct/blocking'
56

6-
export interface ScriptBase extends Pick<GlobalAttributes, 'nonce'> {
7+
export interface ScriptBase extends Pick<GlobalAttributes, 'nonce'>, Blocking {
78
/**
89
* For classic scripts, if the async attribute is present,
910
* then the classic script will be fetched in parallel to parsing and evaluated as soon as it is available.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Represents the possible blocking tokens for an element.
3+
*/
4+
export type BlockingToken = 'render'
5+
6+
/**
7+
* Represents the blocking attribute for an element.
8+
* The blocking attribute must have a value that is an unordered set of unique space-separated tokens,
9+
* each of which are possible blocking tokens.
10+
*/
11+
export interface Blocking {
12+
/**
13+
* The blocking attribute indicates that certain operations should be blocked on the fetching of an external resource.
14+
* The value is an unordered set of unique space-separated tokens, each of which are possible blocking tokens.
15+
*
16+
* @example
17+
* blocking: "render"
18+
*/
19+
blocking?: BlockingToken | string // escape hatch
20+
}

‎packages/unhead/src/types/schema/style.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
export interface Style {
1+
import type { Blocking } from './struct/blocking'
2+
3+
export interface Style extends Blocking {
24
/**
35
* This attribute defines which media the style should be applied to.
46
* Its value is a media query, which defaults to all if the attribute is missing.

0 commit comments

Comments
 (0)
Please sign in to comment.