Skip to content

Commit

Permalink
apply pull Khan#342
Browse files Browse the repository at this point in the history
  • Loading branch information
moaazsidat committed Apr 19, 2020
1 parent dc4269a commit 6704168
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/exports.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
},
};

/**
Expand Down
14 changes: 14 additions & 0 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 6704168

Please sign in to comment.