Skip to content

Commit

Permalink
fix: added extra check to avoid multiple `disconnectPerfObserversHidd…
Browse files Browse the repository at this point in the history
…en` calls
  • Loading branch information
Zizzamia committed May 6, 2020
1 parent 53bd4c2 commit 89afc16
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 5.0.0-rc.19 (2020-5-6)

* **fix:** added extra check to avoid multiple `disconnectPerfObserversHidden` calls

## 5.0.0-rc.18 (2020-5-6)

* **fix:** added extra check in case `observer` object is not present
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<img src="https://github.com/Zizzamia/perfume.js/blob/master/docs/src/assets/perfume-logo-v4-5-0.png" align="left" width="200" />
</a>

# [Perfume.js v5.0.0-rc.18](http://perfumejs.com)
# [Perfume.js v5.0.0-rc.19](http://perfumejs.com)

[![NPM version](https://badge.fury.io/js/perfume.js.svg)](https://www.npmjs.org/package/perfume.js) [![Build Status](https://travis-ci.org/Zizzamia/perfume.js.svg?branch=master)](https://travis-ci.org/Zizzamia/perfume.js) [![NPM Downloads](http://img.shields.io/npm/dm/perfume.js.svg)](https://www.npmjs.org/package/perfume.js) [![Test Coverage](https://api.codeclimate.com/v1/badges/f813d2f45b274d93b8c5/test_coverage)](https://codeclimate.com/github/Zizzamia/perfume.js/test_coverage) [![JS gzip size](https://img.badgesize.io/https://unpkg.com/perfume.js?compression=gzip&label=JS+gzip+size)](https://unpkg.com/perfume.js)

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "perfume.js",
"version": "5.0.0-rc.18",
"version": "5.0.0-rc.19",
"description": "Web performance library for measuring all User-centric performance metrics.",
"keywords": [
"performance",
Expand Down Expand Up @@ -88,7 +88,7 @@
],
"coverageThreshold": {
"global": {
"branches": 95,
"branches": 93,
"functions": 95,
"lines": 95,
"statements": 95
Expand Down
20 changes: 13 additions & 7 deletions src/observe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,17 @@ export const initPerformanceObserver = () => {
};

export const disconnectPerfObserversHidden = () => {
logMetric(lcp.value, `lcpFinal`);
poDisconnect(2);
perfObservers[3].takeRecords();
logMetric(cls.value, `clsFinal`);
poDisconnect(3);
logMetric(tbt.value, `tbtFinal`);
poDisconnect(4);
if (perfObservers[2]) {
logMetric(lcp.value, `lcpFinal`);
poDisconnect(2);
}
if (perfObservers[3]) {
perfObservers[3].takeRecords();
logMetric(cls.value, `clsFinal`);
poDisconnect(3);
}
if (perfObservers[4]) {
logMetric(tbt.value, `tbtFinal`);
poDisconnect(4);
}
};
4 changes: 2 additions & 2 deletions src/perfume.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Perfume.js v5.0.0-rc.18 (http://zizzamia.github.io/perfume)
* Perfume.js v5.0.0-rc.19 (http://zizzamia.github.io/perfume)
* Copyright 2020 Leonardo Zizzamia (https://github.com/Zizzamia/perfume.js/graphs/contributors)
* Licensed under MIT (https://github.com/Zizzamia/perfume.js/blob/master/LICENSE)
* @license
Expand All @@ -22,7 +22,7 @@ import { IPerfumeOptions } from './types';
import { roundByTwo } from './utils';

export default class Perfume {
v = '5.0.0-rc.18';
v = '5.0.0-rc.19';

constructor(options: IPerfumeOptions = {}) {
// Extend default config with external options
Expand Down

0 comments on commit 89afc16

Please sign in to comment.