Skip to content
This repository was archived by the owner on Jul 23, 2024. It is now read-only.

Commit 235d93c

Browse files
committed
Add the node information to the issue
1 parent 9403221 commit 235d93c

2 files changed

Lines changed: 35 additions & 6 deletions

File tree

extension/experiments/inspectedNode/api.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ this.inspectedNode = class extends ExtensionAPI {
6666
const { actorID: ruleId } = rule;
6767
let { declarations } = rule;
6868
declarations = declarations.filter(d => !d.commentOffsets);
69-
return declarations.length ? { ruleId, declarations } : null;
69+
return declarations.length
70+
? { ruleId, declarations, node: _getNodeInfo(node) }
71+
: null;
7072
}).filter(rule => !!rule);
7173
};
7274

@@ -98,8 +100,23 @@ this.inspectedNode = class extends ExtensionAPI {
98100
};
99101

100102
const _getNodeInfo = node => {
101-
const { attributes, nodeName, nodeType, customElementLocation } = node;
102-
return { attributes, nodeName, nodeType, isCustomElement: !!customElementLocation };
103+
const {
104+
id,
105+
className,
106+
attributes,
107+
nodeName,
108+
nodeType,
109+
customElementLocation,
110+
} = node;
111+
112+
return {
113+
id,
114+
className: className.trim(),
115+
attributes,
116+
nodeName,
117+
nodeType,
118+
isCustomElement: !!customElementLocation,
119+
};
103120
};
104121

105122
const _getNode = async (clientId) => {

extension/sidebar-pane.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,28 @@ async function _updateSubtree(selectedNode) {
6262

6363
const { attributes, nodeName } = node;
6464
issues.push(
65-
..._webcompat.getHTMLElementIssues(nodeName, attributes, _targetBrowsers));
65+
...
66+
_webcompat.getHTMLElementIssues(nodeName, attributes, _targetBrowsers)
67+
.map(issue => {
68+
issue.node = node;
69+
return issue;
70+
})
71+
)
6672
}
6773

6874
progressEl.textContent = "Getting all descendants of the selected node";
6975
const declarationBlocks = await browser.experiments.inspectedNode.getStylesInSubtree();
7076

7177
progressEl.textContent = "Getting web compatibility issues for CSS styles";
72-
for (const { declarations } of declarationBlocks) {
78+
for (const { node, declarations } of declarationBlocks) {
7379
issues.push(
74-
..._webcompat.getCSSDeclarationBlockIssues(declarations, _targetBrowsers));
80+
...
81+
_webcompat.getCSSDeclarationBlockIssues(declarations, _targetBrowsers)
82+
.map(issue => {
83+
issue.node = node;
84+
return issue;
85+
})
86+
)
7587
}
7688

7789
progressEl.textContent = "Rendering all issues";

0 commit comments

Comments
 (0)