Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.

Commit

Permalink
perf: lazy load of images in HTML report for retries
Browse files Browse the repository at this point in the history
  • Loading branch information
kvmamich committed May 3, 2017
1 parent eda123b commit 754368a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/reporters/html/static/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Clipboard = require('clipboard');

function expandAll() {
loadLazyImages(document, '.section_collapsed img');
loadLazyImages(document, '.section_collapsed .tab__item_active img');
forEach.call(sections, function(section) {
section.classList.remove('section_collapsed');
});
Expand All @@ -22,8 +22,8 @@
}

function expandErrors() {
loadLazyImages(document, '.section_status_fail > .section__body > .image-box img');
loadLazyImages(document, '.section_status_warning > .section__body > .image-box img');
loadLazyImages(document, '.section_status_fail > .section__body > .image-box .tab__item_active img');
loadLazyImages(document, '.section_status_warning > .section__body > .image-box .tab__item_active img');
forEach.call(sections, function(section) {
if (section.classList.contains('section_status_fail') ||
section.classList.contains('section_status_warning')) {
Expand All @@ -35,7 +35,7 @@
}

function expandRetries() {
loadLazyImages(document, '.has-retries > .section__body > .image-box img');
loadLazyImages(document, '.has-retries > .section__body > .image-box .tab__item_active img');
forEach.call(sections, function(section) {
if (section.classList.contains('has-retries')) {
section.classList.remove('section_collapsed');
Expand Down Expand Up @@ -66,6 +66,7 @@

switch_(imageBox.querySelector('.tab'), 'tab__item_active');
switch_(imageBox.querySelector('.tab-switcher'), 'tab-switcher__button_active');
loadLazyImages(imageBox, '.tab__item_active img');

function switch_(elem, selector) {
forEach.call(elem.children, function(item) {
Expand Down Expand Up @@ -190,7 +191,7 @@

forEach.call(document.querySelectorAll('.section'), function(section) {
section.querySelector('.section__title').addEventListener('click', function() {
loadLazyImages(section, ':scope > .section__body > .image-box img');
loadLazyImages(section, ':scope > .section__body > .image-box .tab__item_active img');
section.classList.toggle('section_collapsed');
});
});
Expand Down

0 comments on commit 754368a

Please sign in to comment.