Code to implement CSS coverage test script

不言
Release: 2018-06-28 11:11:53
Original
1502 people have browsed it

This article mainly introduces the code for implementing CSS coverage test scripts. It has certain reference value. Now I share it with you. Friends in need can refer to it.

Here we only ask for CSS rules. Coverage, so just access querySelectorAll().length. By sorting, you can see the usage of each CSS

document.styleSheets stores a collection of all CSS rules on the current page. Through it, you can traverse all selectors defined in the page