in src/performance/fmp.ts [125:168]
private getFmpTime(resultEls: ElementList): number {
let rt = 0;
for (const item of resultEls) {
let time: number = 0;
if (item.weight === 1) {
const index: number = parseInt(item.ele.getAttribute('fmp_c'), 10);
time = this.statusCollector[index] && this.statusCollector[index].time;
} else if (item.weight === 2) {
if (item.ele.tagName === 'IMG') {
time = this.entries[(item.ele as HTMLImageElement).src];
} else if (item.ele.tagName === 'SVG') {
const index: number = parseInt(item.ele.getAttribute('fmp_c'), 10);
time = this.statusCollector[index] && this.statusCollector[index].time;
} else {
const match = getStyle(item.ele, 'background-image').match(/url\(\"(.*?)\"\)/);
let url: string = '';
if (match && match[1]) {
url = match[1];
if (!url.includes('http')) {
url = location.protocol + match[1];
}
}
time = this.entries[url];
}
} else if (item.weight === 4) {
if (item.ele.tagName === 'CANVAS') {
const index: number = parseInt(item.ele.getAttribute('fmp_c'), 10);
time = this.statusCollector[index] && this.statusCollector[index].time;
} else if (item.ele.tagName === 'VIDEO') {
time = this.entries[(item.ele as HTMLVideoElement).src];
if (!time) {
time = this.entries[(item.ele as HTMLVideoElement).poster];
}
}
}
if (typeof time !== 'number') {
time = 0;
}
if (rt < time) {
rt = time;
}
}
return rt;
}