Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prise en compte du shadow-dom #79

Open
AlexTraveylan opened this issue Nov 28, 2024 · 0 comments
Open

Prise en compte du shadow-dom #79

AlexTraveylan opened this issue Nov 28, 2024 · 0 comments

Comments

@AlexTraveylan
Copy link

AlexTraveylan commented Nov 28, 2024

description

Le shadom-dom se matérialise ainsi dans le html :

image

Il est ignoré par l'extension.

Reproduire

Sur le site web https://candidat.francetravail.fr/inscription-en-ligne/ par exemple, on trouve du shadow-dom, Green-it mesure un dom à 270 alors que le vrai dom est à 780.

image

Pistes

  • Lighthouse recupere la bonne taille de dom
  • Cette fonction permet d'obtenir la bonne taille en tenant en compte le shadow-dom
const countShadom = () => {
    const countElements = (element) => {
	let count = 1;
	Array.from(element.children).forEach(child => {
		count += countElements(child);
	});

	if (element.shadowRoot) {
	    Array.from(element.shadowRoot.children).forEach(sChild => {
	        count += countElements(sChild);
	    });
	}
    return count;
    };
	
    return countElements(document.body)
}
AlexTraveylan pushed a commit to AlexTraveylan/GreenIT-Analysis that referenced this issue Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant