Skip to content

Commit c80acbe

Browse files
MC-41569: "Image Size" sporadically changing from "%" to pixels
1 parent 917a336 commit c80acbe

File tree

3 files changed

+31
-28
lines changed
  • app/code/Magento/PageBuilder/view/adminhtml/web
  • dev/tests/js/jasmine/tests/app/code/Magento/PageBuilder/view/adminhtml/web/js/utils

3 files changed

+31
-28
lines changed

app/code/Magento/PageBuilder/view/adminhtml/web/js/utils/editor.js

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/utils/editor.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -170,18 +170,18 @@ export function parseAttributesString(attributes: string): { [key: string]: stri
170170
* @param element
171171
*/
172172
export function lockImageSize(element: HTMLElement) {
173-
[].slice.call(element.querySelectorAll('img')).forEach((image: HTMLImageElement) => {
173+
[].slice.call(element.querySelectorAll("img")).forEach((image: HTMLImageElement) => {
174174
if (image.style.width.length === 0) {
175-
image.style.width = /^\d+$/.test(image.getAttribute('width')) ?
176-
image.getAttribute('width') + 'px' :
177-
image.getAttribute('width');
178-
image.setAttribute('data-width-locked', 'true');
175+
image.style.width = /^\d+$/.test(image.getAttribute("width")) ?
176+
image.getAttribute("width") + "px" :
177+
image.getAttribute("width");
178+
image.setAttribute("data-width-locked", "true");
179179
}
180180
if (image.style.height.length === 0) {
181-
image.style.height = /^\d+$/.test(image.getAttribute('height')) ?
182-
image.getAttribute('height') + 'px':
183-
image.getAttribute('height');
184-
image.setAttribute('data-height-locked', 'true');
181+
image.style.height = /^\d+$/.test(image.getAttribute("height")) ?
182+
image.getAttribute("height") + "px" :
183+
image.getAttribute("height");
184+
image.setAttribute("data-height-locked", "true");
185185
}
186186
});
187187
}
@@ -192,14 +192,14 @@ export function lockImageSize(element: HTMLElement) {
192192
* @param element
193193
*/
194194
export function unlockImageSize(element: HTMLElement) {
195-
[].slice.call(element.querySelectorAll('img')).forEach((image: HTMLImageElement) => {
196-
if (image.getAttribute('data-width-locked')) {
195+
[].slice.call(element.querySelectorAll("img")).forEach((image: HTMLImageElement) => {
196+
if (image.getAttribute("data-width-locked")) {
197197
image.style.width = null;
198-
image.removeAttribute('data-width-locked');
198+
image.removeAttribute("data-width-locked");
199199
}
200-
if (image.getAttribute('data-height-locked')) {
200+
if (image.getAttribute("data-height-locked")) {
201201
image.style.height = null;
202-
image.removeAttribute('data-height-locked');
202+
image.removeAttribute("data-height-locked");
203203
}
204204
});
205205
}

dev/tests/js/jasmine/tests/app/code/Magento/PageBuilder/view/adminhtml/web/js/utils/editor.test.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ define([
2929
var image = document.createElement('img'),
3030
element = document.createElement('div');
3131

32-
$(image).css({'width' : '100%', 'height' : '100%'});
32+
$(image).css({
33+
width: '100%',
34+
height: '100%'
35+
});
3336
$(image).attr('data-height-locked', 'true');
3437
$(element).append(image);
3538

0 commit comments

Comments
 (0)