diff --git a/src/exports.js b/src/exports.js index e10a6cc..aa8c43c 100644 --- a/src/exports.js +++ b/src/exports.js @@ -89,6 +89,26 @@ const StyleSheetServer = typeof window !== 'undefined' }, }; }, + /** + * Prevent styles from being injected into the DOM. + * + * This is useful in situations where you do not have an available DOM + * but are still considering walking the tree without calling a renderFunc + * + * Should be paired with a subsequent call to + * clearBufferAndResumeStyleInjection. + */ + suppressStyleInjection() { + reset(); + startBuffering(); + }, + + /** + * Opposite method of suppressStyleInjection. + */ + clearBufferAndResumeStyleInjection() { + reset(); + }, }; /** diff --git a/typings/index.d.ts b/typings/index.d.ts index 8c68d68..a1b21dd 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -74,6 +74,20 @@ interface StaticRendererResult { */ interface StyleSheetServerStatic { renderStatic(renderFunc: () => string): StaticRendererResult; + /** + * Prevent styles from being injected into the DOM. + * + * This is useful in situations where you do not have an available DOM + * but are still considering walking the tree without calling a renderFunc + * + * Should be paired with a subsequent call to + * clearBufferAndResumeStyleInjection. + */ + suppressStyleInjection(): void; + /** + * Opposite method of suppressStyleInjection. + */ + clearBufferAndResumeStyleInjection(): void; } export var StyleSheetServer: StyleSheetServerStatic;