support angular click event (#3960)
This commit is contained in:
@@ -989,6 +989,14 @@ function isInteractable(element, hoverStylesMap) {
|
|||||||
_jsConsoleError("Error getting jQuery click events:", e);
|
_jsConsoleError("Error getting jQuery click events:", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (hasAngularClickEvent(element)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_jsConsoleError("Error checking angular click event:", e);
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1133,6 +1141,33 @@ function hasNgAttribute(element) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: it's a hack, should continue to optimize it
|
||||||
|
function hasAngularClickEvent(element) {
|
||||||
|
const ctx = element.__ngContext__;
|
||||||
|
const tView = ctx && ctx[1];
|
||||||
|
if (!tView || !Array.isArray(tView.data)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const tagName = element.tagName.toLowerCase();
|
||||||
|
if (!tagName) {
|
||||||
|
_jsConsoleLog("Element has no tag name: ", element);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const tNode of tView.data) {
|
||||||
|
if (!tNode || typeof tNode !== "object") continue;
|
||||||
|
if (tNode.type !== 0 && tNode.type !== 2) continue; // 0: Element, 2: Container
|
||||||
|
if (tNode.value && tagName !== tNode.value.toLowerCase()) continue;
|
||||||
|
if (!Array.isArray(tNode.attrs)) continue;
|
||||||
|
if (tNode.attrs.includes("click")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
function isAngularMaterial(element) {
|
function isAngularMaterial(element) {
|
||||||
if (!element.attributes[Symbol.iterator]) {
|
if (!element.attributes[Symbol.iterator]) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user