@skbkontur/icons 1.13.0 → 1.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.13.1](https://git.skbkontur.ru/ui/ui-parking/compare/@skbkontur/icons@1.13.0...@skbkontur/icons@1.13.1) (2024-10-31)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **icons:** fix not attached render ([bf41e51](https://git.skbkontur.ru/ui/ui-parking/commits/bf41e51c8a76660a6088c67a706bab98414218fe))
12
+
13
+
14
+
15
+
16
+
6
17
  # [1.13.0](https://git.skbkontur.ru/ui/ui-parking/compare/@skbkontur/icons@1.12.1...@skbkontur/icons@1.13.0) (2024-10-25)
7
18
 
8
19
 
@@ -4,12 +4,12 @@ function checkRuleExists(rootNodeStyles, cssText) {
4
4
  return rootNodeStyles.some(function (cssRules) { return Array.from(cssRules).some(function (r) { return r.cssText === cssText; }); });
5
5
  }
6
6
  /**
7
- * ponyfill for old browsers aka ie11, delete after drop support
7
+ * Not attached element can return the root of the DOM tree it belongs to, or itself - HTMLElement, Text, etc
8
8
  */
9
- function getRootNode(node) {
10
- return typeof Node === 'function' && Object.prototype.hasOwnProperty.call(Node.prototype, 'getRootNode')
11
- ? node.getRootNode()
12
- : node.ownerDocument;
9
+ function getSafeRootNode(element) {
10
+ var _a;
11
+ var rootNode = (_a = element.getRootNode) === null || _a === void 0 ? void 0 : _a.call(element);
12
+ return (rootNode instanceof Document || rootNode instanceof ShadowRoot ? rootNode : element.ownerDocument);
13
13
  }
14
14
  /**
15
15
  * Whether the current browser supports `adoptedStyleSheets`.
@@ -22,17 +22,13 @@ var supportsAdoptingStyleSheets = Boolean(typeof window !== 'undefined' &&
22
22
  'replace' in CSSStyleSheet.prototype);
23
23
  export function injectCss(element) {
24
24
  var _a;
25
- var rootNode = getRootNode(element);
26
- if (!rootNode) {
27
- return;
28
- }
25
+ var rootNode = getSafeRootNode(element);
29
26
  if (supportsAdoptingStyleSheets) {
30
27
  var currentWindow = element.ownerDocument.defaultView;
31
28
  if (!currentWindow) {
32
29
  return;
33
30
  }
34
- var typedRootNode = rootNode;
35
- var rootNodeStyles_1 = typedRootNode.adoptedStyleSheets.map(function (item) { return item.cssRules; });
31
+ var rootNodeStyles_1 = rootNode.adoptedStyleSheets.map(function (item) { return item.cssRules; });
36
32
  var cssRulesStyleSheet_1 = new currentWindow.CSSStyleSheet();
37
33
  CSSRules.forEach(function (rule) { return cssRulesStyleSheet_1.insertRule(rule); });
38
34
  var filteredStyleSheet_1 = new currentWindow.CSSStyleSheet();
@@ -43,11 +39,11 @@ export function injectCss(element) {
43
39
  });
44
40
  if (filteredStyleSheet_1.cssRules.length > 0) {
45
41
  try {
46
- typedRootNode.adoptedStyleSheets.push(filteredStyleSheet_1);
42
+ rootNode.adoptedStyleSheets.push(filteredStyleSheet_1);
47
43
  }
48
44
  catch (e) {
49
45
  // fix for old chrome https://chromestatus.com/feature/5638996492288000 , but slow performance
50
- typedRootNode.adoptedStyleSheets = __spreadArrays(typedRootNode.adoptedStyleSheets, [filteredStyleSheet_1]);
46
+ rootNode.adoptedStyleSheets = __spreadArrays(rootNode.adoptedStyleSheets, [filteredStyleSheet_1]);
51
47
  }
52
48
  }
53
49
  }
@@ -7,12 +7,12 @@ function checkRuleExists(rootNodeStyles, cssText) {
7
7
  return rootNodeStyles.some(function (cssRules) { return Array.from(cssRules).some(function (r) { return r.cssText === cssText; }); });
8
8
  }
9
9
  /**
10
- * ponyfill for old browsers aka ie11, delete after drop support
10
+ * Not attached element can return the root of the DOM tree it belongs to, or itself - HTMLElement, Text, etc
11
11
  */
12
- function getRootNode(node) {
13
- return typeof Node === 'function' && Object.prototype.hasOwnProperty.call(Node.prototype, 'getRootNode')
14
- ? node.getRootNode()
15
- : node.ownerDocument;
12
+ function getSafeRootNode(element) {
13
+ var _a;
14
+ var rootNode = (_a = element.getRootNode) === null || _a === void 0 ? void 0 : _a.call(element);
15
+ return (rootNode instanceof Document || rootNode instanceof ShadowRoot ? rootNode : element.ownerDocument);
16
16
  }
17
17
  /**
18
18
  * Whether the current browser supports `adoptedStyleSheets`.
@@ -25,17 +25,13 @@ var supportsAdoptingStyleSheets = Boolean(typeof window !== 'undefined' &&
25
25
  'replace' in CSSStyleSheet.prototype);
26
26
  function injectCss(element) {
27
27
  var _a;
28
- var rootNode = getRootNode(element);
29
- if (!rootNode) {
30
- return;
31
- }
28
+ var rootNode = getSafeRootNode(element);
32
29
  if (supportsAdoptingStyleSheets) {
33
30
  var currentWindow = element.ownerDocument.defaultView;
34
31
  if (!currentWindow) {
35
32
  return;
36
33
  }
37
- var typedRootNode = rootNode;
38
- var rootNodeStyles_1 = typedRootNode.adoptedStyleSheets.map(function (item) { return item.cssRules; });
34
+ var rootNodeStyles_1 = rootNode.adoptedStyleSheets.map(function (item) { return item.cssRules; });
39
35
  var cssRulesStyleSheet_1 = new currentWindow.CSSStyleSheet();
40
36
  cssRules_1.CSSRules.forEach(function (rule) { return cssRulesStyleSheet_1.insertRule(rule); });
41
37
  var filteredStyleSheet_1 = new currentWindow.CSSStyleSheet();
@@ -46,11 +42,11 @@ function injectCss(element) {
46
42
  });
47
43
  if (filteredStyleSheet_1.cssRules.length > 0) {
48
44
  try {
49
- typedRootNode.adoptedStyleSheets.push(filteredStyleSheet_1);
45
+ rootNode.adoptedStyleSheets.push(filteredStyleSheet_1);
50
46
  }
51
47
  catch (e) {
52
48
  // fix for old chrome https://chromestatus.com/feature/5638996492288000 , but slow performance
53
- typedRootNode.adoptedStyleSheets = tslib_1.__spreadArrays(typedRootNode.adoptedStyleSheets, [filteredStyleSheet_1]);
49
+ rootNode.adoptedStyleSheets = tslib_1.__spreadArrays(rootNode.adoptedStyleSheets, [filteredStyleSheet_1]);
54
50
  }
55
51
  }
56
52
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@skbkontur/icons",
3
3
  "description": "react-ui-icons",
4
- "version": "1.13.0",
4
+ "version": "1.13.1",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
7
7
  },