@ant-design/cssinjs
Advanced tools
Comparing version 1.13.1 to 1.13.2
@@ -11,5 +11,5 @@ export declare const ATTR_CACHE_MAP = "data-ant-cssinjs-cache-path"; | ||
*/ | ||
export declare function reset(mockCache?: Record<string, string>, from?: boolean): void; | ||
export declare function reset(mockCache?: Record<string, string>, fromFile?: boolean): void; | ||
export declare function prepare(): void; | ||
export declare function existPath(path: string): boolean; | ||
export declare function getStyleAndHash(path: string): [style: string | null, hash: string]; |
@@ -24,5 +24,5 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray"; | ||
export function reset(mockCache) { | ||
var from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; | ||
var fromFile = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; | ||
cachePathMap = mockCache; | ||
fromCSSFile = from; | ||
fromCSSFile = fromFile; | ||
} | ||
@@ -35,2 +35,5 @@ export function prepare() { | ||
div.className = ATTR_CACHE_MAP; | ||
div.style.position = 'fixed'; | ||
div.style.visibility = 'hidden'; | ||
div.style.top = '-9999px'; | ||
document.body.appendChild(div); | ||
@@ -66,8 +69,17 @@ var content = getComputedStyle(div).content || ''; | ||
var hash = cachePathMap[path]; | ||
var styleStr = CSS_FILE_STYLE; | ||
if (!fromCSSFile && hash && canUseDom()) { | ||
var _style = document.querySelector("style[".concat(ATTR_MARK, "=\"").concat(cachePathMap[path], "\"]")); | ||
styleStr = (_style === null || _style === void 0 ? void 0 : _style.innerHTML) || null; | ||
var styleStr = null; | ||
if (hash && canUseDom()) { | ||
if (fromCSSFile) { | ||
styleStr = CSS_FILE_STYLE; | ||
} else { | ||
var _style = document.querySelector("style[".concat(ATTR_MARK, "=\"").concat(cachePathMap[path], "\"]")); | ||
if (_style) { | ||
styleStr = _style.innerHTML; | ||
} else { | ||
// Clean up since not exist anymore | ||
delete cachePathMap[path]; | ||
} | ||
} | ||
} | ||
return [styleStr, hash]; | ||
} |
@@ -11,5 +11,5 @@ export declare const ATTR_CACHE_MAP = "data-ant-cssinjs-cache-path"; | ||
*/ | ||
export declare function reset(mockCache?: Record<string, string>, from?: boolean): void; | ||
export declare function reset(mockCache?: Record<string, string>, fromFile?: boolean): void; | ||
export declare function prepare(): void; | ||
export declare function existPath(path: string): boolean; | ||
export declare function getStyleAndHash(path: string): [style: string | null, hash: string]; |
@@ -38,5 +38,5 @@ "use strict"; | ||
function reset(mockCache) { | ||
var from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; | ||
var fromFile = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; | ||
cachePathMap = mockCache; | ||
fromCSSFile = from; | ||
fromCSSFile = fromFile; | ||
} | ||
@@ -49,2 +49,5 @@ function prepare() { | ||
div.className = ATTR_CACHE_MAP; | ||
div.style.position = 'fixed'; | ||
div.style.visibility = 'hidden'; | ||
div.style.top = '-9999px'; | ||
document.body.appendChild(div); | ||
@@ -80,8 +83,17 @@ var content = getComputedStyle(div).content || ''; | ||
var hash = cachePathMap[path]; | ||
var styleStr = CSS_FILE_STYLE; | ||
if (!fromCSSFile && hash && (0, _canUseDom.default)()) { | ||
var _style = document.querySelector("style[".concat(_StyleContext.ATTR_MARK, "=\"").concat(cachePathMap[path], "\"]")); | ||
styleStr = (_style === null || _style === void 0 ? void 0 : _style.innerHTML) || null; | ||
var styleStr = null; | ||
if (hash && (0, _canUseDom.default)()) { | ||
if (fromCSSFile) { | ||
styleStr = CSS_FILE_STYLE; | ||
} else { | ||
var _style = document.querySelector("style[".concat(_StyleContext.ATTR_MARK, "=\"").concat(cachePathMap[path], "\"]")); | ||
if (_style) { | ||
styleStr = _style.innerHTML; | ||
} else { | ||
// Clean up since not exist anymore | ||
delete cachePathMap[path]; | ||
} | ||
} | ||
} | ||
return [styleStr, hash]; | ||
} |
{ | ||
"name": "@ant-design/cssinjs", | ||
"version": "1.13.1", | ||
"version": "1.13.2", | ||
"description": "Component level cssinjs resolution for antd", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -28,4 +28,16 @@ # @ant-design/cssinjs | ||
[![@ant-design/cssinjs](https://nodei.co/npm/@ant-design/cssinjs.png)](https://npmjs.org/package/@ant-design/cssinjs) | ||
```bash | ||
npm install @ant-design/cssinjs | ||
``` | ||
or | ||
```bash | ||
yarn add @ant-design/cssinjs | ||
``` | ||
```bash | ||
pnpm add @ant-design/cssinjs | ||
``` | ||
## Development | ||
@@ -32,0 +44,0 @@ |
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
170527
3839
109