@ant-design/cssinjs
Advanced tools
Comparing version 1.13.0 to 1.13.1
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray"; | ||
import canUseDom from "rc-util/es/Dom/canUseDom"; | ||
import { ATTR_MARK } from "../../StyleContext"; | ||
@@ -29,26 +30,28 @@ export var ATTR_CACHE_MAP = 'data-ant-cssinjs-cache-path'; | ||
if (!cachePathMap) { | ||
var div = document.createElement('div'); | ||
div.className = ATTR_CACHE_MAP; | ||
document.body.appendChild(div); | ||
var content = getComputedStyle(div).content || ''; | ||
content = content.replace(/^"/, '').replace(/"$/, ''); | ||
// Fill data | ||
cachePathMap = {}; | ||
content.split(';').forEach(function (item) { | ||
var _item$split = item.split(':'), | ||
_item$split2 = _slicedToArray(_item$split, 2), | ||
path = _item$split2[0], | ||
hash = _item$split2[1]; | ||
cachePathMap[path] = hash; | ||
}); | ||
if (canUseDom()) { | ||
var div = document.createElement('div'); | ||
div.className = ATTR_CACHE_MAP; | ||
document.body.appendChild(div); | ||
var content = getComputedStyle(div).content || ''; | ||
content = content.replace(/^"/, '').replace(/"$/, ''); | ||
// Remove inline record style | ||
var inlineMapStyle = document.querySelector("style[".concat(ATTR_CACHE_MAP, "]")); | ||
if (inlineMapStyle) { | ||
var _inlineMapStyle$paren; | ||
fromCSSFile = false; | ||
(_inlineMapStyle$paren = inlineMapStyle.parentNode) === null || _inlineMapStyle$paren === void 0 ? void 0 : _inlineMapStyle$paren.removeChild(inlineMapStyle); | ||
// Fill data | ||
content.split(';').forEach(function (item) { | ||
var _item$split = item.split(':'), | ||
_item$split2 = _slicedToArray(_item$split, 2), | ||
path = _item$split2[0], | ||
hash = _item$split2[1]; | ||
cachePathMap[path] = hash; | ||
}); | ||
// Remove inline record style | ||
var inlineMapStyle = document.querySelector("style[".concat(ATTR_CACHE_MAP, "]")); | ||
if (inlineMapStyle) { | ||
var _inlineMapStyle$paren; | ||
fromCSSFile = false; | ||
(_inlineMapStyle$paren = inlineMapStyle.parentNode) === null || _inlineMapStyle$paren === void 0 ? void 0 : _inlineMapStyle$paren.removeChild(inlineMapStyle); | ||
} | ||
document.body.removeChild(div); | ||
} | ||
document.body.removeChild(div); | ||
} | ||
@@ -63,3 +66,3 @@ } | ||
var styleStr = CSS_FILE_STYLE; | ||
if (!fromCSSFile) { | ||
if (!fromCSSFile && hash && canUseDom()) { | ||
var _style = document.querySelector("style[".concat(ATTR_MARK, "=\"").concat(cachePathMap[path], "\"]")); | ||
@@ -66,0 +69,0 @@ styleStr = (_style === null || _style === void 0 ? void 0 : _style.innerHTML) || null; |
@@ -14,2 +14,3 @@ "use strict"; | ||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")); | ||
var _canUseDom = _interopRequireDefault(require("rc-util/lib/Dom/canUseDom")); | ||
var _StyleContext = require("../../StyleContext"); | ||
@@ -44,26 +45,28 @@ var ATTR_CACHE_MAP = 'data-ant-cssinjs-cache-path'; | ||
if (!cachePathMap) { | ||
var div = document.createElement('div'); | ||
div.className = ATTR_CACHE_MAP; | ||
document.body.appendChild(div); | ||
var content = getComputedStyle(div).content || ''; | ||
content = content.replace(/^"/, '').replace(/"$/, ''); | ||
// Fill data | ||
cachePathMap = {}; | ||
content.split(';').forEach(function (item) { | ||
var _item$split = item.split(':'), | ||
_item$split2 = (0, _slicedToArray2.default)(_item$split, 2), | ||
path = _item$split2[0], | ||
hash = _item$split2[1]; | ||
cachePathMap[path] = hash; | ||
}); | ||
if ((0, _canUseDom.default)()) { | ||
var div = document.createElement('div'); | ||
div.className = ATTR_CACHE_MAP; | ||
document.body.appendChild(div); | ||
var content = getComputedStyle(div).content || ''; | ||
content = content.replace(/^"/, '').replace(/"$/, ''); | ||
// Remove inline record style | ||
var inlineMapStyle = document.querySelector("style[".concat(ATTR_CACHE_MAP, "]")); | ||
if (inlineMapStyle) { | ||
var _inlineMapStyle$paren; | ||
fromCSSFile = false; | ||
(_inlineMapStyle$paren = inlineMapStyle.parentNode) === null || _inlineMapStyle$paren === void 0 ? void 0 : _inlineMapStyle$paren.removeChild(inlineMapStyle); | ||
// Fill data | ||
content.split(';').forEach(function (item) { | ||
var _item$split = item.split(':'), | ||
_item$split2 = (0, _slicedToArray2.default)(_item$split, 2), | ||
path = _item$split2[0], | ||
hash = _item$split2[1]; | ||
cachePathMap[path] = hash; | ||
}); | ||
// Remove inline record style | ||
var inlineMapStyle = document.querySelector("style[".concat(ATTR_CACHE_MAP, "]")); | ||
if (inlineMapStyle) { | ||
var _inlineMapStyle$paren; | ||
fromCSSFile = false; | ||
(_inlineMapStyle$paren = inlineMapStyle.parentNode) === null || _inlineMapStyle$paren === void 0 ? void 0 : _inlineMapStyle$paren.removeChild(inlineMapStyle); | ||
} | ||
document.body.removeChild(div); | ||
} | ||
document.body.removeChild(div); | ||
} | ||
@@ -78,3 +81,3 @@ } | ||
var styleStr = CSS_FILE_STYLE; | ||
if (!fromCSSFile) { | ||
if (!fromCSSFile && hash && (0, _canUseDom.default)()) { | ||
var _style = document.querySelector("style[".concat(_StyleContext.ATTR_MARK, "=\"").concat(cachePathMap[path], "\"]")); | ||
@@ -81,0 +84,0 @@ styleStr = (_style === null || _style === void 0 ? void 0 : _style.innerHTML) || null; |
{ | ||
"name": "@ant-design/cssinjs", | ||
"version": "1.13.0", | ||
"version": "1.13.1", | ||
"description": "Component level cssinjs resolution for antd", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
170035
3815