File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed
app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/utils
dev/tests/js/jasmine/tests/app/code/Magento/PageBuilder/view/adminhtml/web/js/utils Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -171,8 +171,10 @@ export function parseAttributesString(attributes: string): { [key: string]: stri
171
171
*/
172
172
export function lockImageSize ( element : HTMLElement ) {
173
173
[ ] . slice . call ( element . querySelectorAll ( "img" ) ) . forEach ( ( image : HTMLImageElement ) => {
174
- image . style . width = `${ image . width } px` ;
175
- image . style . height = `${ image . height } px` ;
174
+ if ( image . style . width . length === 0 && image . style . height . length === 0 ) {
175
+ image . style . width = `${ image . width } px` ;
176
+ image . style . height = `${ image . height } px` ;
177
+ }
176
178
} ) ;
177
179
}
178
180
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Copyright © Magento, Inc. All rights reserved.
3
+ * See COPYING.txt for license details.
4
+ */
5
+
6
+ define ( [
7
+ 'Magento_PageBuilder/js/utils/editor' ,
8
+ 'jquery'
9
+ ] , function ( utils , $ ) {
10
+ 'use strict' ;
11
+
12
+ describe ( 'Magento_PageBuilder/js/utils/editor.js' , function ( ) {
13
+ describe ( 'lockImageSize' , function ( ) {
14
+ it ( 'Should not change the defined image sizes' , function ( ) {
15
+ var image = new Image ( ) ;
16
+
17
+ $ ( document . body ) . append ( image ) ;
18
+ $ ( image ) . width ( '100%' ) ;
19
+
20
+ utils . lockImageSize ( document . body ) ;
21
+ expect ( image . style . width ) . toEqual ( '100%' ) ;
22
+
23
+ image . remove ( ) ;
24
+ } ) ;
25
+ } ) ;
26
+ } ) ;
27
+ } ) ;
You can’t perform that action at this time.
0 commit comments