Better handling 0 width / 0 height media placeholders.
This commit is contained in:
parent
3ec0b28981
commit
83ed39c607
|
@ -55,6 +55,11 @@ var PlaceHolder = (() => {
|
|||
for (let p of props) {
|
||||
destStyle[p] = srcStyle[p];
|
||||
}
|
||||
for (let size of ["width", "height"]) {
|
||||
if (/^0(?:\D|$)/.test(destStyle[size])) {
|
||||
destStyle[size] = "";
|
||||
}
|
||||
}
|
||||
if (src.offsetTop < 0 && src.offsetTop <= (-src.offsetHeight)) {
|
||||
destStyle.top = "0"; // fixes video player off-display position on Youtube
|
||||
}
|
||||
|
@ -83,6 +88,10 @@ var PlaceHolder = (() => {
|
|||
replacement = e;
|
||||
break;
|
||||
}
|
||||
if (replacement = e._placeHolderReplacement) {
|
||||
ph = replacement._placeHolderObj;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ph) {
|
||||
ev.preventDefault();
|
||||
|
@ -159,6 +168,9 @@ var PlaceHolder = (() => {
|
|||
|
||||
replacement._placeHolderObj = this;
|
||||
replacement._placeHolderElement = element;
|
||||
for (let e of replacement.querySelectorAll("*")) {
|
||||
e._placeHolderReplacement = replacement;
|
||||
}
|
||||
|
||||
element.replaceWith(replacement);
|
||||
|
||||
|
|
Loading…
Reference in New Issue