@mui/styled-engine
Advanced tools
Comparing version 6.2.1 to 6.3.0
/** | ||
* @mui/styled-engine v6.2.1 | ||
* @mui/styled-engine v6.3.0 | ||
* | ||
@@ -4,0 +4,0 @@ * @license MIT |
/** | ||
* @mui/styled-engine v6.2.1 | ||
* @mui/styled-engine v6.3.0 | ||
* | ||
@@ -4,0 +4,0 @@ * @license MIT |
@@ -12,19 +12,7 @@ 'use client'; | ||
import { jsx as _jsx } from "react/jsx-runtime"; | ||
const createEmotionCache = options => { | ||
const createEmotionCache = (options, CustomSheet) => { | ||
const cache = createCache(options); | ||
/** | ||
* This is for client-side apps only. | ||
* A custom sheet is required to make the GlobalStyles API work with `prepend: true`. | ||
* This is because the [sheet](https://github.com/emotion-js/emotion/blob/main/packages/react/src/global.js#L94-L99) does not consume the options. | ||
*/ | ||
class MyStyleSheet extends StyleSheet { | ||
constructor(args) { | ||
super(args); | ||
this.prepend = cache.sheet.prepend; | ||
} | ||
} | ||
// Do the same as https://github.com/emotion-js/emotion/blob/main/packages/cache/src/index.js#L238-L245 | ||
cache.sheet = new MyStyleSheet({ | ||
cache.sheet = new CustomSheet({ | ||
key: cache.key, | ||
@@ -39,11 +27,33 @@ nonce: cache.sheet.nonce, | ||
}; | ||
// prepend: true moves MUI styles to the top of the <head> so they're loaded first. | ||
// It allows developers to easily override MUI styles with other styling solutions, like CSS modules. | ||
let cache; | ||
if (typeof document === 'object') { | ||
// Use `insertionPoint` over `prepend`(deprecated) because it can be controlled for GlobalStyles injection order | ||
// For more information, see https://github.com/mui/material-ui/issues/44597 | ||
let insertionPoint = document.querySelector('[name="emotion-insertion-point"]'); | ||
if (!insertionPoint) { | ||
insertionPoint = document.createElement('meta'); | ||
insertionPoint.setAttribute('name', 'emotion-insertion-point'); | ||
insertionPoint.setAttribute('content', ''); | ||
const head = document.querySelector('head'); | ||
if (head) { | ||
head.prepend(insertionPoint); | ||
} | ||
} | ||
/** | ||
* This is for client-side apps only. | ||
* A custom sheet is required to make the GlobalStyles API injected above the insertion point. | ||
* This is because the [sheet](https://github.com/emotion-js/emotion/blob/main/packages/react/src/global.js#L94-L99) does not consume the options. | ||
*/ | ||
class MyStyleSheet extends StyleSheet { | ||
insert(rule, options) { | ||
if (this.key && this.key.endsWith('global')) { | ||
this.before = insertionPoint; | ||
} | ||
return super.insert(rule, options); | ||
} | ||
} | ||
cache = createEmotionCache({ | ||
key: 'css', | ||
prepend: true | ||
}); | ||
insertionPoint | ||
}, MyStyleSheet); | ||
} | ||
@@ -50,0 +60,0 @@ export default function StyledEngineProvider(props) { |
/** | ||
* @mui/styled-engine v6.2.1 | ||
* @mui/styled-engine v6.3.0 | ||
* | ||
@@ -4,0 +4,0 @@ * @license MIT |
@@ -18,19 +18,7 @@ "use strict"; | ||
// https://github.com/emotion-js/emotion/issues/2790 | ||
const createEmotionCache = options => { | ||
const createEmotionCache = (options, CustomSheet) => { | ||
const cache = (0, _cache.default)(options); | ||
/** | ||
* This is for client-side apps only. | ||
* A custom sheet is required to make the GlobalStyles API work with `prepend: true`. | ||
* This is because the [sheet](https://github.com/emotion-js/emotion/blob/main/packages/react/src/global.js#L94-L99) does not consume the options. | ||
*/ | ||
class MyStyleSheet extends _sheet.StyleSheet { | ||
constructor(args) { | ||
super(args); | ||
this.prepend = cache.sheet.prepend; | ||
} | ||
} | ||
// Do the same as https://github.com/emotion-js/emotion/blob/main/packages/cache/src/index.js#L238-L245 | ||
cache.sheet = new MyStyleSheet({ | ||
cache.sheet = new CustomSheet({ | ||
key: cache.key, | ||
@@ -45,11 +33,33 @@ nonce: cache.sheet.nonce, | ||
}; | ||
// prepend: true moves MUI styles to the top of the <head> so they're loaded first. | ||
// It allows developers to easily override MUI styles with other styling solutions, like CSS modules. | ||
let cache; | ||
if (typeof document === 'object') { | ||
// Use `insertionPoint` over `prepend`(deprecated) because it can be controlled for GlobalStyles injection order | ||
// For more information, see https://github.com/mui/material-ui/issues/44597 | ||
let insertionPoint = document.querySelector('[name="emotion-insertion-point"]'); | ||
if (!insertionPoint) { | ||
insertionPoint = document.createElement('meta'); | ||
insertionPoint.setAttribute('name', 'emotion-insertion-point'); | ||
insertionPoint.setAttribute('content', ''); | ||
const head = document.querySelector('head'); | ||
if (head) { | ||
head.prepend(insertionPoint); | ||
} | ||
} | ||
/** | ||
* This is for client-side apps only. | ||
* A custom sheet is required to make the GlobalStyles API injected above the insertion point. | ||
* This is because the [sheet](https://github.com/emotion-js/emotion/blob/main/packages/react/src/global.js#L94-L99) does not consume the options. | ||
*/ | ||
class MyStyleSheet extends _sheet.StyleSheet { | ||
insert(rule, options) { | ||
if (this.key && this.key.endsWith('global')) { | ||
this.before = insertionPoint; | ||
} | ||
return super.insert(rule, options); | ||
} | ||
} | ||
cache = createEmotionCache({ | ||
key: 'css', | ||
prepend: true | ||
}); | ||
insertionPoint | ||
}, MyStyleSheet); | ||
} | ||
@@ -56,0 +66,0 @@ function StyledEngineProvider(props) { |
{ | ||
"name": "@mui/styled-engine", | ||
"version": "6.2.1", | ||
"version": "6.3.0", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "author": "MUI Team", |
@@ -12,19 +12,7 @@ 'use client'; | ||
import { jsx as _jsx } from "react/jsx-runtime"; | ||
const createEmotionCache = options => { | ||
const createEmotionCache = (options, CustomSheet) => { | ||
const cache = createCache(options); | ||
/** | ||
* This is for client-side apps only. | ||
* A custom sheet is required to make the GlobalStyles API work with `prepend: true`. | ||
* This is because the [sheet](https://github.com/emotion-js/emotion/blob/main/packages/react/src/global.js#L94-L99) does not consume the options. | ||
*/ | ||
class MyStyleSheet extends StyleSheet { | ||
constructor(args) { | ||
super(args); | ||
this.prepend = cache.sheet.prepend; | ||
} | ||
} | ||
// Do the same as https://github.com/emotion-js/emotion/blob/main/packages/cache/src/index.js#L238-L245 | ||
cache.sheet = new MyStyleSheet({ | ||
cache.sheet = new CustomSheet({ | ||
key: cache.key, | ||
@@ -39,11 +27,33 @@ nonce: cache.sheet.nonce, | ||
}; | ||
// prepend: true moves MUI styles to the top of the <head> so they're loaded first. | ||
// It allows developers to easily override MUI styles with other styling solutions, like CSS modules. | ||
let cache; | ||
if (typeof document === 'object') { | ||
// Use `insertionPoint` over `prepend`(deprecated) because it can be controlled for GlobalStyles injection order | ||
// For more information, see https://github.com/mui/material-ui/issues/44597 | ||
let insertionPoint = document.querySelector('[name="emotion-insertion-point"]'); | ||
if (!insertionPoint) { | ||
insertionPoint = document.createElement('meta'); | ||
insertionPoint.setAttribute('name', 'emotion-insertion-point'); | ||
insertionPoint.setAttribute('content', ''); | ||
const head = document.querySelector('head'); | ||
if (head) { | ||
head.prepend(insertionPoint); | ||
} | ||
} | ||
/** | ||
* This is for client-side apps only. | ||
* A custom sheet is required to make the GlobalStyles API injected above the insertion point. | ||
* This is because the [sheet](https://github.com/emotion-js/emotion/blob/main/packages/react/src/global.js#L94-L99) does not consume the options. | ||
*/ | ||
class MyStyleSheet extends StyleSheet { | ||
insert(rule, options) { | ||
if (this.key && this.key.endsWith('global')) { | ||
this.before = insertionPoint; | ||
} | ||
return super.insert(rule, options); | ||
} | ||
} | ||
cache = createEmotionCache({ | ||
key: 'css', | ||
prepend: true | ||
}); | ||
insertionPoint | ||
}, MyStyleSheet); | ||
} | ||
@@ -50,0 +60,0 @@ export default function StyledEngineProvider(props) { |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
127123
699