-
Notifications
You must be signed in to change notification settings - Fork 82
Revert "fix: apply StyleProvider nonce to CSS variable styles" #254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ import StyleContext, { | |
| ATTR_TOKEN, | ||
| CSS_IN_JS_INSTANCE, | ||
| } from '../StyleContext'; | ||
| import { isClientSide, mergeCSSConfig, toStyleStr } from '../util'; | ||
| import { isClientSide, toStyleStr } from '../util'; | ||
| import type { TokenWithCSSVar } from '../util/css-variables'; | ||
| import { transformToken } from '../util/css-variables'; | ||
| import type { ExtractStyle } from './useGlobalCache'; | ||
|
|
@@ -39,7 +39,6 @@ const useCSSVarRegister = <V, T extends Record<string, V>>( | |
| cache: { instanceId }, | ||
| container, | ||
| hashPriority, | ||
| nonce, | ||
| } = useContext(StyleContext); | ||
| const { _tokenKey: tokenKey } = token; | ||
|
|
||
|
|
@@ -71,17 +70,12 @@ const useCSSVarRegister = <V, T extends Record<string, V>>( | |
| if (!cssVarsStr) { | ||
| return; | ||
| } | ||
| const mergedCSSConfig = mergeCSSConfig<Parameters<typeof updateCSS>[2]>( | ||
| { | ||
| mark: ATTR_MARK, | ||
| prepend: 'queue', | ||
| attachTo: container, | ||
| priority: -999, | ||
| }, | ||
| nonce, | ||
| ); | ||
|
|
||
| const style = updateCSS(cssVarsStr, styleId, mergedCSSConfig); | ||
| const style = updateCSS(cssVarsStr, styleId, { | ||
| mark: ATTR_MARK, | ||
| prepend: 'queue', | ||
| attachTo: container, | ||
| priority: -999, | ||
| }); | ||
|
Comment on lines
+73
to
+78
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
|
|
||
| (style as any)[CSS_IN_JS_INSTANCE] = instanceId; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,7 @@ import StyleContext, { | |
| CSS_IN_JS_INSTANCE, | ||
| } from '../StyleContext'; | ||
| import type Theme from '../theme/Theme'; | ||
| import { flattenToken, memoResult, mergeCSSConfig, token2key, toStyleStr } from '../util'; | ||
| import { flattenToken, memoResult, token2key, toStyleStr } from '../util'; | ||
| import { transformToken } from '../util/css-variables'; | ||
| import type { ExtractStyle } from './useGlobalCache'; | ||
| import useGlobalCache from './useGlobalCache'; | ||
|
|
@@ -161,7 +161,6 @@ export default function useCacheToken< | |
| cache: { instanceId }, | ||
| container, | ||
| hashPriority, | ||
| nonce, | ||
| } = useContext(StyleContext); | ||
| const { | ||
| salt = '', | ||
|
|
@@ -220,17 +219,12 @@ export default function useCacheToken< | |
| if (!cssVarsStr) { | ||
| return; | ||
| } | ||
| const mergedCSSConfig = mergeCSSConfig<Parameters<typeof updateCSS>[2]>( | ||
| { | ||
| mark: ATTR_MARK, | ||
| prepend: 'queue', | ||
| attachTo: container, | ||
| priority: -999, | ||
| }, | ||
| nonce, | ||
| ); | ||
|
|
||
| const style = updateCSS(cssVarsStr, hash(`css-var-${themeKey}`), mergedCSSConfig); | ||
| const style = updateCSS(cssVarsStr, hash(`css-var-${themeKey}`), { | ||
| mark: ATTR_MARK, | ||
| prepend: 'queue', | ||
| attachTo: container, | ||
| priority: -999, | ||
| }); | ||
|
Comment on lines
+222
to
+227
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Theme token values are injected into the document via |
||
|
|
||
| (style as any)[CSS_IN_JS_INSTANCE] = instanceId; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removal of the
nonceproperty fromStyleContextPropsis a security regression. This property is essential for applications that implement a strict Content Security Policy (CSP) requiring nonces for inline styles. By removing this property, the library loses the ability to pass nonces to dynamically injected style tags, which will cause them to be blocked by the browser in strict CSP environments. This may force developers to adopt less secure CSP directives like'unsafe-inline'to maintain functionality.