Full support for classes

This commit is contained in:
Thomas Forgione 2023-02-17 11:25:36 +01:00
parent 9a66c7c491
commit b1c3d6a630
1 changed files with 8 additions and 2 deletions

View File

@ -80,12 +80,18 @@ async function main() {
let shouldCreateSpan = query !== "ul" && query !== "ol" && query != "img"; let shouldCreateSpan = query !== "ul" && query !== "ol" && query != "img";
// Query the considered element // Query the considered element
let parents = await page.$$(query);
let elements = await page.$$(query + (shouldCreateSpan ? ' > *:first-child' : '')); let elements = await page.$$(query + (shouldCreateSpan ? ' > *:first-child' : ''));
for (let element of elements) { for (let index = 0; index < elements.length; index ++) {
let parent = parents[index];
let element = elements[index];
let box = await element.boundingBox(); let box = await element.boundingBox();
let classNameAttr = await element.getProperty('className');
let classElement = shouldCreateSpan ? parent : element;
let classNameAttr = await classElement.getProperty('className');
let className = await classNameAttr.jsonValue(); let className = await classNameAttr.jsonValue();
// Scale the bounding box // Scale the bounding box