MCPcopy Index your code
hub / github.com/react/react / pushStyle

Function pushStyle

packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js:3058–3189  ·  view source on GitHub ↗
(
  target: Array<Chunk | PrecomputedChunk>,
  props: Object,
  resumableState: ResumableState,
  renderState: RenderState,
  hoistableState: null | HoistableState,
  textEmbedded: boolean,
  formatContext: FormatContext,
)

Source from the content-addressed store, hash-verified

3056}
3057
3058function pushStyle(
3059 target: Array<Chunk | PrecomputedChunk>,
3060 props: Object,
3061 resumableState: ResumableState,
3062 renderState: RenderState,
3063 hoistableState: null | HoistableState,
3064 textEmbedded: boolean,
3065 formatContext: FormatContext,
3066): ReactNodeList {
3067 const noscriptTagInScope = formatContext.tagScope & NOSCRIPT_SCOPE;
3068 if (__DEV__) {
3069 if (hasOwnProperty.call(props, 'children')) {
3070 const children = props.children;
3071
3072 const child = Array.isArray(children)
3073 ? children.length < 2
3074 ? children[0]
3075 : null
3076 : children;
3077
3078 if (
3079 typeof child === 'function' ||
3080 typeof child === 'symbol' ||
3081 Array.isArray(child)
3082 ) {
3083 const childType =
3084 typeof child === 'function'
3085 ? 'a Function'
3086 : typeof child === 'symbol'
3087 ? 'a Sybmol'
3088 : 'an Array';
3089 console.error(
3090 'React expect children of <style> tags to be a string, number, or object with a `toString` method but found %s instead. ' +
3091 'In browsers style Elements can only have `Text` Nodes as children.',
3092 childType,
3093 );
3094 }
3095 }
3096 }
3097 const precedence = props.precedence;
3098 const href = props.href;
3099 const nonce = props.nonce;
3100
3101 if (
3102 formatContext.insertionMode === SVG_MODE ||
3103 noscriptTagInScope ||
3104 props.itemProp != null ||
3105 typeof precedence !== 'string' ||
3106 typeof href !== 'string' ||
3107 href === ''
3108 ) {
3109 // This style tag is not able to be turned into a Style Resource
3110 return pushStyleImpl(target, props);
3111 }
3112
3113 if (__DEV__) {
3114 if (href.includes(' ')) {
3115 console.error(

Callers 1

pushStartInstanceFunction · 0.85

Calls 10

stringToChunkFunction · 0.90
pushStyleImplFunction · 0.85
escapeTextForBrowserFunction · 0.85
pushStyleContentsFunction · 0.85
setMethod · 0.80
addMethod · 0.80
getResourceKeyFunction · 0.70
errorMethod · 0.65
getMethod · 0.65
pushMethod · 0.65

Tested by

no test coverage detected