fix: extract attributes for heuristically-detected interactive elements
Elements detected as interactive via heuristic methods (cursor:pointer style, interactive class names, event listeners) had empty attributes because `isInteractiveCandidate()` was used as the gate for attribute extraction. This function only recognizes standard HTML tags and ARIA attributes, missing heuristic detections. After interactivity is confirmed by `isInteractiveElement()`, backfill attributes for elements that were missed. This ensures `includeAttributes` (e.g. `['class']`) works correctly for all interactive elements, not just semantically standard ones. Closes #124 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1608,6 +1608,18 @@ export default (
|
||||
* @edit direct dom ref
|
||||
*/
|
||||
nodeData.ref = node
|
||||
|
||||
// Extract attributes for heuristically-detected interactive elements
|
||||
// isInteractiveCandidate() only covers standard tags and ARIA attributes,
|
||||
// so elements detected via cursor:pointer, class names, or event listeners
|
||||
// may have empty attributes. Fill them in so include_attributes works.
|
||||
if (nodeData.isInteractive && Object.keys(nodeData.attributes).length === 0) {
|
||||
const attributeNames = node.getAttributeNames?.() || []
|
||||
for (const name of attributeNames) {
|
||||
const value = node.getAttribute(name)
|
||||
nodeData.attributes[name] = value
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user