Skip to content

Commit

Permalink
feat: update of the plugin to use DOMInformations
Browse files Browse the repository at this point in the history
  • Loading branch information
hrenaud committed Apr 9, 2024
1 parent e80e8c2 commit 31edba3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
14 changes: 7 additions & 7 deletions lighthouse-plugin-ecoindex/audits/commons.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export default {
requiredArtifacts: [
'MainDocumentContent',
'DOMStats',
'devtoolsLogs',
'DOMInformations',
]
}
requiredArtifacts: [
'MainDocumentContent',
'DOMStats',
'devtoolsLogs',
'DOMInformations',
],
}
22 changes: 11 additions & 11 deletions lighthouse-plugin-ecoindex/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ export const B_TO_KB = 1000
* @returns number
*/
export async function getEcoindexNodes(artifacts) {
if (!artifacts.DOMInformations) {
// throw new Error(
// "DOMInformations not found, EcoindexNodes can't be calculated.",
// )
const MainDocumentContent = artifacts.MainDocumentContent
const dom = new JSDOM(MainDocumentContent)
const allNodes = dom.window.document.querySelectorAll('*').length
const svgContentNodes = dom.window.document.querySelectorAll('svg *').length
return allNodes - svgContentNodes
}
// if (!artifacts.DOMInformations) {
// throw new Error(
// "DOMInformations not found, EcoindexNodes can't be calculated.",
// )
// const MainDocumentContent = artifacts.MainDocumentContent
// const dom = new JSDOM(MainDocumentContent)
// const allNodes = dom.window.document.querySelectorAll('*').length
// const svgContentNodes = dom.window.document.querySelectorAll('svg *').length
// return allNodes - svgContentNodes
// }
const domInformations = artifacts.DOMInformations
console.debug(`domInformations`, domInformations)
// console.debug(`domInformations`, domInformations)
return domInformations.nodesBodyWithoutSVGChildsCount
}

Expand Down

0 comments on commit 31edba3

Please sign in to comment.