UEA-PRODEM
This commit is contained in:
+25
-21
@@ -42,7 +42,6 @@ function isShadowRoot(value) {
|
||||
}
|
||||
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
||||
}
|
||||
const invalidOverflowDisplayValues = /*#__PURE__*/new Set(['inline', 'contents']);
|
||||
function isOverflowElement(element) {
|
||||
const {
|
||||
overflow,
|
||||
@@ -50,32 +49,35 @@ function isOverflowElement(element) {
|
||||
overflowY,
|
||||
display
|
||||
} = getComputedStyle(element);
|
||||
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
|
||||
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== 'inline' && display !== 'contents';
|
||||
}
|
||||
const tableElements = /*#__PURE__*/new Set(['table', 'td', 'th']);
|
||||
function isTableElement(element) {
|
||||
return tableElements.has(getNodeName(element));
|
||||
return /^(table|td|th)$/.test(getNodeName(element));
|
||||
}
|
||||
const topLayerSelectors = [':popover-open', ':modal'];
|
||||
function isTopLayer(element) {
|
||||
return topLayerSelectors.some(selector => {
|
||||
try {
|
||||
return element.matches(selector);
|
||||
} catch (_e) {
|
||||
return false;
|
||||
try {
|
||||
if (element.matches(':popover-open')) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
} catch (_e) {
|
||||
// no-op
|
||||
}
|
||||
try {
|
||||
return element.matches(':modal');
|
||||
} catch (_e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
const transformProperties = ['transform', 'translate', 'scale', 'rotate', 'perspective'];
|
||||
const willChangeValues = ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'];
|
||||
const containValues = ['paint', 'layout', 'strict', 'content'];
|
||||
const willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
|
||||
const containRe = /paint|layout|strict|content/;
|
||||
const isNotNone = value => !!value && value !== 'none';
|
||||
let isWebKitValue;
|
||||
function isContainingBlock(elementOrCss) {
|
||||
const webkit = isWebKit();
|
||||
const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss;
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
||||
// https://drafts.csswg.org/css-transforms-2/#individual-transforms
|
||||
return transformProperties.some(value => css[value] ? css[value] !== 'none' : false) || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || willChangeValues.some(value => (css.willChange || '').includes(value)) || containValues.some(value => (css.contain || '').includes(value));
|
||||
return isNotNone(css.transform) || isNotNone(css.translate) || isNotNone(css.scale) || isNotNone(css.rotate) || isNotNone(css.perspective) || !isWebKit() && (isNotNone(css.backdropFilter) || isNotNone(css.filter)) || willChangeRe.test(css.willChange || '') || containRe.test(css.contain || '');
|
||||
}
|
||||
function getContainingBlock(element) {
|
||||
let currentNode = getParentNode(element);
|
||||
@@ -90,12 +92,13 @@ function getContainingBlock(element) {
|
||||
return null;
|
||||
}
|
||||
function isWebKit() {
|
||||
if (typeof CSS === 'undefined' || !CSS.supports) return false;
|
||||
return CSS.supports('-webkit-backdrop-filter', 'none');
|
||||
if (isWebKitValue == null) {
|
||||
isWebKitValue = typeof CSS !== 'undefined' && CSS.supports && CSS.supports('-webkit-backdrop-filter', 'none');
|
||||
}
|
||||
return isWebKitValue;
|
||||
}
|
||||
const lastTraversableNodeNames = /*#__PURE__*/new Set(['html', 'body', '#document']);
|
||||
function isLastTraversableNode(node) {
|
||||
return lastTraversableNodeNames.has(getNodeName(node));
|
||||
return /^(html|body|#document)$/.test(getNodeName(node));
|
||||
}
|
||||
function getComputedStyle(element) {
|
||||
return getWindow(element).getComputedStyle(element);
|
||||
@@ -151,8 +154,9 @@ function getOverflowAncestors(node, list, traverseIframes) {
|
||||
if (isBody) {
|
||||
const frameElement = getFrameElement(win);
|
||||
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
|
||||
} else {
|
||||
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
||||
}
|
||||
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
||||
}
|
||||
function getFrameElement(win) {
|
||||
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
||||
|
||||
+25
-21
@@ -48,7 +48,6 @@
|
||||
}
|
||||
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
||||
}
|
||||
const invalidOverflowDisplayValues = /*#__PURE__*/new Set(['inline', 'contents']);
|
||||
function isOverflowElement(element) {
|
||||
const {
|
||||
overflow,
|
||||
@@ -56,32 +55,35 @@
|
||||
overflowY,
|
||||
display
|
||||
} = getComputedStyle(element);
|
||||
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
|
||||
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== 'inline' && display !== 'contents';
|
||||
}
|
||||
const tableElements = /*#__PURE__*/new Set(['table', 'td', 'th']);
|
||||
function isTableElement(element) {
|
||||
return tableElements.has(getNodeName(element));
|
||||
return /^(table|td|th)$/.test(getNodeName(element));
|
||||
}
|
||||
const topLayerSelectors = [':popover-open', ':modal'];
|
||||
function isTopLayer(element) {
|
||||
return topLayerSelectors.some(selector => {
|
||||
try {
|
||||
return element.matches(selector);
|
||||
} catch (_e) {
|
||||
return false;
|
||||
try {
|
||||
if (element.matches(':popover-open')) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
} catch (_e) {
|
||||
// no-op
|
||||
}
|
||||
try {
|
||||
return element.matches(':modal');
|
||||
} catch (_e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
const transformProperties = ['transform', 'translate', 'scale', 'rotate', 'perspective'];
|
||||
const willChangeValues = ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'];
|
||||
const containValues = ['paint', 'layout', 'strict', 'content'];
|
||||
const willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
|
||||
const containRe = /paint|layout|strict|content/;
|
||||
const isNotNone = value => !!value && value !== 'none';
|
||||
let isWebKitValue;
|
||||
function isContainingBlock(elementOrCss) {
|
||||
const webkit = isWebKit();
|
||||
const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss;
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
||||
// https://drafts.csswg.org/css-transforms-2/#individual-transforms
|
||||
return transformProperties.some(value => css[value] ? css[value] !== 'none' : false) || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || willChangeValues.some(value => (css.willChange || '').includes(value)) || containValues.some(value => (css.contain || '').includes(value));
|
||||
return isNotNone(css.transform) || isNotNone(css.translate) || isNotNone(css.scale) || isNotNone(css.rotate) || isNotNone(css.perspective) || !isWebKit() && (isNotNone(css.backdropFilter) || isNotNone(css.filter)) || willChangeRe.test(css.willChange || '') || containRe.test(css.contain || '');
|
||||
}
|
||||
function getContainingBlock(element) {
|
||||
let currentNode = getParentNode(element);
|
||||
@@ -96,12 +98,13 @@
|
||||
return null;
|
||||
}
|
||||
function isWebKit() {
|
||||
if (typeof CSS === 'undefined' || !CSS.supports) return false;
|
||||
return CSS.supports('-webkit-backdrop-filter', 'none');
|
||||
if (isWebKitValue == null) {
|
||||
isWebKitValue = typeof CSS !== 'undefined' && CSS.supports && CSS.supports('-webkit-backdrop-filter', 'none');
|
||||
}
|
||||
return isWebKitValue;
|
||||
}
|
||||
const lastTraversableNodeNames = /*#__PURE__*/new Set(['html', 'body', '#document']);
|
||||
function isLastTraversableNode(node) {
|
||||
return lastTraversableNodeNames.has(getNodeName(node));
|
||||
return /^(html|body|#document)$/.test(getNodeName(node));
|
||||
}
|
||||
function getComputedStyle(element) {
|
||||
return getWindow(element).getComputedStyle(element);
|
||||
@@ -157,8 +160,9 @@
|
||||
if (isBody) {
|
||||
const frameElement = getFrameElement(win);
|
||||
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
|
||||
} else {
|
||||
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
||||
}
|
||||
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
||||
}
|
||||
function getFrameElement(win) {
|
||||
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
||||
|
||||
Reference in New Issue
Block a user