@skbkontur/icons 1.13.0-getrootnode-fix.1 → 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,19 +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(element) {
10
- return typeof Node === 'function' && Object.prototype.hasOwnProperty.call(Node.prototype, 'getRootNode')
11
- ? element.getRootNode()
12
- : element.ownerDocument;
13
- }
14
- /**
15
- * not attached element can return the root of the DOM tree it belongs to, or itself - HTMLElement, Text, etc
16
- */
17
- function getRootNodeWithAdoptedStyleSheets(element) {
18
- var rootNode = getRootNode(element);
19
- return rootNode instanceof Document || rootNode instanceof ShadowRoot ? rootNode : element.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);
20
13
  }
21
14
  /**
22
15
  * Whether the current browser supports `adoptedStyleSheets`.
@@ -29,14 +22,13 @@ var supportsAdoptingStyleSheets = Boolean(typeof window !== 'undefined' &&
29
22
  'replace' in CSSStyleSheet.prototype);
30
23
  export function injectCss(element) {
31
24
  var _a;
32
- var rootNode = getRootNodeWithAdoptedStyleSheets(element);
25
+ var rootNode = getSafeRootNode(element);
33
26
  if (supportsAdoptingStyleSheets) {
34
27
  var currentWindow = element.ownerDocument.defaultView;
35
28
  if (!currentWindow) {
36
29
  return;
37
30
  }
38
- var typedRootNode = rootNode;
39
- var rootNodeStyles_1 = typedRootNode.adoptedStyleSheets.map(function (item) { return item.cssRules; });
31
+ var rootNodeStyles_1 = rootNode.adoptedStyleSheets.map(function (item) { return item.cssRules; });
40
32
  var cssRulesStyleSheet_1 = new currentWindow.CSSStyleSheet();
41
33
  CSSRules.forEach(function (rule) { return cssRulesStyleSheet_1.insertRule(rule); });
42
34
  var filteredStyleSheet_1 = new currentWindow.CSSStyleSheet();
@@ -47,11 +39,11 @@ export function injectCss(element) {
47
39
  });
48
40
  if (filteredStyleSheet_1.cssRules.length > 0) {
49
41
  try {
50
- typedRootNode.adoptedStyleSheets.push(filteredStyleSheet_1);
42
+ rootNode.adoptedStyleSheets.push(filteredStyleSheet_1);
51
43
  }
52
44
  catch (e) {
53
45
  // fix for old chrome https://chromestatus.com/feature/5638996492288000 , but slow performance
54
- typedRootNode.adoptedStyleSheets = __spreadArrays(typedRootNode.adoptedStyleSheets, [filteredStyleSheet_1]);
46
+ rootNode.adoptedStyleSheets = __spreadArrays(rootNode.adoptedStyleSheets, [filteredStyleSheet_1]);
55
47
  }
56
48
  }
57
49
  }
@@ -7,19 +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(element) {
13
- return typeof Node === 'function' && Object.prototype.hasOwnProperty.call(Node.prototype, 'getRootNode')
14
- ? element.getRootNode()
15
- : element.ownerDocument;
16
- }
17
- /**
18
- * not attached element can return the root of the DOM tree it belongs to, or itself - HTMLElement, Text, etc
19
- */
20
- function getRootNodeWithAdoptedStyleSheets(element) {
21
- var rootNode = getRootNode(element);
22
- return rootNode instanceof Document || rootNode instanceof ShadowRoot ? rootNode : element.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);
23
16
  }
24
17
  /**
25
18
  * Whether the current browser supports `adoptedStyleSheets`.
@@ -32,14 +25,13 @@ var supportsAdoptingStyleSheets = Boolean(typeof window !== 'undefined' &&
32
25
  'replace' in CSSStyleSheet.prototype);
33
26
  function injectCss(element) {
34
27
  var _a;
35
- var rootNode = getRootNodeWithAdoptedStyleSheets(element);
28
+ var rootNode = getSafeRootNode(element);
36
29
  if (supportsAdoptingStyleSheets) {
37
30
  var currentWindow = element.ownerDocument.defaultView;
38
31
  if (!currentWindow) {
39
32
  return;
40
33
  }
41
- var typedRootNode = rootNode;
42
- var rootNodeStyles_1 = typedRootNode.adoptedStyleSheets.map(function (item) { return item.cssRules; });
34
+ var rootNodeStyles_1 = rootNode.adoptedStyleSheets.map(function (item) { return item.cssRules; });
43
35
  var cssRulesStyleSheet_1 = new currentWindow.CSSStyleSheet();
44
36
  cssRules_1.CSSRules.forEach(function (rule) { return cssRulesStyleSheet_1.insertRule(rule); });
45
37
  var filteredStyleSheet_1 = new currentWindow.CSSStyleSheet();
@@ -50,11 +42,11 @@ function injectCss(element) {
50
42
  });
51
43
  if (filteredStyleSheet_1.cssRules.length > 0) {
52
44
  try {
53
- typedRootNode.adoptedStyleSheets.push(filteredStyleSheet_1);
45
+ rootNode.adoptedStyleSheets.push(filteredStyleSheet_1);
54
46
  }
55
47
  catch (e) {
56
48
  // fix for old chrome https://chromestatus.com/feature/5638996492288000 , but slow performance
57
- typedRootNode.adoptedStyleSheets = tslib_1.__spreadArrays(typedRootNode.adoptedStyleSheets, [filteredStyleSheet_1]);
49
+ rootNode.adoptedStyleSheets = tslib_1.__spreadArrays(rootNode.adoptedStyleSheets, [filteredStyleSheet_1]);
58
50
  }
59
51
  }
60
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-getrootnode-fix.1",
4
+ "version": "1.13.1",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
7
7
  },