Skip to content

Commit

Permalink
Merge pull request #1423 from holatuwol/ie-lock-style-auto
Browse files Browse the repository at this point in the history
fix: if we're locking the image attributes, use 'auto' for the height like we do in other browsers
  • Loading branch information
julien authored Sep 24, 2020
2 parents e1c9e3a + dba16c5 commit 1d712a3
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/plugins/dragresize_ie11.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,14 +420,17 @@
src: image.getAttribute('src'),
alt: image.getAttribute('alt') || '',
width: image.getAttribute('width') || '',
height: image.getAttribute('height') || '',

// Lock ratio is on by default (#10833).
lock: this.ready
? helpers.checkHasNaturalRatio(image)
: true,
};

data.height = data.lock
? null
: image.getAttribute('height') || '';

// If we used 'a' in widget#parts definition, it could happen that
// selected element is a child of widget.parts#caption. Since there's no clever
// way to solve it with CSS selectors, it's done like that. (#11783).
Expand Down Expand Up @@ -1249,7 +1252,10 @@
function setDimensions(widget) {
const data = widget.data;

const dimensions = {width: data.width, height: data.height};
const dimensions = {
width: data.width,
height: data.lock ? null : data.height,
};

const image = widget.parts.image;

Expand Down Expand Up @@ -1475,7 +1481,9 @@
// This is to prevent images to visually disappear.
if (newWidth >= 15 && newHeight >= 15) {
image.$.style.width = newWidth + 'px';
image.$.style.height = newHeight + 'px';
image.$.style.height = widget.data.lock
? 'auto'
: newHeight + 'px';

updateData = true;
} else {
Expand All @@ -1496,7 +1504,7 @@

if (updateData) {
widget.setData({
height: newHeight,
height: widget.data.lock ? null : newHeight,
width: newWidth,
});

Expand Down

0 comments on commit 1d712a3

Please sign in to comment.