← All changes
|
build/modules/block-editor/utils/fit-text-frontend.js
+5
-1
23.1.0
→
trunk
View file →
| @@ -59,8 +59,11 @@ | ||
| 59 | 59 | init() { |
| 60 | 60 | const context = getContext(); |
| 61 | 61 | const { ref } = getElement(); |
| 62 | 62 | const applyFontSize = (fontSize) => { |
| 63 | + if (!ref) { | |
| 64 | + return; | |
| 65 | + } | |
| 63 | 66 | if (fontSize === 0) { |
| 64 | 67 | ref.style.fontSize = ""; |
| 65 | 68 | } else { |
| 66 | 69 | ref.style.fontSize = `${fontSize}px`; |
| @@ -66,9 +69,9 @@ | ||
| 66 | 69 | ref.style.fontSize = `${fontSize}px`; |
| 67 | 70 | } |
| 68 | 71 | }; |
| 69 | 72 | context.fontSize = optimizeFitText(ref, applyFontSize); |
| 70 | - if (window.ResizeObserver && ref.parentElement) { | |
| 73 | + if (window.ResizeObserver && ref?.parentElement) { | |
| 71 | 74 | const resizeObserver = new window.ResizeObserver(() => { |
| 72 | 75 | context.fontSize = optimizeFitText(ref, applyFontSize); |
| 73 | 76 | }); |
| 74 | 77 | resizeObserver.observe(ref.parentElement); |
| @@ -78,8 +81,9 @@ | ||
| 78 | 81 | resizeObserver.disconnect(); |
| 79 | 82 | } |
| 80 | 83 | }; |
| 81 | 84 | } |
| 85 | + return void 0; | |
| 82 | 86 | } |
| 83 | 87 | } |
| 84 | 88 | }); |
| 85 | 89 | //# sourceMappingURL=fit-text-frontend.js.map |