Skip to content

Commit

Permalink
fix: miss elements under a div
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyutaotao committed Dec 27, 2024
1 parent 8a8c97f commit 2f1a779
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/web-integration/src/extractor/dom-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ export function isContainerElement(node: Node): node is HTMLElement {
return false;
}

if (includeUserDescribedElement(node)) {
return false;
}

const computedStyle = window.getComputedStyle(node);
const backgroundColor = computedStyle.getPropertyValue('background-color');
if (backgroundColor) {
Expand All @@ -74,6 +78,17 @@ export function isContainerElement(node: Node): node is HTMLElement {
return false;
}

function includeUserDescribedElement(node: Node) {
if (node instanceof Element) {
const selector = `[${USER_DESCRIBED_ELEMENT_ATTRIBUTE_REF}]`;
const elements = node.querySelectorAll(selector);
if (elements.length > 0) {
return true;
}
}
return false;
}

function includeBaseElement(node: Node) {
if (!(node instanceof HTMLElement)) return false;

Expand All @@ -83,6 +98,7 @@ function includeBaseElement(node: Node) {
}

const includeList = [
'canvas',
'svg',
'button',
'input',
Expand Down

0 comments on commit 2f1a779

Please sign in to comment.