add angualar date picker support (#1955)

Co-authored-by: lawyzheng <lawyzheng1106@gmail.com>
This commit is contained in:
Shuchang Zheng
2025-03-17 12:12:16 -07:00
committed by GitHub
parent 2dbc00385f
commit 6cc595d04c
3 changed files with 71 additions and 15 deletions

View File

@@ -920,6 +920,19 @@ function hasNgAttribute(element) {
return false;
}
function isAngularMaterial(element) {
if (!element.attributes[Symbol.iterator]) {
return false;
}
for (let attr of element.attributes) {
if (attr.name.startsWith("mat")) {
return true;
}
}
return false;
}
const isAngularDropdown = (element) => {
if (!hasNgAttribute(element)) {
return false;
@@ -936,6 +949,20 @@ const isAngularDropdown = (element) => {
return false;
};
const isAngularMaterialDatePicker = (element) => {
if (!isAngularMaterial(element)) {
return false;
}
const tagName = element.tagName.toLowerCase();
if (tagName !== "input") return false;
return (
(element.closest("mat-datepicker") ||
element.closest("mat-formio-date")) !== null
);
};
function getPseudoContent(element, pseudo) {
const pseudoStyle = getElementComputedStyle(element, pseudo);
if (!pseudoStyle) {
@@ -1325,6 +1352,7 @@ async function buildElementObject(
isDivComboboxDropdown(element) ||
isDropdownButton(element) ||
isAngularDropdown(element) ||
isAngularMaterialDatePicker(element) ||
isSelect2Dropdown(element) ||
isSelect2MultiChoice(element),
isCheckable: isCheckableDiv(element),