Skip to content

Commit 6704168

Browse files
committed
apply pull Khan#342
1 parent dc4269a commit 6704168

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

src/exports.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,26 @@ const StyleSheetServer = typeof window !== 'undefined'
8989
},
9090
};
9191
},
92+
/**
93+
* Prevent styles from being injected into the DOM.
94+
*
95+
* This is useful in situations where you do not have an available DOM
96+
* but are still considering walking the tree without calling a renderFunc
97+
*
98+
* Should be paired with a subsequent call to
99+
* clearBufferAndResumeStyleInjection.
100+
*/
101+
suppressStyleInjection() {
102+
reset();
103+
startBuffering();
104+
},
105+
106+
/**
107+
* Opposite method of suppressStyleInjection.
108+
*/
109+
clearBufferAndResumeStyleInjection() {
110+
reset();
111+
},
92112
};
93113

94114
/**

typings/index.d.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,20 @@ interface StaticRendererResult {
7474
*/
7575
interface StyleSheetServerStatic {
7676
renderStatic(renderFunc: () => string): StaticRendererResult;
77+
/**
78+
* Prevent styles from being injected into the DOM.
79+
*
80+
* This is useful in situations where you do not have an available DOM
81+
* but are still considering walking the tree without calling a renderFunc
82+
*
83+
* Should be paired with a subsequent call to
84+
* clearBufferAndResumeStyleInjection.
85+
*/
86+
suppressStyleInjection(): void;
87+
/**
88+
* Opposite method of suppressStyleInjection.
89+
*/
90+
clearBufferAndResumeStyleInjection(): void;
7791
}
7892

7993
export var StyleSheetServer: StyleSheetServerStatic;

0 commit comments

Comments
 (0)